How adityacodes-root/devops-project works
1. This repo is a two-tier containerized web application with a clear split between a Next.js frontend and a FastAPI backend. The application is deployed as separate services rather than a monolith.
2. The backend lives in backend/app/main.py and is a Python/FastAPI service served with Uvicorn. Its unit tests are in backend/app/test_main.py, and dependencies are pinned in backend/requirements.txt.
3. The frontend lives in frontend/pages/index.js and is a Next.js app with server-side rendering. Frontend tests use Jest, with snapshots and setup files under frontend/__tests__, frontend/jest.config.js, and frontend/jest.setup.js.
4. At runtime, the browser talks to the frontend service first. The frontend is the user-facing entry point and is responsible for rendering the page and reaching the backend for application data or API responses.
5. Both tiers are containerized with multi-stage Docker builds (backend/Dockerfile, frontend/Dockerfile). That makes the deployable unit for each service a container image, which is what the cloud platforms run.
6. The repository supports two parallel production deployments:
- AWS: container workloads run on ECS/Fargate behind an Application Load Balancer.
- GCP: container workloads run on Cloud Run with managed HTTPS and autoscaling.
In both cases, the services are provisioned as separate cloud resources for frontend and backend.
7. Terraform is the infrastructure boundary. terraform/aws defines the AWS environment: VPC, security groups, IAM, ECS, ALB, secrets, and CloudWatch monitoring. terraform/gcp defines the GCP environment: Cloud Run, Secret Manager, Cloud Monitoring, and remote state backend configuration.
8. Secrets are not hardcoded in the app. They are injected from AWS Secrets Manager or GCP Secret Manager, depending on the target cloud, which keeps runtime configuration outside the container images.
9. Monitoring is part of the infrastructure layer, not the app layer. AWS uses CloudWatch dashboards/alerts, while GCP uses Cloud Monitoring for service health, latency, and error tracking.
10. GitHub Actions provides the delivery pipeline. .github/workflows/ci.yml runs on develop for test/build validation, and .github/workflows/cd.yml runs on main to build/push images and apply Terraform for deployment.
11. The Terraform state is managed remotely for team use and recovery: S3 on AWS and Google Cloud Storage on GCP, rather than local state files.
12. The main architectural boundaries to show in a diagram are: user/browser, frontend container service, backend API service, cloud runtime/orchestration layer, secrets/monitoring services, and the CI/CD + Terraform control plane that builds and deploys everything.
Main entry points: aws/main.tf AWS stack · gcp/main.tf GCP stack · index.js Frontend · main.py Backend API
Components 18
Application
User-facing frontend and backend services
- Browser · End-user entry point
- Frontend · User-facing web app
frontend/pages/index.js - Frontend image · Multi-stage container for the frontend service
frontend/Dockerfile - Backend API · Python API service
backend/app/main.py - Backend image · Multi-stage container for the backend service
backend/Dockerfile
Infrastructure
Terraform-managed cloud resources and runtime
- AWS stack · AWS deployment boundary
terraform/aws/main.tf - Networking · VPC and security boundary
terraform/aws/vpc.tf - ECS/Fargate · Container orchestration for frontend and backend
terraform/aws/ecs.tf - Load balancer · Public traffic entry and routing
terraform/aws/alb.tf - Secrets · Injected runtime secrets
terraform/aws/secrets.tf - Monitoring · Logs, dashboards, and alerts
terraform/aws/monitoring.tf - GCP stack · GCP deployment boundary
terraform/gcp/main.tf - Cloud Run · Managed container runtime for services
terraform/gcp/cloudrun.tf - Secrets · Injected runtime secrets
terraform/gcp/secrets.tf - Monitoring · Service health and error observability
terraform/gcp/monitoring.tf
Delivery
CI/CD and container build pipeline
- CI · Test and build validation on develop
.github/workflows/ci.yml - CD · Build, push, and deploy on main
.github/workflows/cd.yml - Remote state · Shared remote Terraform state
terraform/gcp/backend.tf
Connections 31
- Browser → Frontend: uses · Browser loads the Next.js app
- Frontend → Backend API: calls · Frontend fetches application data from the API
- Frontend → Frontend image: packaged as · Frontend deploys as a container image
- Backend API → Backend image: packaged as · Backend deploys as a container image
- AWS stack → Networking: defines · Core AWS networking boundary
- AWS stack → ECS/Fargate: defines · AWS container orchestration
- AWS stack → Load balancer: defines · Public routing layer
- AWS stack → Secrets: defines · AWS secret injection
- AWS stack → Monitoring: defines · AWS observability
- Load balancer → Frontend: routes to · Public requests reach the frontend service
- ECS/Fargate → Frontend image: runs · Frontend image runs on ECS/Fargate
- ECS/Fargate → Backend image: runs · Backend image runs on ECS/Fargate
- Secrets → Backend API: injects · Backend runtime configuration comes from secrets
- Monitoring → ECS/Fargate: watches · Monitors container services
- GCP stack → Cloud Run: defines · GCP managed container runtime
- GCP stack → Secrets: defines · GCP secret injection
- GCP stack → Monitoring: defines · GCP observability
- Cloud Run → Frontend image: runs · Frontend image runs on Cloud Run
- Cloud Run → Backend image: runs · Backend image runs on Cloud Run
- Secrets → Backend API: injects · Backend runtime configuration comes from secrets
- Monitoring → Cloud Run: watches · Monitors managed services
- CI → Frontend: tests · Validates frontend code
- CI → Backend API: tests · Validates backend code
- CI → Frontend image: builds · Checks frontend image build
- CI → Backend image: builds · Checks backend image build
- CD → Frontend image: builds/pushes · Produces the deployable frontend image
- CD → Backend image: builds/pushes · Produces the deployable backend image
- CD → AWS stack: applies · Deploys AWS infrastructure with Terraform
- CD → GCP stack: applies · Deploys GCP infrastructure with Terraform
- Remote state → AWS stack: stores state · Remote state backend for AWS deployments
- Remote state → GCP stack: stores state · Remote state backend for GCP deployments