# maheshgummul9/pythoncoffeeapp architecture

> Architecture diagram of the GitHub repository maheshgummul9/pythoncoffeeapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maheshgummul9/pythoncoffeeapp
- Repository: https://github.com/maheshgummul9/pythoncoffeeapp

## Overview

#### Purpose and Entry Point
SecureCart is a FastAPI-rendered coffee/snacks storefront used to demonstrate a resilient AWS deployment. The application handles catalog browsing, session cart operations, checkout, JSON product APIs, and an ALB-facing health check. Its executable entry point is `app/main.py`; local startup uses Uvicorn against the exported FastAPI application.

#### HTTP Application Layer
`app/main.py` is the central application boundary: it defines page routes (`/`, products, cart, checkout), mutation routes for cart changes and order completion, JSON product endpoints, and `/health`. It coordinates request handling, persistence access, cart/session behavior, and Jinja rendering.
- `app/main.py`
- `templates/home.html`
- `templates/checkout.html`

#### Server-Rendered Storefront
The browser-facing UI is server-rendered with Jinja templates. Shared page layout and styling are separated from route logic, while catalog, product detail, cart, checkout, and successful-order views represent the main customer flow.
- `templates/base.html`
- `templates/product.html`
- `templates/cart.html`
- `static/style.css`

#### Commerce Data Boundaries
The intended persistence split is relational product/order data versus high-frequency cart and session state. Locally, the application begins with SQLite and seeds an initial eight-product catalog; production switches relational storage through `DATABASE_URL` to RDS PostgreSQL. DynamoDB is the planned/production boundary for cart and session reads/writes.
- `app/main.py`
- `requirements.txt`

#### Request and Checkout Flow
A customer request enters the FastAPI app, which retrieves product data and renders templates or returns JSON. Cart add/update/remove operations mutate session/cart state; checkout reads that state, persists the resulting order in the relational store, then renders a success page. `/health` is intentionally isolated as a lightweight liveness target for the load balancer.
- `app/main.py`
- `templates/cart.html`
- `templates/success.html`

#### AWS Edge, Compute, and Network
Production traffic is designed to flow Route 53 → AWS WAF → Application Load Balancer → EC2 Auto Scaling Group. Instances run the FastAPI/Uvicorn service across two Availability Zones. Application and database tiers reside in private VPC subnets, preventing direct internet access; the ALB is the public application ingress.
- `architecture/securecart_architecture.png`
- `app/main.py`

#### Reliability, Security, and Operations
RDS PostgreSQL uses Multi-AZ deployment for relational-data availability; EC2 Auto Scaling removes a single compute-instance dependency. IAM roles enforce workload access, Secrets Manager supplies sensitive values such as database credentials, and CloudWatch provides logs and alarms. Static assets are intended for S3 delivery, while Route 53 provides DNS and WAF filters malicious edge traffic.
- `architecture/securecart_architecture.png`
- `static/style.css`

