This application has to parts -
- Front end - It has the display logic, allows person to log in, see and interact with map UI.
- Back end - It allows to interact with the vehicles, returns minified data for display of on the map UI, detailed data when we have clicked on one vehicle.
Simulation parts -
- Data ingestion - This is just a script which updates the coordinates and meta info of vehicles routinely.
Constriants - 20,000 Vehicles 6 hr interval between updates, ~ 1 update per second
As the data is not really realtime, we can add cache in the endpoint which gets all vehicle data.
As another optimization, we could add a consilidator for updates. Example - Group updates in 10 seconds and run all operations together. (Not implementing it right now)
- /update/{vehicle_id} [PUT] Upsert data
- /vehicle/{vehicle_id} [GET] Get vehicle detail (Protected by auth)
- /geo.json [GET] Get an optimized and condensed geojson file (Protected by auth)
- /login [POST] Authenticates a uses, returns JWT bearer token
Uses react, has sinlge screen which goes away after login.
Map box will get the geojson from the link. it requires authentication using Bearer token.
Simple script that loops over all numbers from 1 to 20k and upserts data for vehicle for that ID
Commands to setup a mysql database for vehicles
- run
pip install Flask PyJWT SQLAlchemy
- Source src/vars.sh
- Run
python src/backend/main.py
- Run
python src/data_pusher/pusher.py
- cd into src/frontend
- run
npm i
- run
npm run start