Problem Statement
Starting projects from scratch is slow and tedious. This project serves as a base template for future projects to accelerate the initial setup phase.
Description
A production-style REST API which incorporates data security, AWS cloud deployment, monitoring, and CI/CD workflows through GitHub Actions, preventing broken code deployments, real-time error diagnosis, and sensitive data exposure.
REST API built using FastAPI and PostgreSQL, using Docker to containerise the application, then deployed on AWS EC2. Traefik acting as a reverse proxy, routing traffic to the API.
Tech Stack
- FastAPI: Acts as the pipeline between the traffic requests and the database.
- PostgreSQL: The persistent database for storing data from requests.
- SQLAlchemy: An Object-Relational-Mapper (ORM), used for managing database requests, and mapping Python objects to database tables.
- Docker: Containerises the application and databases, removing dependency issues, improving reproducibility.
- Traefik: Acts as a middleman between public traffic and the API keeping the database and API server private.
- AWS EC2: Virtual machine used for online app deployment.
- GitHub Actions: Workflow CI/CD pipeline automation tool, ensuring all pushed code is functional before deployment.
- Prometheus: Pulls metrics data from app, visualised in Grafana
- Grafana: Visualises metric data from Prometheus in user-friendly UI
- Socket Proxy: Tecnativa socket proxy, for securing access to docker socket
API Endpoints
- API: http://localhost/docs
- Grafana: http://localhost/grafana
- Prometheus: http://localhost/prometheus
- Traefik: http://localhost:80
CI/CD Pipeline
GitHub Actions tests each API Endpoint after each code commit, ensuring each feature works as expected prior to deployment on the EC2 virtual machine.