# abdyken/ecommerce-api architecture

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

- Interactive diagram: https://gitdiagram.com/abdyken/ecommerce-api
- Repository: https://github.com/abdyken/ecommerce-api

## Overview

E-Commerce API exposes a FastAPI workflow for account access, product discovery, cart management, and Stripe checkout through order fulfillment. Endpoint modules own request handling and database operations; shared dependencies resolve sessions and authenticated users. The README documents additional address/profile, email, and observability capabilities. The graph includes those documented branches, but unsampled implementation details and monitoring wiring are not inferred beyond the documented relationships.

Main entry points: [`app/api/endpoints/payments.py`](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/payments.py) (Checkout and orders), [`app/api/dependencies.py`](https://github.com/abdyken/ecommerce-api/blob/main/app/api/dependencies.py) (Request dependencies), [`app/main.py`](https://github.com/abdyken/ecommerce-api/blob/main/app/main.py) (FastAPI application), [`app/api/endpoints/auth.py`](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/auth.py) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entrypoints"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_products["Product catalog<br/>[products.py]"]
  node_cart["Shopping cart<br/>[cart.py]"]
  node_payments["Checkout and orders<br/>[payments.py]"]
  node_users["Profiles and addresses<br/>[users.py]"]
end

subgraph group_commerce["Commerce domains"]
  node_identity["Users and addresses<br/>[user.py]"]
  node_catalog["Product records<br/>[product.py]"]
  node_cartdata["Cart records<br/>[cart.py]"]
  node_orderdata["Order records<br/>[order.py]"]
end

subgraph group_shared["Shared runtime"]
  node_dependencies["Request dependencies<br/>[dependencies.py]"]
  node_security["JWT and passwords<br/>[security.py]"]
  node_settings["Application settings<br/>[config.py]"]
  node_database[("PostgreSQL database<br/>[database.py]")]
  node_email["Order email service<br/>[email.py]"]
end

subgraph group_ops["Observability"]
  node_monitoring["Metrics and logs<br/>[prometheus.yml]"]
end

node_shopper(("Shopper"))
node_stripe{{"Stripe"}}
node_mailhost{{"SMTP service"}}
node_prometheus{{"Prometheus"}}
node_loki{{"Loki"}}
node_promtail{{"Promtail"}}

node_shopper -->|"sends requests"| node_fastapi
node_fastapi -->|"routes to"| node_auth
node_fastapi -->|"routes to"| node_products
node_fastapi -->|"routes to"| node_cart
node_fastapi -->|"routes to"| node_payments
node_fastapi -->|"routes to"| node_users
node_auth -->|"uses"| node_dependencies
node_products -->|"uses"| node_dependencies
node_cart -->|"uses"| node_dependencies
node_payments -->|"uses"| node_dependencies
node_users -->|"uses"| node_dependencies
node_dependencies -->|"validates tokens"| node_security
node_auth -->|"hashes and signs"| node_security
node_dependencies -->|"opens sessions"| node_database
node_auth -->|"reads and creates"| node_identity
node_products -->|"manages products"| node_catalog
node_cart -->|"manages cart"| node_cartdata
node_cart -->|"checks products"| node_catalog
node_users -->|"manages profiles"| node_identity
node_payments -->|"reads cart"| node_cartdata
node_payments -->|"creates orders"| node_orderdata
node_payments -->|"updates stock"| node_catalog
node_payments -->|"creates intents"| node_stripe
node_stripe -->|"sends webhooks"| node_payments
node_payments -->|"sends confirmations"| node_email
node_email -.->|"delivers email"| node_mailhost
node_security -->|"reads signing config"| node_settings
node_payments -->|"reads Stripe config"| node_settings
node_email -->|"reads mail config"| node_settings
node_monitoring -->|"configures scraping"| node_prometheus
node_promtail -->|"ships logs"| node_loki

click node_fastapi "https://github.com/abdyken/ecommerce-api/blob/main/app/main.py"
click node_auth "https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/auth.py"
click node_products "https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/products.py"
click node_cart "https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/cart.py"
click node_payments "https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/payments.py"
click node_users "https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/users.py"
click node_identity "https://github.com/abdyken/ecommerce-api/blob/main/app/models/user.py"
click node_catalog "https://github.com/abdyken/ecommerce-api/blob/main/app/models/product.py"
click node_cartdata "https://github.com/abdyken/ecommerce-api/blob/main/app/models/cart.py"
click node_orderdata "https://github.com/abdyken/ecommerce-api/blob/main/app/models/order.py"
click node_dependencies "https://github.com/abdyken/ecommerce-api/blob/main/app/api/dependencies.py"
click node_security "https://github.com/abdyken/ecommerce-api/blob/main/app/core/security.py"
click node_settings "https://github.com/abdyken/ecommerce-api/blob/main/app/core/config.py"
click node_database "https://github.com/abdyken/ecommerce-api/blob/main/app/db/database.py"
click node_email "https://github.com/abdyken/ecommerce-api/blob/main/app/services/email.py"
click node_monitoring "https://github.com/abdyken/ecommerce-api/blob/main/monitoring/prometheus.yml"

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_fastapi,node_auth,node_products,node_cart,node_payments,node_users toneBlue
class node_identity,node_catalog,node_cartdata,node_orderdata toneAmber
class node_dependencies,node_security,node_settings,node_database,node_email toneMint
class node_monitoring toneRose
class node_shopper,node_stripe,node_mailhost,node_prometheus,node_loki,node_promtail toneIndigo
```

## Components

### API entrypoints

- [FastAPI application](https://github.com/abdyken/ecommerce-api/blob/main/app/main.py): `app/main.py`
- [Authentication](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/auth.py): `app/api/endpoints/auth.py`
- [Product catalog](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/products.py): `app/api/endpoints/products.py`
- [Shopping cart](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/cart.py): `app/api/endpoints/cart.py`
- [Checkout and orders](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/payments.py): `app/api/endpoints/payments.py`
- [Profiles and addresses](https://github.com/abdyken/ecommerce-api/blob/main/app/api/endpoints/users.py): `app/api/endpoints/users.py`

### Commerce domains

- [Users and addresses](https://github.com/abdyken/ecommerce-api/blob/main/app/models/user.py): `app/models/user.py`
- [Product records](https://github.com/abdyken/ecommerce-api/blob/main/app/models/product.py): `app/models/product.py`
- [Cart records](https://github.com/abdyken/ecommerce-api/blob/main/app/models/cart.py): `app/models/cart.py`
- [Order records](https://github.com/abdyken/ecommerce-api/blob/main/app/models/order.py): `app/models/order.py`

### Shared runtime

- [Request dependencies](https://github.com/abdyken/ecommerce-api/blob/main/app/api/dependencies.py): `app/api/dependencies.py`
- [JWT and passwords](https://github.com/abdyken/ecommerce-api/blob/main/app/core/security.py): `app/core/security.py`
- [Application settings](https://github.com/abdyken/ecommerce-api/blob/main/app/core/config.py): `app/core/config.py`
- [PostgreSQL database](https://github.com/abdyken/ecommerce-api/blob/main/app/db/database.py): `app/db/database.py`
- [Order email service](https://github.com/abdyken/ecommerce-api/blob/main/app/services/email.py): `app/services/email.py`

### Observability

- [Metrics and logs](https://github.com/abdyken/ecommerce-api/blob/main/monitoring/prometheus.yml): `monitoring/prometheus.yml`

### Other components

- **Shopper**
- **Stripe**
- **SMTP service**
- **Prometheus**
- **Loki**
- **Promtail**

## Connections

- Shopper → FastAPI application: sends requests (evidence: `README.md`)
- FastAPI application → Authentication: routes to (evidence: `app/main.py`)
- FastAPI application → Product catalog: routes to (evidence: `app/main.py`)
- FastAPI application → Shopping cart: routes to (evidence: `app/main.py`)
- FastAPI application → Checkout and orders: routes to (evidence: `app/main.py`)
- FastAPI application → Profiles and addresses: routes to (evidence: `app/main.py`)
- Authentication → Request dependencies: uses (evidence: `app/api/endpoints/auth.py`)
- Product catalog → Request dependencies: uses (evidence: `app/api/endpoints/products.py`)
- Shopping cart → Request dependencies: uses (evidence: `app/api/endpoints/cart.py`)
- Checkout and orders → Request dependencies: uses (evidence: `app/api/endpoints/payments.py`)
- Profiles and addresses → Request dependencies: uses (evidence: `app/api/endpoints/users.py`)
- Request dependencies → JWT and passwords: validates tokens (evidence: `app/api/dependencies.py`)
- Authentication → JWT and passwords: hashes and signs (evidence: `app/api/endpoints/auth.py`)
- Request dependencies → PostgreSQL database: opens sessions (evidence: `app/api/dependencies.py`)
- Authentication → Users and addresses: reads and creates (evidence: `app/api/endpoints/auth.py`)
- Product catalog → Product records: manages products (evidence: `app/api/endpoints/products.py`)
- Shopping cart → Cart records: manages cart (evidence: `app/api/endpoints/cart.py`)
- Shopping cart → Product records: checks products (evidence: `app/api/endpoints/cart.py`)
- Profiles and addresses → Users and addresses: manages profiles (evidence: `app/api/endpoints/users.py`)
- Checkout and orders → Cart records: reads cart (evidence: `app/api/endpoints/payments.py`)
- Checkout and orders → Order records: creates orders (evidence: `app/api/endpoints/payments.py`)
- Checkout and orders → Product records: updates stock (evidence: `app/api/endpoints/payments.py`)
- Checkout and orders → Stripe: creates intents (evidence: `app/api/endpoints/payments.py`)
- Stripe → Checkout and orders: sends webhooks (evidence: `app/api/endpoints/payments.py`)
- Checkout and orders → Order email service: sends confirmations (evidence: `app/api/endpoints/payments.py`)
- Order email service → SMTP service: delivers email
- JWT and passwords → Application settings: reads signing config (evidence: `app/core/security.py`)
- Checkout and orders → Application settings: reads Stripe config (evidence: `app/api/endpoints/payments.py`)
- Order email service → Application settings: reads mail config (evidence: `app/services/email.py`)
- Metrics and logs → Prometheus: configures scraping (evidence: `README.md`)
- Promtail → Loki: ships logs (evidence: `README.md`)
