# narasimhacha/e--commerce-platform-using-py architecture

> Architecture diagram of the GitHub repository narasimhacha/e--commerce-platform-using-py, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/narasimhacha/e--commerce-platform-using-py
- Repository: https://github.com/narasimhacha/e--commerce-platform-using-py

## Overview

This is a FastAPI e-commerce backend. The principal workflow is user registration/login, JWT-authenticated catalog and cart operations, with admin-gated inventory management and stock checks; a separate recommendation endpoint is documented as using cart contents and Claude, then validating suggestions against the catalog. The graph follows sampled route and persistence calls; recommendation internals and some documented route wiring were not sampled, so only documented dependencies are shown.

Main entry points: [`auth.py`](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py) (Auth routes), [`cart.py`](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/cart.py) (Cart operations), [`main.py`](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py) (FastAPI app), [`Database_config/database.py`](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/Database_config/database.py) (DB engine and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_application["FastAPI app<br/>[main.py]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_token_access["JWT and RBAC<br/>[auth.py]"]
  node_passwords["Password hashing<br/>[auth.py]"]
end

subgraph group_commerce["Commerce features"]
  node_catalog["Product catalog<br/>[main.py]"]
  node_cart_routes["Cart operations<br/>[cart.py]"]
  node_stock_rules["Stock validation<br/>[cart.py]"]
  node_recommendations["Recommendations<br/>[main.py]"]
end

subgraph group_persistence["Persistence"]
  node_schemas["Models and schemas<br/>[models.py]"]
  node_db_setup["DB engine and sessions<br/>[database.py]"]
end

node_client(("API client"))
node_claude["Claude API"]
node_sql_store[("SQL database")]

node_client -->|"sends requests"| node_application
node_application -->|"dispatches auth"| node_auth_routes
node_application -->|"dispatches cart"| node_cart_routes
node_application -->|"handles catalog"| node_catalog
node_application -.->|"handles recommendations"| node_recommendations
node_auth_routes -->|"hashes and verifies"| node_passwords
node_auth_routes -->|"creates tokens"| node_token_access
node_token_access -->|"authenticates routes"| node_auth_routes
node_auth_routes -->|"opens sessions"| node_db_setup
node_catalog -->|"opens sessions"| node_db_setup
node_cart_routes -->|"checks identity"| node_token_access
node_cart_routes -->|"validates quantity"| node_stock_rules
node_cart_routes -->|"opens sessions"| node_db_setup
node_recommendations -.->|"uses cart contents"| node_cart_routes
node_recommendations -.->|"requests suggestions"| node_claude
node_recommendations -.->|"validates products"| node_db_setup
node_db_setup -->|"connects to"| node_sql_store
node_auth_routes -->|"uses user models"| node_schemas
node_catalog -->|"uses product models"| node_schemas
node_cart_routes -->|"uses cart models"| node_schemas

click node_application "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py"
click node_auth_routes "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py"
click node_token_access "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py"
click node_passwords "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py"
click node_catalog "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py"
click node_cart_routes "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/cart.py"
click node_stock_rules "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/cart.py"
click node_recommendations "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py"
click node_schemas "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/models.py"
click node_db_setup "https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/Database_config/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_application,node_client toneBlue
class node_auth_routes,node_token_access,node_passwords,node_sql_store toneAmber
class node_catalog,node_cart_routes,node_stock_rules,node_recommendations,node_claude toneMint
class node_schemas,node_db_setup toneRose
```

## Components

### API routing

- [FastAPI app](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py): `main.py`

### Identity and access

- [Auth routes](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py): `auth.py`
- [JWT and RBAC](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py): `auth.py`
- [Password hashing](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/auth.py): `auth.py`

### Commerce features

- [Product catalog](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py): `main.py`
- [Cart operations](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/cart.py): `cart.py`
- [Stock validation](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/cart.py): `cart.py`
- [Recommendations](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/main.py): `main.py`

### Persistence

- [Models and schemas](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/models.py): `models.py`
- [DB engine and sessions](https://github.com/narasimhacha/e--commerce-platform-using-py/blob/main/Database_config/database.py): `Database_config/database.py`

### Other components

- **API client**
- **Claude API**
- **SQL database**

## Connections

- API client → FastAPI app: sends requests
- FastAPI app → Auth routes: dispatches auth
- FastAPI app → Cart operations: dispatches cart
- FastAPI app → Product catalog: handles catalog
- FastAPI app → Recommendations: handles recommendations
- Auth routes → Password hashing: hashes and verifies
- Auth routes → JWT and RBAC: creates tokens
- JWT and RBAC → Auth routes: authenticates routes
- Auth routes → DB engine and sessions: opens sessions
- Product catalog → DB engine and sessions: opens sessions
- Cart operations → JWT and RBAC: checks identity
- Cart operations → Stock validation: validates quantity
- Cart operations → DB engine and sessions: opens sessions
- Recommendations → Cart operations: uses cart contents
- Recommendations → Claude API: requests suggestions
- Recommendations → DB engine and sessions: validates products
- DB engine and sessions → SQL database: connects to
- Auth routes → Models and schemas: uses user models
- Product catalog → Models and schemas: uses product models
- Cart operations → Models and schemas: uses cart models
