# ipgoutam/g-mart architecture

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

- Interactive diagram: https://gitdiagram.com/ipgoutam/g-mart
- Repository: https://github.com/ipgoutam/g-mart

## Overview

G-MART is a grocery-shopping application with a React customer storefront and admin console backed by a FastAPI service. Shoppers browse products, manage a cart, check out, and track orders; administrators manage catalog, inventory, orders, payments, and store operations. The frontend routes users into these experiences and uses a shared API client; the backend registers API routers over database-backed models. Notification delivery is a distinct capability. Several feature modules were not sampled, so their internal calls and some frontend-to-backend links are not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/ipgoutam/g-mart/blob/main/backend/app/main.py) (FastAPI application), [`frontend/web/src/App.tsx`](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/App.tsx) (Route application), [`frontend/web/src/pages/customer`](https://github.com/ipgoutam/g-mart/tree/main/frontend/web/src/pages/customer) (Customer storefront), [`frontend/web/src/services/api.ts`](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Route application<br/>[App.tsx]"]
  node_customer_ui["Customer storefront"]
  node_admin_ui["Admin console"]
  node_auth_ui["Sign-in UI<br/>[Login.tsx]"]
  node_auth_state["Auth state<br/>[AuthContext.tsx]"]
  node_cart_state["Cart state<br/>[CartContext.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_theme["Theme preference<br/>[useTheme.ts]"]
end

subgraph group_commerce["Commerce API"]
  node_auth_api["Authentication<br/>[auth.py]"]
  node_catalog["Product catalog<br/>[products.py]"]
  node_product_details["Product details<br/>[product_details.py]"]
  node_cart_api["Cart operations<br/>[cart.py]"]
  node_orders["Order lifecycle<br/>[orders.py]"]
  node_payments["Payments<br/>[payments.py]"]
end

subgraph group_operations["Store operations"]
  node_store_admin["Store management"]
  node_notifications["Notification delivery"]
end

subgraph group_platform["Backend platform"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

node_shopper(("Shopper"))
node_admin(("Administrator"))
node_razorpay["Razorpay"]
node_email_sms["Email and SMS"]

node_shopper -->|"uses storefront"| node_frontend
node_admin -->|"uses console"| node_frontend
node_frontend -->|"routes customers"| node_customer_ui
node_frontend -->|"routes admins"| node_admin_ui
node_frontend -->|"routes sign-in"| node_auth_ui
node_auth_ui -->|"calls login"| node_auth_state
node_auth_state -->|"requests profile"| node_api_client
node_cart_state -->|"reads identity"| node_auth_state
node_cart_state -->|"syncs cart"| node_api_client
node_customer_ui -->|"fetches store data"| node_api_client
node_customer_ui -->|"manages cart"| node_cart_state
node_customer_ui -->|"uses theme"| node_theme
node_api_client -.->|"sends HTTP requests"| node_api_app
node_api_app -->|"registers router"| node_auth_api
node_api_app -->|"registers router"| node_catalog
node_api_app -->|"registers router"| node_product_details
node_api_app -->|"registers router"| node_cart_api
node_api_app -->|"registers router"| node_orders
node_api_app -->|"registers router"| node_payments
node_api_app -->|"registers routers"| node_store_admin
node_orders -->|"creates order alerts"| node_notifications
node_notifications -->|"sends messages"| node_email_sms
node_orders -->|"queries and writes"| node_database
node_auth_api -->|"uses sessions"| node_database
node_api_app -->|"initializes tables"| node_database
node_payments -.->|"payment integration"| node_razorpay

click node_frontend "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/App.tsx"
click node_customer_ui "https://github.com/ipgoutam/g-mart/tree/main/frontend/web/src/pages/customer"
click node_admin_ui "https://github.com/ipgoutam/g-mart/tree/main/frontend/web/src/pages/admin"
click node_auth_ui "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/pages/auth/Login.tsx"
click node_auth_state "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/context/AuthContext.tsx"
click node_cart_state "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/context/CartContext.tsx"
click node_api_client "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/services/api.ts"
click node_theme "https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/hooks/useTheme.ts"
click node_api_app "https://github.com/ipgoutam/g-mart/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/auth.py"
click node_catalog "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/products.py"
click node_product_details "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/product_details.py"
click node_cart_api "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/cart.py"
click node_orders "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/orders.py"
click node_payments "https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/payments.py"
click node_store_admin "https://github.com/ipgoutam/g-mart/tree/main/backend/app/routers"
click node_notifications "https://github.com/ipgoutam/g-mart/blob/main/backend/app/services/notification_service.py"
click node_database "https://github.com/ipgoutam/g-mart/blob/main/backend/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_frontend,node_customer_ui,node_admin_ui,node_auth_ui,node_auth_state,node_cart_state,node_api_client,node_theme toneBlue
class node_auth_api,node_catalog,node_product_details,node_cart_api,node_orders,node_payments toneAmber
class node_store_admin,node_notifications toneMint
class node_api_app,node_database toneRose
class node_shopper,node_admin,node_razorpay,node_email_sms toneIndigo
```

## Components

### Web experience

- [Route application](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/App.tsx): `frontend/web/src/App.tsx`
- [Customer storefront](https://github.com/ipgoutam/g-mart/tree/main/frontend/web/src/pages/customer): `frontend/web/src/pages/customer`
- [Admin console](https://github.com/ipgoutam/g-mart/tree/main/frontend/web/src/pages/admin): `frontend/web/src/pages/admin`
- [Sign-in UI](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/pages/auth/Login.tsx): `frontend/web/src/pages/auth/Login.tsx`
- [Auth state](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/context/AuthContext.tsx): `frontend/web/src/context/AuthContext.tsx`
- [Cart state](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/context/CartContext.tsx): `frontend/web/src/context/CartContext.tsx`
- [API client](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/services/api.ts): `frontend/web/src/services/api.ts`
- [Theme preference](https://github.com/ipgoutam/g-mart/blob/main/frontend/web/src/hooks/useTheme.ts): `frontend/web/src/hooks/useTheme.ts`

### Commerce API

- [Authentication](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Product catalog](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/products.py): `backend/app/routers/products.py`
- [Product details](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/product_details.py): `backend/app/routers/product_details.py`
- [Cart operations](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/cart.py): `backend/app/routers/cart.py`
- [Order lifecycle](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/orders.py): `backend/app/routers/orders.py`
- [Payments](https://github.com/ipgoutam/g-mart/blob/main/backend/app/routers/payments.py): `backend/app/routers/payments.py`

### Store operations

- [Store management](https://github.com/ipgoutam/g-mart/tree/main/backend/app/routers): `backend/app/routers`
- [Notification delivery](https://github.com/ipgoutam/g-mart/blob/main/backend/app/services/notification_service.py): `backend/app/services/notification_service.py`

### Backend platform

- [FastAPI application](https://github.com/ipgoutam/g-mart/blob/main/backend/app/main.py): `backend/app/main.py`
- [SQL database](https://github.com/ipgoutam/g-mart/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Shopper**
- **Administrator**
- **Razorpay**
- **Email and SMS**

## Connections

- Shopper → Route application: uses storefront (evidence: `frontend/web/src/App.tsx`)
- Administrator → Route application: uses console (evidence: `frontend/web/src/App.tsx`)
- Route application → Customer storefront: routes customers (evidence: `frontend/web/src/App.tsx`)
- Route application → Admin console: routes admins (evidence: `frontend/web/src/App.tsx`)
- Route application → Sign-in UI: routes sign-in (evidence: `frontend/web/src/App.tsx`)
- Sign-in UI → Auth state: calls login (evidence: `frontend/web/src/pages/auth/Login.tsx`)
- Auth state → API client: requests profile (evidence: `frontend/web/src/context/AuthContext.tsx`)
- Cart state → Auth state: reads identity (evidence: `frontend/web/src/context/CartContext.tsx`)
- Cart state → API client: syncs cart (evidence: `frontend/web/src/context/CartContext.tsx`)
- Customer storefront → API client: fetches store data (evidence: `frontend/web/src/pages/customer/Home.tsx`)
- Customer storefront → Cart state: manages cart (evidence: `frontend/web/src/pages/customer/ProductDetails.tsx`)
- Customer storefront → Theme preference: uses theme (evidence: `frontend/web/src/pages/customer/Home.tsx`)
- API client → FastAPI application: sends HTTP requests
- FastAPI application → Authentication: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Product catalog: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Product details: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Cart operations: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Order lifecycle: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Payments: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Store management: registers routers (evidence: `backend/app/main.py`)
- Order lifecycle → Notification delivery: creates order alerts (evidence: `backend/app/routers/orders.py`)
- Notification delivery → Email and SMS: sends messages (evidence: `backend/app/services/notification_service.py`)
- Order lifecycle → SQL database: queries and writes (evidence: `backend/app/routers/orders.py`)
- Authentication → SQL database: uses sessions (evidence: `backend/app/routers/auth.py`)
- FastAPI application → SQL database: initializes tables (evidence: `backend/app/main.py`)
- Payments → Razorpay: payment integration
