All Projects → janhartmann → flight-spotter

janhartmann / flight-spotter

Licence: MIT License
✈️ Real-time Flight Spotter using React, TypeScript, GraphQL, MapBox and The OpenSky Network API

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to flight-spotter

typescript-graphql-postgres-boilerplate
Simple boilerplate integrated typescript, graphql, postgres and apollo server
Stars: ✭ 18 (-60.87%)
Mutual labels:  apollo-server
apollo-chat-graphql-server
Apollo Chat is a Chat Service build on GraphQL Apollo with Subscriptions
Stars: ✭ 13 (-71.74%)
Mutual labels:  apollo-server
erdapfel
Qwant Maps front-end
Stars: ✭ 84 (+82.61%)
Mutual labels:  mapbox-gl-js
graphql-server-typed
Using typescript and gql-code-gen for easy graphql setup
Stars: ✭ 32 (-30.43%)
Mutual labels:  apollo-server
crowdfunding-backend
[DEPRECATED] A crowdfunding backend written with NodeJS, Apollo and PostgreSQL. Features an extensive data model, mult. payment integrations, passwordless auth, statistics and admin endpoints.
Stars: ✭ 23 (-50%)
Mutual labels:  apollo-server
adonis-graphql-server
A GraphQL server built with Apollo server and AdonisJs
Stars: ✭ 31 (-32.61%)
Mutual labels:  apollo-server
serverless-apollo-datasource-redis
Serverless Apollo Server 2 with cached Datasource in Redis
Stars: ✭ 26 (-43.48%)
Mutual labels:  apollo-server
apollo-graphql-tutorial
Learning apollo graphql version 2.x with Node.js
Stars: ✭ 18 (-60.87%)
Mutual labels:  apollo-server
nextjs-typescript-graphql-starter
A Next.js starter with Typescript, Jest, GraphQL Apollo Server & Apollo Client v3 with graphql-codegen.
Stars: ✭ 15 (-67.39%)
Mutual labels:  apollo-server
vue-mapbox-map
A minimalist Vue component wrapping Mapbox GL or MapLibre GL for dynamic interaction!
Stars: ✭ 26 (-43.48%)
Mutual labels:  mapbox-gl-js
graphql-insta-example
Application made to show the basic concepts of GraphQL with Apollo Server
Stars: ✭ 24 (-47.83%)
Mutual labels:  apollo-server
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (-60.87%)
Mutual labels:  mapbox-gl-js
apollo-error-converter
Global Apollo Server Error handling made easy. Remove verbose and repetitive resolver / data source Error handling. Automatic Error catching, logging, and conversion to ApolloErrors.
Stars: ✭ 16 (-65.22%)
Mutual labels:  apollo-server
react-mapboxgl-example
Example on how to use Mapbox GL in a React application
Stars: ✭ 24 (-47.83%)
Mutual labels:  mapbox-gl-js
graphql-typeorm-koa-workshop
Demo GraphQL API server
Stars: ✭ 36 (-21.74%)
Mutual labels:  apollo-server
les-chat
Real-time messenger with private, public & group chat. Made using PERN + GraphQL stack.
Stars: ✭ 48 (+4.35%)
Mutual labels:  apollo-server
impact-tools
Simple blueprints for change-makers
Stars: ✭ 34 (-26.09%)
Mutual labels:  mapbox-gl-js
mongoose-graphql-pagination
GraphQL cursor pagination (Relay-like) for Mongoose models.
Stars: ✭ 29 (-36.96%)
Mutual labels:  apollo-server
hano-graphql
GraphQL, Hapi and Node Project For Scaleable Apps.
Stars: ✭ 13 (-71.74%)
Mutual labels:  apollo-server
now-course
Proyecto para el curso de Now.sh en Platzi
Stars: ✭ 19 (-58.7%)
Mutual labels:  apollo-server

✈️ Real Time Flight Spotter

License: MIT code style: prettier

This is an "full-stack" example (and hopefully a source of inspiration), on how to create a real time flight spotter using React, TypeScript, GraphQL, MapBox and The OpenSky Network API for live flight data tracking.

Screenshot

Live Demo

The interactive map with flights

https://flight-spotter.janhartmann.dk

The server with an active GraphQL Playground

https://flight-spotter-api.janhartmann.dk

Highlights

  • The client is built using React (with hooks) and TypeScript.
  • Strong typings between the client GraphQL queries and the server schema with type generation.
  • JSS for component styling and theming.
  • The map is built using the MapBox GL library, wrapped in custom React components and custom theme.
  • The server is built using Apollo GraphQL Server and in TypeScript.
  • The flight data is fetched from The OpenSky Network, removing the need for a data store.

Prerequisite

  • You will need a MapBox access token in order to display the map. For development and own-use it is perfectly fine to use their free option.
  • (optional, but recommended) In order to have more recent flight data (~5 seconds), create a free account on their website. If you do not have an account the flight data will be around ~10 seconds old.

Development

Start by cloning the repository.

The repository is a mono-repository, meaning it consists of both a client and server. It is possible to install both the server and the clients dependencies by running the following from the root of the repository:

yarn install

Now, create an .env file in the ./server directory containing:

OPENSKY_API_USERNAME=<your-username>
OPENSKY_API_PASSWORD=<your-password>

Then create another .env file in the ./client directory containing:

MAPBOX_ACCESS_TOKEN=<your-token>

To start the development server and client, run from the root of the repository:

yarn start

This will start up the Apollo GraphQL Server (together with a playground) on http://localhost:5000 as well as the client on http://localhost:3000.

GraphQL Schema

Based on The OpenSky Network REST endpoints, we can create the following schema for querying our data:

Schema

Limitations

The flight data is coming from The OpenSky Network and itself has a few limitations, please see their page for more information.

There can be aircraft's which has just grounded but appears to be bypassing an airport, this can happend when we are predicting its flight path, but the aircraft landed on its path towards the airport.

Some flights can have missing data, like route information, trajectories and altitude data being wrong.

Sometimes The OpenSky Network API can be down for a very short period of time, if it is getting a lot of requests at the same time.

FAQ

Predicting flight position using stale data

One of the "limitations" of The OpenSky Network API is that the flight data can be delayed for approximately 5-10 seconds, depending if the request is sent using an registered account.

We are, however, able to predict where the aircraft is going by using its current position, velocity (m/s) and direction it is heading using the Haversine formula.

Thankfully, there exists a great geospatial analysis library Turf.js to help us with this calculation.

Once we have the predicted next destination, we can create a line to the point from the current known position of the aircraft, split it into segments and animate it over a duration until we get the new position from the server.

Trajectory line to the arrival airport

When working with a sphere, like the Earth, and you want to create a line from a-b (or in our case the current position of the aircraft and its destination), it is not just a straight line. We need to take the earths curvature into account. This is done by drawing a line using the Great-circle distance. This is why you see a arch on the e.g. transatlantic flights.

Again, we have Turf.js to help us with this calculation.

GraphQL schema and resolver code-generation

When querying the server for data, we use the GraphQL Code Generator to generate TypeScript typings from the server schema. Both for our resolver types, but also our client query types.

This is done to avoid writing the same things which are already described by the GraphQL schema. When we change the schema or a client query and reboot the server, new types are automatically generated and can be referenced in the code.

Contributions

Have an idea, a bug fix, comments or questions? Open an issue and let's have a talk!

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].