# kanhunayak2026/ecommerce-backend architecture

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

- Interactive diagram: https://gitdiagram.com/kanhunayak2026/ecommerce-backend
- Repository: https://github.com/kanhunayak2026/ecommerce-backend

## Overview

This is a FastAPI e-commerce backend. Clients use its API to manage accounts and catalog data, maintain a cart, and place and manage orders; admin-only operations include catalog changes and order-status updates. The API also uses Pydantic request/response schemas and SQLAlchemy models backed by a MySQL database. The sampled excerpts show API routes and model definitions, but omit portions of main.py, so details of authentication and checkout wiring are limited to what the visible code supports.

Main entry points: [`app/main.py`](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/main.py) (FastAPI routes), [`app/database.py`](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/database.py) (DB session config), [`app/model.py`](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/model.py) (User model), [`app/category_model.py`](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/category_model.py) (Category model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and contracts"]
  node_routes["FastAPI routes<br/>[main.py]"]
  node_schemas["Request schemas<br/>[pydatic.py]"]
end

subgraph group_identity["Identity and catalog"]
  node_auth["JWT helpers<br/>[auth.py]"]
  node_users["User model<br/>[model.py]"]
  node_categories["Category model<br/>[category_model.py]"]
  node_products["Product model<br/>[product_model.py]"]
end

subgraph group_commerce["Cart and orders"]
  node_carts["Cart models<br/>[cart_model.py]"]
  node_orders["Order models<br/>[order_model.py]"]
end

subgraph group_persistence["Persistence"]
  node_dbconfig["DB session config<br/>[database.py]"]
  node_mysql[("MySQL database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_routes
node_routes -->|"returns responses"| node_client
node_routes -->|"validates data"| node_schemas
node_routes -.->|"uses tokens"| node_auth
node_routes -->|"queries users"| node_users
node_routes -->|"queries categories"| node_categories
node_routes -->|"queries products"| node_products
node_routes -->|"queries cart"| node_carts
node_routes -->|"queries orders"| node_orders
node_routes -->|"opens sessions"| node_dbconfig
node_users -->|"uses base"| node_dbconfig
node_categories -->|"uses base"| node_dbconfig
node_products -->|"uses base"| node_dbconfig
node_carts -->|"uses base"| node_dbconfig
node_orders -->|"uses base"| node_dbconfig
node_dbconfig -->|"connects"| node_mysql

click node_routes "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/main.py"
click node_schemas "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/pydatic.py"
click node_auth "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/auth.py"
click node_users "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/model.py"
click node_categories "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/category_model.py"
click node_products "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/product_model.py"
click node_carts "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/cart_model.py"
click node_orders "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/order_model.py"
click node_dbconfig "https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/database.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_routes,node_schemas,node_client toneBlue
class node_auth,node_users,node_categories,node_products toneAmber
class node_carts,node_orders toneMint
class node_dbconfig,node_mysql toneRose
```

## Components

### API and contracts

- [FastAPI routes](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/main.py): `app/main.py`
- [Request schemas](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/pydatic.py): `app/pydatic.py`

### Identity and catalog

- [JWT helpers](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/auth.py): `app/auth.py`
- [User model](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/model.py): `app/model.py`
- [Category model](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/category_model.py): `app/category_model.py`
- [Product model](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/product_model.py): `app/product_model.py`

### Cart and orders

- [Cart models](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/cart_model.py): `app/cart_model.py`
- [Order models](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/order_model.py): `app/order_model.py`

### Persistence

- [DB session config](https://github.com/kanhunayak2026/ecommerce-backend/blob/main/app/database.py): `app/database.py`
- **MySQL database**

### Other components

- **API client**

## Connections

- API client → FastAPI routes: sends requests
- FastAPI routes → API client: returns responses
- FastAPI routes → Request schemas: validates data
- FastAPI routes → JWT helpers: uses tokens
- FastAPI routes → User model: queries users
- FastAPI routes → Category model: queries categories
- FastAPI routes → Product model: queries products
- FastAPI routes → Cart models: queries cart
- FastAPI routes → Order models: queries orders
- FastAPI routes → DB session config: opens sessions
- User model → DB session config: uses base
- Category model → DB session config: uses base
- Product model → DB session config: uses base
- Cart models → DB session config: uses base
- Order models → DB session config: uses base
- DB session config → MySQL database: connects
