# shammell/clothing-brand architecture

> Architecture diagram of the GitHub repository shammell/clothing-brand, 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/shammell/clothing-brand
- Repository: https://github.com/shammell/clothing-brand

## Overview

Thread&Co is a clothing-store application with a Next.js storefront/admin UI and a FastAPI backend. The backend supports account registration and login, product browsing and administration, stock-aware order placement and cancellation, and an AI shopping assistant. The frontend includes product browsing, cart and wishlist state, and admin screens. The excerpts establish backend routing and service dependencies, but do not show frontend API calls, so those connections are omitted.

Main entry points: [`backend/app/main.py`](https://github.com/shammell/clothing-brand/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/core/database.py`](https://github.com/shammell/clothing-brand/blob/main/backend/app/core/database.py) (Database connection), [`backend/app/routes/auth.py`](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/auth.py) (Authentication routes), [`backend/app/routes/orders.py`](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/orders.py) (Order routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Storefront UI"]
  node_storefront["Storefront<br/>[page.tsx]"]
  node_product_detail["Product detail<br/>[page.tsx]"]
  node_admin_ui["Admin console<br/>[page.tsx]"]
  node_auth_store["Auth state<br/>[auth-store.ts]"]
  node_shop_store["Cart and wishlist<br/>[shop-store.ts]"]
  node_add_to_cart["Add-to-cart behavior<br/>[useAddToCart.ts]"]
end

subgraph group_api["Backend API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_product_routes["Product routes<br/>[products.py]"]
  node_order_routes["Order routes<br/>[orders.py]"]
  node_chat_routes["Chat routes<br/>[chat.py]"]
end

subgraph group_domain["Domain and services"]
  node_auth_service["Auth and tokens<br/>[auth_service.py]"]
  node_chat_service["AI chat service<br/>[chat_services.py]"]
  node_user_model["User model<br/>[user.py]"]
  node_product_model["Product model<br/>[product.py]"]
  node_order_model["Order model<br/>[order.py]"]
  node_chat_model["Chat model<br/>[chat.py]"]
end

subgraph group_infrastructure["Infrastructure"]
  node_config["Application settings<br/>[config.py]"]
  node_database["Database connection<br/>[database.py]"]
  node_limiter["Rate limiting<br/>[limiter.py]"]
end

node_customer(("Shopper"))
node_admin_user(("Store admin"))
node_mongo[("MongoDB")]
node_redis[("Redis")]
node_groq["Groq API"]

node_customer -->|"browses"| node_storefront
node_customer -->|"views product"| node_product_detail
node_admin_user -->|"manages store"| node_admin_ui
node_add_to_cart -->|"writes cart"| node_shop_store
node_shop_store -->|"dispatches sync event"| node_auth_store
node_api_app -->|"registers router"| node_auth_routes
node_api_app -->|"registers router"| node_product_routes
node_api_app -->|"registers router"| node_order_routes
node_api_app -->|"registers router"| node_chat_routes
node_api_app -->|"connects lifecycle"| node_database
node_api_app -->|"configures limiter"| node_limiter
node_auth_routes -->|"reads and writes"| node_database
node_auth_routes -->|"validates users"| node_user_model
node_auth_routes -->|"hashes and signs"| node_auth_service
node_product_routes -->|"reads and writes"| node_database
node_product_routes -->|"validates products"| node_product_model
node_order_routes -->|"reads and updates"| node_database
node_order_routes -->|"uses order schemas"| node_order_model
node_order_routes -.->|"checks stock variants"| node_product_model
node_chat_routes -->|"requests response"| node_chat_service
node_chat_routes -->|"uses chat schema"| node_chat_model
node_database -->|"reads settings"| node_config
node_database -->|"connects"| node_mongo
node_limiter -->|"reads settings"| node_config
node_limiter -.->|"uses when configured"| node_redis
node_auth_service -->|"reads token settings"| node_config
node_chat_service -->|"reads provider settings"| node_config
node_chat_service -->|"sends chat request"| node_groq

click node_storefront "https://github.com/shammell/clothing-brand/blob/main/frontend/app/page.tsx"
click node_product_detail "https://github.com/shammell/clothing-brand/blob/main/frontend/app/products/%5Bid%5D/page.tsx"
click node_admin_ui "https://github.com/shammell/clothing-brand/blob/main/frontend/app/admin/page.tsx"
click node_auth_store "https://github.com/shammell/clothing-brand/blob/main/frontend/lib/auth-store.ts"
click node_shop_store "https://github.com/shammell/clothing-brand/blob/main/frontend/lib/shop-store.ts"
click node_add_to_cart "https://github.com/shammell/clothing-brand/blob/main/frontend/lib/useAddToCart.ts"
click node_api_app "https://github.com/shammell/clothing-brand/blob/main/backend/app/main.py"
click node_auth_routes "https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/auth.py"
click node_product_routes "https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/products.py"
click node_order_routes "https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/orders.py"
click node_chat_routes "https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/chat.py"
click node_auth_service "https://github.com/shammell/clothing-brand/blob/main/backend/app/services/auth_service.py"
click node_chat_service "https://github.com/shammell/clothing-brand/blob/main/backend/app/services/chat_services.py"
click node_user_model "https://github.com/shammell/clothing-brand/blob/main/backend/app/models/user.py"
click node_product_model "https://github.com/shammell/clothing-brand/blob/main/backend/app/models/product.py"
click node_order_model "https://github.com/shammell/clothing-brand/blob/main/backend/app/models/order.py"
click node_chat_model "https://github.com/shammell/clothing-brand/blob/main/backend/app/models/chat.py"
click node_config "https://github.com/shammell/clothing-brand/blob/main/backend/app/core/config.py"
click node_database "https://github.com/shammell/clothing-brand/blob/main/backend/app/core/database.py"
click node_limiter "https://github.com/shammell/clothing-brand/blob/main/backend/app/core/limiter.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_storefront,node_product_detail,node_admin_ui,node_auth_store,node_shop_store,node_add_to_cart toneBlue
class node_api_app,node_auth_routes,node_product_routes,node_order_routes,node_chat_routes,node_mongo,node_redis toneAmber
class node_auth_service,node_chat_service,node_user_model,node_product_model,node_order_model,node_chat_model,node_groq toneMint
class node_config,node_database,node_limiter toneRose
class node_customer,node_admin_user toneIndigo
```

## Components

### Storefront UI

- [Storefront](https://github.com/shammell/clothing-brand/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Product detail](https://github.com/shammell/clothing-brand/blob/main/frontend/app/products/%5Bid%5D/page.tsx): `frontend/app/products/[id]/page.tsx`
- [Admin console](https://github.com/shammell/clothing-brand/blob/main/frontend/app/admin/page.tsx): `frontend/app/admin/page.tsx`
- [Auth state](https://github.com/shammell/clothing-brand/blob/main/frontend/lib/auth-store.ts): `frontend/lib/auth-store.ts`
- [Cart and wishlist](https://github.com/shammell/clothing-brand/blob/main/frontend/lib/shop-store.ts): `frontend/lib/shop-store.ts`
- [Add-to-cart behavior](https://github.com/shammell/clothing-brand/blob/main/frontend/lib/useAddToCart.ts): `frontend/lib/useAddToCart.ts`

### Backend API

- [FastAPI app](https://github.com/shammell/clothing-brand/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/auth.py): `backend/app/routes/auth.py`
- [Product routes](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/products.py): `backend/app/routes/products.py`
- [Order routes](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/orders.py): `backend/app/routes/orders.py`
- [Chat routes](https://github.com/shammell/clothing-brand/blob/main/backend/app/routes/chat.py): `backend/app/routes/chat.py`

### Domain and services

- [Auth and tokens](https://github.com/shammell/clothing-brand/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`
- [AI chat service](https://github.com/shammell/clothing-brand/blob/main/backend/app/services/chat_services.py): `backend/app/services/chat_services.py`
- [User model](https://github.com/shammell/clothing-brand/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [Product model](https://github.com/shammell/clothing-brand/blob/main/backend/app/models/product.py): `backend/app/models/product.py`
- [Order model](https://github.com/shammell/clothing-brand/blob/main/backend/app/models/order.py): `backend/app/models/order.py`
- [Chat model](https://github.com/shammell/clothing-brand/blob/main/backend/app/models/chat.py): `backend/app/models/chat.py`

### Infrastructure

- [Application settings](https://github.com/shammell/clothing-brand/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Database connection](https://github.com/shammell/clothing-brand/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Rate limiting](https://github.com/shammell/clothing-brand/blob/main/backend/app/core/limiter.py): `backend/app/core/limiter.py`

### Other components

- **Shopper**
- **Store admin**
- **MongoDB**
- **Redis**
- **Groq API**

## Connections

- Shopper → Storefront: browses
- Shopper → Product detail: views product
- Store admin → Admin console: manages store
- Add-to-cart behavior → Cart and wishlist: writes cart (evidence: `frontend/lib/useAddToCart.ts`)
- Cart and wishlist → Auth state: dispatches sync event (evidence: `frontend/lib/shop-store.ts`)
- FastAPI app → Authentication routes: registers router (evidence: `backend/app/main.py`)
- FastAPI app → Product routes: registers router (evidence: `backend/app/main.py`)
- FastAPI app → Order routes: registers router (evidence: `backend/app/main.py`)
- FastAPI app → Chat routes: registers router (evidence: `backend/app/main.py`)
- FastAPI app → Database connection: connects lifecycle (evidence: `backend/app/main.py`)
- FastAPI app → Rate limiting: configures limiter (evidence: `backend/app/main.py`)
- Authentication routes → Database connection: reads and writes (evidence: `backend/app/routes/auth.py`)
- Authentication routes → User model: validates users (evidence: `backend/app/routes/auth.py`)
- Authentication routes → Auth and tokens: hashes and signs (evidence: `backend/app/routes/auth.py`)
- Product routes → Database connection: reads and writes (evidence: `backend/app/routes/products.py`)
- Product routes → Product model: validates products (evidence: `backend/app/routes/products.py`)
- Order routes → Database connection: reads and updates (evidence: `backend/app/routes/orders.py`)
- Order routes → Order model: uses order schemas (evidence: `backend/app/routes/orders.py`)
- Order routes → Product model: checks stock variants
- Chat routes → AI chat service: requests response (evidence: `backend/app/routes/chat.py`)
- Chat routes → Chat model: uses chat schema (evidence: `backend/app/routes/chat.py`)
- Database connection → Application settings: reads settings (evidence: `backend/app/core/database.py`)
- Database connection → MongoDB: connects (evidence: `backend/app/core/database.py`)
- Rate limiting → Application settings: reads settings (evidence: `backend/app/core/limiter.py`)
- Rate limiting → Redis: uses when configured (evidence: `backend/app/core/limiter.py`)
- Auth and tokens → Application settings: reads token settings (evidence: `backend/app/services/auth_service.py`)
- AI chat service → Application settings: reads provider settings (evidence: `backend/app/services/chat_services.py`)
- AI chat service → Groq API: sends chat request (evidence: `backend/app/services/chat_services.py`)
