Skip to content

Latest commit

 

History

History
86 lines (77 loc) · 7.01 KB

File metadata and controls

86 lines (77 loc) · 7.01 KB

Architecture

System Overview

This project implements a production-ready cloud-native API with full observability and infrastructure as code.

┌─────────────────────────────────────────────────────────────────────┐
│                        AWS Cloud (us-east-1)                        │
│                                                                     │
│  ┌─────────────────────────────────────────────────────────────┐   │
│  │                    VPC (10.0.0.0/16)                         │   │
│  │                                                              │   │
│  │  ┌──────────┐    ┌─────────────────────────────────────┐    │   │
│  │  │ Internet │    │     Application Load Balancer        │    │   │
│  │  │ Gateway  │───▶│     (HTTP :80 → Target Group)       │    │   │
│  │  └──────────┘    └─────────────┬───────────────────────┘    │   │
│  │                                │                             │   │
│  │              ┌─────────────────┼─────────────────┐          │   │
│  │              │                 │                  │          │   │
│  │   ┌──────────▼──────┐  ┌──────▼───────────┐     │          │   │
│  │   │  Subnet AZ-1    │  │  Subnet AZ-2     │     │          │   │
│  │   │  10.0.1.0/24    │  │  10.0.2.0/24     │     │          │   │
│  │   │                 │  │                   │     │          │   │
│  │   │ ┌─────────────┐ │  │ ┌──────────────┐ │     │          │   │
│  │   │ │ ECS Fargate │ │  │ │ ECS Fargate  │ │     │          │   │
│  │   │ │   Task #1   │ │  │ │   Task #2    │ │     │          │   │
│  │   │ │  (API:8000) │ │  │ │  (API:8000)  │ │     │          │   │
│  │   │ └─────────────┘ │  │ └──────────────┘ │     │          │   │
│  │   └─────────────────┘  └──────────────────┘     │          │   │
│  │                                                  │          │   │
│  │   ECS Cluster (Container Insights enabled)       │          │   │
│  │                                                              │   │
│  └─────────────────────────────────────────────────────────────┘   │
│                                                                     │
│  ┌──────────────┐    ┌──────────────────┐                          │
│  │     ECR      │    │   CloudWatch     │                          │
│  │  (Images)    │    │   (Logs: 30d)    │                          │
│  └──────────────┘    └──────────────────┘                          │
└─────────────────────────────────────────────────────────────────────┘

Local Development Stack

┌─────────────────────────────────────────────────────────┐
│                  Docker Compose Network                   │
│                                                          │
│  ┌──────────────┐   ┌─────────────┐   ┌──────────────┐ │
│  │   FastAPI     │   │ Prometheus  │   │   Grafana    │ │
│  │   :8000       │──▶│   :9090     │──▶│   :3000      │ │
│  │               │   │  (scrape    │   │  (visualize  │ │
│  │  /health      │   │   /metrics) │   │   metrics)   │ │
│  │  /metrics     │   └─────────────┘   └──────────────┘ │
│  │  /docs        │                                       │
│  └──────────────┘   ┌─────────────┐                     │
│                      │ LocalStack  │                     │
│                      │   :4566     │                     │
│                      │ (AWS Mock)  │                     │
│                      └─────────────┘                     │
└─────────────────────────────────────────────────────────┘

CI/CD Pipeline Flow

  Push to GitHub
       │
       ▼
  ┌─────────┐     ┌──────────┐     ┌───────────────┐     ┌──────────────┐     ┌──────────┐
  │  Lint   │────▶│  Test    │────▶│ Security Scan │────▶│ Docker Build │────▶│ Push ECR │
  │ (ruff)  │     │ (pytest) │     │   (Trivy)     │     │ (Distroless) │     │ (AWS)    │
  └─────────┘     │ cov ≥80% │     │ CRITICAL/HIGH │     └──────────────┘     └──────────┘
                  └──────────┘     └───────────────┘

Key Design Decisions

Decision Rationale
Distroless runtime No shell = no RCE attack vector. Image ~80MB vs ~900MB
Multi-AZ deployment Tasks distributed across 2 AZs for high availability
Prometheus pull model API exposes /metrics; Prometheus scrapes every 10s
Structured JSON logging Machine-parseable logs for CloudWatch / ELK / Datadog
Health check separation /health (liveness) vs /ready (readiness) per K8s/ECS best practices
LocalStack for testing Full AWS emulation without credentials or costs