Main entry points: [`app/main.py`](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py) (FastAPI / Uvicorn), [`templates/product.html`](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/templates/product.html) (Jinja Storefront Views), [`static/style.css`](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/static/style.css) (Storefront Styling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Public Edge"]
  node_route53["Route 53<br/>dns"]
  node_waf["AWS WAF<br/>edge firewall"]
  node_alb["Application Load Balancer<br/>public ingress"]
end

subgraph group_compute["Private Application Tier"]
  node_ec2_asg{{"EC2 Auto Scaling Group<br/>compute fleet"}}
  node_fastapi["FastAPI / Uvicorn<br/>HTTP application<br/>[main.py]"]
  node_jinja_views["Jinja Storefront Views<br/>server-rendered UI<br/>[product.html]"]
  node_static_assets["Storefront Styling<br/>static assets<br/>[style.css]"]
  node_product_api["Product JSON API<br/>HTTP API<br/>[main.py]"]
  node_checkout["Checkout and Order Completion<br/>application flow<br/>[main.py]"]
end

subgraph group_data["State and Data"]
  node_catalog_orders[("Product and Order Store<br/>relational data<br/>[main.py]")]
  node_rds[("RDS PostgreSQL Multi-AZ<br/>production database")]
  node_cart_sessions[("DynamoDB Cart and Sessions<br/>session state<br/>[main.py]")]
  node_s3[("S3 Static Assets<br/>object storage")]
end

subgraph group_operations["Security and Operations"]
  node_secrets["Secrets Manager<br/>secret store"]
  node_iam["IAM Roles<br/>access control"]
  node_cloudwatch["CloudWatch<br/>observability"]
end

node_browser(("Customer Browser<br/>client"))

node_browser -->|"store request"| node_route53
node_route53 -->|"DNS traffic"| node_waf
node_waf -->|"filtered HTTPS"| node_alb
node_alb -->|"forwards requests"| node_ec2_asg
node_alb -.->|"/health"| node_fastapi
node_ec2_asg -->|"runs"| node_fastapi
node_fastapi -->|"renders pages"| node_jinja_views
node_fastapi -->|"serves JSON"| node_product_api
node_fastapi -->|"handles checkout"| node_checkout
node_fastapi -->|"reads products and orders"| node_catalog_orders
node_fastapi -->|"mutates cart state"| node_cart_sessions
node_checkout -->|"persists order"| node_catalog_orders
node_catalog_orders -.->|"production backend"| node_rds
node_browser -.->|"loads static assets"| node_s3
node_s3 -.->|"delivers"| node_static_assets
node_secrets -->|"provides credentials"| node_fastapi
node_iam -->|"workload permissions"| node_fastapi
node_fastapi -->|"logs and metrics"| node_cloudwatch

click node_fastapi "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py"
click node_jinja_views "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/templates/product.html"
click node_static_assets "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/static/style.css"
click node_product_api "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py"
click node_checkout "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py"
click node_catalog_orders "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py"
click node_cart_sessions "https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py"

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_route53,node_waf,node_alb toneBlue
class node_ec2_asg,node_fastapi,node_jinja_views,node_static_assets,node_product_api,node_checkout toneAmber
class node_catalog_orders,node_rds,node_cart_sessions,node_s3 toneMint
class node_secrets,node_iam,node_cloudwatch toneRose
class node_browser toneNeutral
```

## Components

### Public Edge

- **Route 53**: dns
- **AWS WAF**: edge firewall
- **Application Load Balancer**: public ingress · Routes traffic and checks /health.

### Private Application Tier

EC2 instances run across two Availability Zones.

- **EC2 Auto Scaling Group**: compute fleet
- [FastAPI / Uvicorn](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py): HTTP application · Routes pages, mutations, JSON APIs, checkout, and health checks. · `app/main.py`
- [Jinja Storefront Views](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/templates/product.html): server-rendered UI · Catalog, product, cart, checkout, and order-success pages. · `templates/product.html`
- [Storefront Styling](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/static/style.css): static assets · `static/style.css`
- [Product JSON API](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py): HTTP API · `app/main.py`
- [Checkout and Order Completion](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py): application flow · Converts cart state into a persisted order. · `app/main.py`

### State and Data

- [Product and Order Store](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py): relational data · SQLite locally; RDS PostgreSQL through DATABASE_URL in production. · `app/main.py`
- **RDS PostgreSQL Multi-AZ**: production database · Highly available relational persistence.
- [DynamoDB Cart and Sessions](https://github.com/maheshgummul9/pythoncoffeeapp/blob/main/app/main.py): session state · Production boundary for high-frequency cart and session reads/writes. · `app/main.py`
- **S3 Static Assets**: object storage

### Security and Operations

- **Secrets Manager**: secret store · Supplies database credentials and other sensitive values.
- **IAM Roles**: access control · Grants workload access to AWS resources.
- **CloudWatch**: observability · Collects logs and drives alarms.

### Other components

- **Customer Browser**: client

## Connections

- Customer Browser → Route 53: store request
- Route 53 → AWS WAF: DNS traffic
- AWS WAF → Application Load Balancer: filtered HTTPS
- Application Load Balancer → EC2 Auto Scaling Group: forwards requests
- Application Load Balancer → FastAPI / Uvicorn: /health
- EC2 Auto Scaling Group → FastAPI / Uvicorn: runs
- FastAPI / Uvicorn → Jinja Storefront Views: renders pages
- FastAPI / Uvicorn → Product JSON API: serves JSON
- FastAPI / Uvicorn → Checkout and Order Completion: handles checkout
- FastAPI / Uvicorn → Product and Order Store: reads products and orders
- FastAPI / Uvicorn → DynamoDB Cart and Sessions: mutates cart state
- Checkout and Order Completion → Product and Order Store: persists order
- Product and Order Store → RDS PostgreSQL Multi-AZ: production backend
- Customer Browser → S3 Static Assets: loads static assets
- S3 Static Assets → Storefront Styling: delivers
- Secrets Manager → FastAPI / Uvicorn: provides credentials
- IAM Roles → FastAPI / Uvicorn: workload permissions
- FastAPI / Uvicorn → CloudWatch: logs and metrics
