# wazimughal/ca2-enterprise-architecture architecture

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

- Interactive diagram: https://gitdiagram.com/wazimughal/ca2-enterprise-architecture
- Repository: https://github.com/wazimughal/ca2-enterprise-architecture

## Overview

This repository implements a small checkout system composed of a gateway and pricing, inventory, and checkout services. The principal workflow is a client request to the gateway, forwarding to checkout, then separate price and stock lookups; checkout calculates the total, records an audit row in PostgreSQL, and returns the result. Pricing and inventory use in-memory SKU data, and the services expose health and Prometheus metrics endpoints. The README is only a title; these relationships come from the sampled service code, while Kubernetes manifests indicate deployment configuration but do not establish additional runtime calls.

Main entry points: [`k8s`](https://github.com/wazimughal/ca2-enterprise-architecture/tree/main/k8s) (Kubernetes resources), [`checkout/app.py`](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/checkout/app.py) (Checkout handler), [`gateway/app.py`](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/gateway/app.py) (API gateway), [`pricing/app.py`](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/pricing/app.py) (Pricing lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request entry"]
  node_gateway["API gateway<br/>[app.py]"]
end

subgraph group_commerce["Checkout services"]
  node_checkout["Checkout handler<br/>[app.py]"]
  node_pricing["Pricing lookup<br/>[app.py]"]
  node_inventory["Stock lookup<br/>[app.py]"]
  node_price_data[("Price list<br/>[app.py]")]
  node_stock_data[("Stock data<br/>[app.py]")]
end

subgraph group_state["Persistence"]
  node_audit[("Audit table<br/>[app.py]")]
  node_postgres[("PostgreSQL")]
end

subgraph group_operations["Deployment"]
  node_k8s["Kubernetes resources"]
end

node_client(("Client"))

node_client -->|"submits checkout"| node_gateway
node_gateway -->|"forwards request"| node_checkout
node_checkout -->|"requests price"| node_pricing
node_pricing -->|"reads price"| node_price_data
node_checkout -->|"checks stock"| node_inventory
node_inventory -->|"reads quantity"| node_stock_data
node_checkout -->|"saves audit"| node_postgres
node_postgres -->|"stores row"| node_audit
node_gateway -->|"returns response"| node_client
node_k8s -.->|"deploys service"| node_gateway
node_k8s -.->|"deploys service"| node_checkout
node_k8s -.->|"deploys service"| node_pricing
node_k8s -.->|"deploys service"| node_inventory
node_k8s -.->|"deploys database"| node_postgres

click node_gateway "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/gateway/app.py"
click node_checkout "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/checkout/app.py"
click node_pricing "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/pricing/app.py"
click node_inventory "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/inventory/app.py"
click node_price_data "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/pricing/app.py"
click node_stock_data "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/inventory/app.py"
click node_audit "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/checkout/app.py"
click node_postgres "https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/k8s/postgres-deployment.yaml"
click node_k8s "https://github.com/wazimughal/ca2-enterprise-architecture/tree/main/k8s"

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_gateway,node_client toneBlue
class node_checkout,node_pricing,node_inventory,node_price_data,node_stock_data toneAmber
class node_audit,node_postgres toneMint
class node_k8s toneRose
```

## Components

### Request entry

- [API gateway](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/gateway/app.py): `gateway/app.py`

### Checkout services

- [Checkout handler](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/checkout/app.py): `checkout/app.py`
- [Pricing lookup](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/pricing/app.py): `pricing/app.py`
- [Stock lookup](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/inventory/app.py): `inventory/app.py`
- [Price list](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/pricing/app.py): `pricing/app.py`
- [Stock data](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/inventory/app.py): `inventory/app.py`

### Persistence

- [Audit table](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/checkout/app.py): `checkout/app.py`
- [PostgreSQL](https://github.com/wazimughal/ca2-enterprise-architecture/blob/main/k8s/postgres-deployment.yaml): `k8s/postgres-deployment.yaml`

### Deployment

- [Kubernetes resources](https://github.com/wazimughal/ca2-enterprise-architecture/tree/main/k8s): `k8s`

### Other components

- **Client**

## Connections

- Client → API gateway: submits checkout
- API gateway → Checkout handler: forwards request
- Checkout handler → Pricing lookup: requests price
- Pricing lookup → Price list: reads price
- Checkout handler → Stock lookup: checks stock
- Stock lookup → Stock data: reads quantity
- Checkout handler → PostgreSQL: saves audit
- PostgreSQL → Audit table: stores row
- API gateway → Client: returns response
- Kubernetes resources → API gateway: deploys service
- Kubernetes resources → Checkout handler: deploys service
- Kubernetes resources → Pricing lookup: deploys service
- Kubernetes resources → Stock lookup: deploys service
- Kubernetes resources → PostgreSQL: deploys database
