# rajasrinithi3-jpg/ecommerce-backend architecture

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

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

## Overview

CommerceIQ-AI is a shopping and market-insights application: shoppers browse products, inspect market signals and reviews, get recommendations, and can ask a conversational assistant; dashboards expose buyer and seller views. The React app calls a FastAPI backend, whose endpoints query SQLite-backed product data and compute insights. Authentication uses Firebase, with server-side token verification for protected actions; README notes dashboard role gates are UI-only. Some capability links are documented rather than shown in sampled code, so unsampled connections are omitted.

Main entry points: [`backend/main.py`](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py) (API routes), [`frontend/src/App.tsx`](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/App.tsx) (Commerce app), [`frontend/src/api.ts`](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/api.ts) (API client), [`backend/database.py`](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/database.py) (Database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Shopping frontend"]
  node_webapp["Commerce app<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_chat_ui["Chat widget<br/>[ChatWidget.tsx]"]
  node_insights_ui["Insights views<br/>[Analytics.tsx]"]
  node_overview_hook["Overview polling"]
end

subgraph group_api["Commerce API"]
  node_fastapi["API routes<br/>[main.py]"]
end

subgraph group_insights["Discovery and analytics"]
  node_chat_service["Shopping assistant<br/>[chatbot.py]"]
  node_recommendations["Product recommendations<br/>[recommender.py]"]
  node_analytics["Buyer and seller insights<br/>[main.py]"]
  node_market_insights["Market signals<br/>[main.py]"]
end

subgraph group_identity["Identity"]
  node_firebase_client["Firebase client<br/>[firebase.ts]"]
  node_auth["Token verification<br/>[auth.py]"]
end

subgraph group_catalog["Catalog data"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_data_model["Product and review model<br/>[models.py]"]
  node_sqlite[("Commerce database<br/>[database.py]")]
  node_csv_loader["Catalog data import<br/>[load_data.py]"]
end

node_shopper(("Shopper"))
node_firebase{{"Firebase Auth"}}
node_llm_service{{"GitHub Models API"}}

node_shopper -->|"uses"| node_webapp
node_webapp -->|"requests data"| node_api_client
node_webapp -->|"renders"| node_chat_ui
node_webapp -->|"renders"| node_insights_ui
node_insights_ui -->|"loads overview"| node_overview_hook
node_overview_hook -->|"fetches overview"| node_api_client
node_chat_ui -->|"sends messages"| node_api_client
node_api_client -->|"HTTP requests"| node_fastapi
node_webapp -->|"authenticates users"| node_firebase_client
node_firebase_client -->|"uses"| node_firebase
node_api_client -->|"sends ID token"| node_auth
node_fastapi -->|"verifies protected actions"| node_auth
node_fastapi -->|"queries catalog"| node_db_session
node_db_session -->|"opens sessions"| node_sqlite
node_data_model -->|"uses base"| node_db_session
node_fastapi -->|"queries entities"| node_data_model
node_csv_loader -->|"loads catalog records"| node_data_model
node_fastapi -->|"retrieves and replies"| node_chat_service
node_chat_service -->|"requests generated reply"| node_llm_service
node_fastapi -->|"gets similar products"| node_recommendations
node_fastapi -->|"computes dashboards"| node_analytics
node_fastapi -->|"computes product signals"| node_market_insights

click node_webapp "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/api.ts"
click node_chat_ui "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/ChatWidget.tsx"
click node_insights_ui "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/Analytics.tsx"
click node_overview_hook "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/useAnalyticsOverview.ts"
click node_firebase_client "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/firebase.ts"
click node_fastapi "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py"
click node_auth "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/auth.py"
click node_chat_service "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/chatbot.py"
click node_recommendations "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/src/recommendation/recommender.py"
click node_analytics "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py"
click node_market_insights "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py"
click node_db_session "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/database.py"
click node_data_model "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/models.py"
click node_sqlite "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/database.py"
click node_csv_loader "https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/scripts/load_data.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_webapp,node_api_client,node_chat_ui,node_insights_ui,node_overview_hook toneBlue
class node_fastapi toneAmber
class node_chat_service,node_recommendations,node_analytics,node_market_insights,node_llm_service toneMint
class node_firebase_client,node_auth toneRose
class node_db_session,node_data_model,node_sqlite,node_csv_loader,node_shopper,node_firebase toneIndigo
```

## Components

### Shopping frontend

- [Commerce app](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Chat widget](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/ChatWidget.tsx): `frontend/src/ChatWidget.tsx`
- [Insights views](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/Analytics.tsx): `frontend/src/Analytics.tsx`
- [Overview polling](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/useAnalyticsOverview.ts): `frontend/src/useAnalyticsOverview.ts`

### Commerce API

- [API routes](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py): `backend/main.py`

### Discovery and analytics

- [Shopping assistant](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/chatbot.py): `backend/chatbot.py`
- [Product recommendations](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/src/recommendation/recommender.py): `backend/src/recommendation/recommender.py`
- [Buyer and seller insights](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py): `backend/main.py`
- [Market signals](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/main.py): `backend/main.py`

### Identity

- [Firebase client](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/frontend/src/firebase.ts): `frontend/src/firebase.ts`
- [Token verification](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/auth.py): `backend/auth.py`

### Catalog data

- [Database sessions](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/database.py): `backend/database.py`
- [Product and review model](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/models.py): `backend/models.py`
- [Commerce database](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/database.py): `backend/database.py`
- [Catalog data import](https://github.com/rajasrinithi3-jpg/ecommerce-backend/blob/main/backend/scripts/load_data.py): `backend/scripts/load_data.py`

### Other components

- **Shopper**
- **Firebase Auth**
- **GitHub Models API**

## Connections

- Shopper → Commerce app: uses (evidence: `README.md`)
- Commerce app → API client: requests data (evidence: `frontend/src/App.tsx`)
- Commerce app → Chat widget: renders (evidence: `frontend/src/App.tsx`)
- Commerce app → Insights views: renders (evidence: `frontend/src/App.tsx`)
- Insights views → Overview polling: loads overview (evidence: `frontend/src/Analytics.tsx`)
- Overview polling → API client: fetches overview (evidence: `frontend/src/useAnalyticsOverview.ts`)
- Chat widget → API client: sends messages (evidence: `frontend/src/ChatWidget.tsx`)
- API client → API routes: HTTP requests (evidence: `README.md`)
- Commerce app → Firebase client: authenticates users (evidence: `frontend/src/App.tsx`)
- Firebase client → Firebase Auth: uses (evidence: `frontend/src/firebase.ts`)
- API client → Token verification: sends ID token (evidence: `frontend/src/api.ts`)
- API routes → Token verification: verifies protected actions (evidence: `backend/main.py`)
- API routes → Database sessions: queries catalog (evidence: `backend/main.py`)
- Database sessions → Commerce database: opens sessions (evidence: `backend/database.py`)
- Product and review model → Database sessions: uses base (evidence: `backend/models.py`)
- API routes → Product and review model: queries entities (evidence: `backend/main.py`)
- Catalog data import → Product and review model: loads catalog records (evidence: `backend/scripts/load_data.py`)
- API routes → Shopping assistant: retrieves and replies (evidence: `backend/main.py`)
- Shopping assistant → GitHub Models API: requests generated reply (evidence: `backend/chatbot.py`)
- API routes → Product recommendations: gets similar products (evidence: `backend/main.py`)
- API routes → Buyer and seller insights: computes dashboards (evidence: `README.md`)
- API routes → Market signals: computes product signals (evidence: `backend/main.py`)
