Project is hosted here - EDIT : The project is no longer accessible online due to the costs of hosting on AWS
This is my solution to Reaktor winter 2022 code challenge. TLDR: Fetch location data from an external api -> Parse the response data -> fetch data from a second external api based on the parsed response -> display second api data on a website
- Poll drones api once every second
- Parse received data and poll pilots api if any NDZ infractions occur
- Update database based on pilot data
- Emit latest pilot data to all clients through Socket.io
Frontend: React.js + TypeScript Backend: Node.js + Typescript DB: PostgreSql
The production application and the database are hosted on AWS ECS and RDS instances. These cloud instances were created using terraform. More information about the deployment can be found further down in this readme.
Monadikuikka images in frontend header were generated by Dall-e.
- Clone the repo with
git clone git@github.com:Melimet/Birdnest-Solution.git
- Go inside the freshly cloned repo and run
docker compose up
in the project root folder. The project is now accessible in http://localhost:3001/ - The project can be shut down with
docker compose down
-
Clone the repo with
git clone git@github.com:Melimet/Birdnest-Solution.git
and go inside the freshly cloned folder -
In order for the app to work, a postgreSQL db must be setup and configured to a environment file. Easiest way to setup postgres is to have docker installed and run
./scripts/dev_db.sh
which starts a docker image running a postgresql database locally. The database can be stopped withdocker stop pgsql-dev
Alternatives to using docker(not recommended) Here is a guide to setup postgres locally. Alternatively postgres can be setup quite easily on a service such as fly.io. -
Configure environment variables in
./backend/.env
. The environment file must be configured so that the app can connect to a postgresql database - Otherwise the app will not run../backend/
contains a.env.pub
file which contains a model .env file with examples..env.pub
must be renamed to.env
If you are using pgsql docker image, ./backend/.env.pub
is already configured correctly, just rename it to .env
- Excecute these commands in project root folder. These commands install required dependencies and start the app.
sh scripts/install_dependencies.sh
sh scripts/build_and_copy_frontend.sh
sh scripts/start.sh
The project can now be accessed in http://localhost:3001/.
CI is implemented through a simplistic Github actions which runs linters and existing tests. On a succesful CI run, the CD pipeline builds a new container image based on the latest commit and pushes it to AWS ECR. If the push to ECR is succesful, a new ECS task definition is created and then deployed with the latest image.
Disclaimer: This is my second time doing anything with AWS and the absolute first time using Terraform, but this project seemed like a good excuse to try them out. I ended up working quite alot on the cloud deployment and this was by far the most challenging part of the project, but the end result was satisfying.
The application is hosted inside an ECS Fargate instance and the production database is hosted in AWS RDS. The deployment in it's entirety is done through Terraform. The deployment files can be viewed in ./terraform
.
Terraform's state is configured to be stored in Terraform cloud. Terraform validates and updates(if necessary) it's own state on each push to Github.
Testing is implemented in the form of unit and integration tests in the backend. E2E tests were considered but seemed to be overkill since frontend has next to no functionalities and only passively displays information.
- For improved scalability, backend could be split in to two separate entities: A poller api that polls the provided apis and writes the pilot info into database and a simple express backend that responds to frontend's api requests.
- Testing could be expanded by quite alot.
Now that the application polls once every second, timestamps update even though they shouldn't.FixedCD pipeline only pushes latest image to ECR, production is not updated right awayFixed