# phatphudo/cs571-final-project architecture

> Architecture diagram of the GitHub repository phatphudo/cs571-final-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phatphudo/cs571-final-project
- Repository: https://github.com/phatphudo/cs571-final-project
- Video tour (about a minute): https://gitdiagram.com/phatphudo/cs571-final-project/video

## Overview

Cloud Native Task API is a FastAPI service for creating and listing users and their tasks, backed by PostgreSQL. Requests enter the API routes, are validated and serialized with Pydantic schemas, and use SQLAlchemy sessions and models for persistence. The service also exposes health and Prometheus metrics endpoints. The README documents local Compose use and a GKE deployment path with Ingress, Cloud SQL connectivity, and managed Prometheus. Source excerpts show route and persistence behavior; deployment relationships below rely on README statements where noted.

Main entry points: [`app/main.py`](https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py) (User and task routes), [`app/database.py`](https://github.com/phatphudo/cs571-final-project/blob/main/app/database.py) (SQLAlchemy sessions), [`k8s/deployment.yaml`](https://github.com/phatphudo/cs571-final-project/blob/main/k8s/deployment.yaml) (GKE deployment), [`app/models.py`](https://github.com/phatphudo/cs571-final-project/blob/main/app/models.py) (User and task models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_routes["User and task routes<br/>[main.py]"]
  node_health["Health endpoint<br/>[main.py]"]
end

subgraph group_domain["Task domain"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
  node_models["User and task models<br/>[models.py]"]
end

subgraph group_storage["Persistence"]
  node_database["SQLAlchemy sessions<br/>[database.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_operations["Operations"]
  node_metrics["Metrics endpoint<br/>[main.py]"]
  node_prometheus["Prometheus"]
  node_grafana["Grafana"]
  node_gke["GKE deployment<br/>[deployment.yaml]"]
  node_ingress["Application ingress<br/>[ingress.yaml]"]
  node_cloudsql["Cloud SQL proxy<br/>[deployment.yaml]"]
  node_managedprom["Managed Prometheus collection"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_routes
node_routes -->|"validates and serializes"| node_schemas
node_routes -->|"queries and writes"| node_models
node_routes -->|"injects sessions"| node_database
node_models -->|"uses base"| node_database
node_database -->|"reads configuration"| node_settings
node_database -->|"connects to"| node_postgres
node_routes -->|"serves health"| node_health
node_prometheus -->|"scrapes"| node_metrics
node_grafana -->|"queries metrics"| node_prometheus
node_client -->|"enters through"| node_ingress
node_ingress -->|"routes traffic"| node_gke
node_gke -->|"runs sidecar"| node_cloudsql
node_cloudsql -->|"connects to"| node_postgres
node_managedprom -->|"collects metrics"| node_gke

click node_routes "https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py"
click node_health "https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py"
click node_metrics "https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py"
click node_schemas "https://github.com/phatphudo/cs571-final-project/blob/main/app/schemas.py"
click node_models "https://github.com/phatphudo/cs571-final-project/blob/main/app/models.py"
click node_database "https://github.com/phatphudo/cs571-final-project/blob/main/app/database.py"
click node_settings "https://github.com/phatphudo/cs571-final-project/blob/main/app/settings.py"
click node_gke "https://github.com/phatphudo/cs571-final-project/blob/main/k8s/deployment.yaml"
click node_ingress "https://github.com/phatphudo/cs571-final-project/blob/main/k8s/ingress.yaml"
click node_cloudsql "https://github.com/phatphudo/cs571-final-project/blob/main/k8s/deployment.yaml"
click node_managedprom "https://github.com/phatphudo/cs571-final-project/blob/main/k8s/managed-prometheus-podmonitoring.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_health,node_client toneBlue
class node_schemas,node_models toneAmber
class node_database,node_settings,node_postgres toneMint
class node_metrics,node_prometheus,node_grafana,node_gke,node_ingress,node_cloudsql,node_managedprom toneRose
```

## Components

### API surface

- [User and task routes](https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py): `app/main.py`
- [Health endpoint](https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py): `app/main.py`

### Task domain

- [Request and response schemas](https://github.com/phatphudo/cs571-final-project/blob/main/app/schemas.py): `app/schemas.py`
- [User and task models](https://github.com/phatphudo/cs571-final-project/blob/main/app/models.py): `app/models.py`

### Persistence

- [SQLAlchemy sessions](https://github.com/phatphudo/cs571-final-project/blob/main/app/database.py): `app/database.py`
- [Runtime settings](https://github.com/phatphudo/cs571-final-project/blob/main/app/settings.py): `app/settings.py`
- **PostgreSQL**

### Operations

- [Metrics endpoint](https://github.com/phatphudo/cs571-final-project/blob/main/app/main.py): `app/main.py`
- **Prometheus**
- **Grafana**
- [GKE deployment](https://github.com/phatphudo/cs571-final-project/blob/main/k8s/deployment.yaml): `k8s/deployment.yaml`
- [Application ingress](https://github.com/phatphudo/cs571-final-project/blob/main/k8s/ingress.yaml): `k8s/ingress.yaml`
- [Cloud SQL proxy](https://github.com/phatphudo/cs571-final-project/blob/main/k8s/deployment.yaml): `k8s/deployment.yaml`
- [Managed Prometheus collection](https://github.com/phatphudo/cs571-final-project/blob/main/k8s/managed-prometheus-podmonitoring.yaml): `k8s/managed-prometheus-podmonitoring.yaml`

### Other components

- **API client**

## Connections

- API client → User and task routes: sends requests (evidence: `app/main.py`)
- User and task routes → Request and response schemas: validates and serializes (evidence: `app/main.py`)
- User and task routes → User and task models: queries and writes (evidence: `app/main.py`)
- User and task routes → SQLAlchemy sessions: injects sessions (evidence: `app/main.py`)
- User and task models → SQLAlchemy sessions: uses base (evidence: `app/models.py`)
- SQLAlchemy sessions → Runtime settings: reads configuration (evidence: `app/database.py`)
- SQLAlchemy sessions → PostgreSQL: connects to (evidence: `README.md`)
- User and task routes → Health endpoint: serves health (evidence: `app/main.py`)
- Prometheus → Metrics endpoint: scrapes (evidence: `README.md`)
- Grafana → Prometheus: queries metrics (evidence: `README.md`)
- API client → Application ingress: enters through (evidence: `README.md`)
- Application ingress → GKE deployment: routes traffic (evidence: `README.md`)
- GKE deployment → Cloud SQL proxy: runs sidecar (evidence: `README.md`)
- Cloud SQL proxy → PostgreSQL: connects to (evidence: `README.md`)
- Managed Prometheus collection → GKE deployment: collects metrics (evidence: `README.md`)
