# jainish1510/thread architecture

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

- Interactive diagram: https://gitdiagram.com/jainish1510/thread
- Repository: https://github.com/jainish1510/thread

## Overview

THREAD is a fictional direct-to-consumer fashion storefront and commerce API. A shopper browses products, checks stock and transparency details, adds items to a bag, then checks out; the API prices the order, reserves inventory, processes payment, and exposes order tracking. Customers can also manage accounts and use a size finder and plain-language search; staff manage orders, stock, and analytics. The map includes those documented capabilities, but unsampled web components and API routes are connected only where README or indexed source references support the relationship.

Main entry points: [`services/api/app/services/orders.py`](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/orders.py) (Order services), [`services/api/app/main.py`](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/main.py) (Commerce API), [`services/api/app/db.py`](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/db.py) (Commerce database), [`apps/web/src/components/checkout/CheckoutFlow.tsx`](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/checkout/CheckoutFlow.tsx) (Checkout flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_web["Storefront routes"]
  node_browser["Shop browser<br/>[ShopBrowser.tsx]"]
  node_product["Product view<br/>[ProductView.tsx]"]
  node_search["Plain-language search<br/>[SearchPage.tsx]"]
  node_fit["Size finder<br/>[FitFinder.tsx]"]
  node_cart["Shopping bag<br/>[cart.ts]"]
  node_checkout["Checkout flow<br/>[CheckoutFlow.tsx]"]
end

subgraph group_commerce["Commerce API"]
  node_api["Commerce API<br/>[main.py]"]
  node_catalog["Catalog routes<br/>[catalog.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_account["Account routes<br/>[me.py]"]
  node_db[("Commerce database<br/>[db.py]")]
  node_models["Commerce records<br/>[models.py]"]
end

subgraph group_fulfillment["Orders and inventory"]
  node_orders["Order services<br/>[orders.py]"]
  node_inventory["Inventory service<br/>[inventory.py]"]
  node_payment["Payment service<br/>[payments.py]"]
  node_webhooks["Payment webhooks<br/>[webhooks.py]"]
  node_events["Live event broker<br/>[events.py]"]
  node_tracking["Order tracking<br/>[OrderTracking.tsx]"]
end

subgraph group_customer["Customer and transparency"]
  node_transparency["Supply chain explorer"]
  node_passport["Digital passport<br/>[PassportBody.tsx]"]
end

subgraph group_operations["Admin operations"]
  node_admin["Admin routes<br/>[admin.py]"]
  node_adminui["Admin console<br/>[AdminConsole.tsx]"]
end

node_shopper(("Shopper"))
node_stripe["Stripe"]
node_redis[("Redis fan-out")]

node_shopper -->|"browses"| node_web
node_web -.->|"renders"| node_browser
node_browser -.->|"loads catalog"| node_catalog
node_shopper -->|"opens product"| node_product
node_shopper -->|"searches"| node_search
node_shopper -->|"finds size"| node_fit
node_product -.->|"loads product"| node_catalog
node_product -.->|"checks live stock"| node_inventory
node_shopper -->|"adds items"| node_cart
node_cart -->|"starts checkout"| node_checkout
node_shopper -->|"submits order"| node_checkout
node_checkout -->|"requests checkout"| node_api
node_api -->|"routes requests"| node_catalog
node_api -->|"routes requests"| node_auth
node_api -->|"routes requests"| node_account
node_api -->|"expires reservations"| node_orders
node_api -->|"creates schema"| node_db
node_catalog -->|"queries"| node_db
node_account -->|"reads and writes"| node_db
node_auth -->|"reads and writes"| node_db
node_checkout -.->|"creates order"| node_orders
node_orders -->|"reserves stock"| node_inventory
node_orders -.->|"starts payment"| node_payment
node_checkout -->|"pays"| node_stripe
node_webhooks -->|"verifies event"| node_payment
node_webhooks -->|"transitions order"| node_orders
node_orders -->|"publishes updates"| node_events
node_inventory -->|"publishes stock"| node_events
node_events -->|"fans out"| node_redis
node_shopper -->|"tracks order"| node_tracking
node_tracking -.->|"receives updates"| node_events
node_shopper -->|"explores provenance"| node_transparency
node_shopper -->|"opens passport"| node_passport
node_adminui -.->|"manages commerce"| node_admin
node_admin -->|"updates stock"| node_inventory
node_admin -.->|"advances orders"| node_orders
node_admin -->|"queries metrics"| node_db
node_models -->|"maps records"| node_db

click node_web "https://github.com/jainish1510/thread/tree/THREAD/apps/web/src/app"
click node_browser "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/shop/ShopBrowser.tsx"
click node_product "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/product/ProductView.tsx"
click node_search "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/search/SearchPage.tsx"
click node_fit "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/fit/FitFinder.tsx"
click node_cart "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/store/cart.ts"
click node_checkout "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/checkout/CheckoutFlow.tsx"
click node_api "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/main.py"
click node_catalog "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/catalog.py"
click node_auth "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/auth.py"
click node_account "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/me.py"
click node_orders "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/orders.py"
click node_inventory "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/inventory.py"
click node_payment "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/payments.py"
click node_webhooks "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/webhooks.py"
click node_events "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/events.py"
click node_tracking "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/orders/OrderTracking.tsx"
click node_db "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/db.py"
click node_models "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/models.py"
click node_transparency "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/transparency/SupplyChainExplorer.tsx"
click node_passport "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/passport/PassportBody.tsx"
click node_admin "https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/admin.py"
click node_adminui "https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/admin/AdminConsole.tsx"

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_web,node_browser,node_product,node_search,node_fit,node_cart,node_checkout toneBlue
class node_api,node_catalog,node_auth,node_account,node_db,node_models,node_redis toneAmber
class node_orders,node_inventory,node_payment,node_webhooks,node_events,node_tracking toneMint
class node_transparency,node_passport toneRose
class node_admin,node_adminui,node_shopper,node_stripe toneIndigo
```

## Components

### Storefront

- [Storefront routes](https://github.com/jainish1510/thread/tree/THREAD/apps/web/src/app): `apps/web/src/app`
- [Shop browser](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/shop/ShopBrowser.tsx): `apps/web/src/components/shop/ShopBrowser.tsx`
- [Product view](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/product/ProductView.tsx): `apps/web/src/components/product/ProductView.tsx`
- [Plain-language search](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/search/SearchPage.tsx): `apps/web/src/components/search/SearchPage.tsx`
- [Size finder](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/fit/FitFinder.tsx): `apps/web/src/components/fit/FitFinder.tsx`
- [Shopping bag](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/store/cart.ts): `apps/web/src/store/cart.ts`
- [Checkout flow](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/checkout/CheckoutFlow.tsx): `apps/web/src/components/checkout/CheckoutFlow.tsx`

### Commerce API

- [Commerce API](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/main.py): `services/api/app/main.py`
- [Catalog routes](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/catalog.py): `services/api/app/routers/catalog.py`
- [Authentication](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/auth.py): `services/api/app/routers/auth.py`
- [Account routes](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/me.py): `services/api/app/routers/me.py`
- [Commerce database](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/db.py): `services/api/app/db.py`
- [Commerce records](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/models.py): `services/api/app/models.py`

### Orders and inventory

- [Order services](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/orders.py): `services/api/app/services/orders.py`
- [Inventory service](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/inventory.py): `services/api/app/services/inventory.py`
- [Payment service](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/services/payments.py): `services/api/app/services/payments.py`
- [Payment webhooks](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/webhooks.py): `services/api/app/routers/webhooks.py`
- [Live event broker](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/events.py): `services/api/app/events.py`
- [Order tracking](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/orders/OrderTracking.tsx): `apps/web/src/components/orders/OrderTracking.tsx`

### Customer and transparency

- [Supply chain explorer](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/transparency/SupplyChainExplorer.tsx): `apps/web/src/components/transparency/SupplyChainExplorer.tsx`
- [Digital passport](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/passport/PassportBody.tsx): `apps/web/src/components/passport/PassportBody.tsx`

### Admin operations

- [Admin routes](https://github.com/jainish1510/thread/blob/THREAD/services/api/app/routers/admin.py): `services/api/app/routers/admin.py`
- [Admin console](https://github.com/jainish1510/thread/blob/THREAD/apps/web/src/components/admin/AdminConsole.tsx): `apps/web/src/components/admin/AdminConsole.tsx`

### Other components

- **Shopper**
- **Stripe**
- **Redis fan-out**

## Connections

- Shopper → Storefront routes: browses (evidence: `README.md`)
- Storefront routes → Shop browser: renders
- Shop browser → Catalog routes: loads catalog
- Shopper → Product view: opens product (evidence: `README.md`)
- Shopper → Plain-language search: searches (evidence: `README.md`)
- Shopper → Size finder: finds size (evidence: `README.md`)
- Product view → Catalog routes: loads product
- Product view → Inventory service: checks live stock
- Shopper → Shopping bag: adds items (evidence: `README.md`)
- Shopping bag → Checkout flow: starts checkout (evidence: `README.md`)
- Shopper → Checkout flow: submits order (evidence: `README.md`)
- Checkout flow → Commerce API: requests checkout (evidence: `README.md`)
- Commerce API → Catalog routes: routes requests (evidence: `services/api/app/main.py`)
- Commerce API → Authentication: routes requests (evidence: `services/api/app/main.py`)
- Commerce API → Account routes: routes requests (evidence: `services/api/app/main.py`)
- Commerce API → Order services: expires reservations (evidence: `services/api/app/main.py`)
- Commerce API → Commerce database: creates schema (evidence: `services/api/app/main.py`)
- Catalog routes → Commerce database: queries (evidence: `services/api/app/routers/catalog.py`)
- Account routes → Commerce database: reads and writes (evidence: `services/api/app/routers/me.py`)
- Authentication → Commerce database: reads and writes (evidence: `services/api/app/routers/auth.py`)
- Checkout flow → Order services: creates order
- Order services → Inventory service: reserves stock (evidence: `services/api/app/services/orders.py`)
- Order services → Payment service: starts payment
- Checkout flow → Stripe: pays (evidence: `README.md`)
- Payment webhooks → Payment service: verifies event (evidence: `services/api/app/routers/webhooks.py`)
- Payment webhooks → Order services: transitions order (evidence: `services/api/app/routers/webhooks.py`)
- Order services → Live event broker: publishes updates (evidence: `services/api/app/services/orders.py`)
- Inventory service → Live event broker: publishes stock (evidence: `services/api/app/services/inventory.py`)
- Live event broker → Redis fan-out: fans out (evidence: `services/api/app/events.py`)
- Shopper → Order tracking: tracks order (evidence: `README.md`)
- Order tracking → Live event broker: receives updates
- Shopper → Supply chain explorer: explores provenance (evidence: `README.md`)
- Shopper → Digital passport: opens passport (evidence: `README.md`)
- Admin console → Admin routes: manages commerce
- Admin routes → Inventory service: updates stock (evidence: `services/api/app/routers/admin.py`)
- Admin routes → Order services: advances orders (evidence: `services/api/app/routers/admin.py`)
- Admin routes → Commerce database: queries metrics (evidence: `services/api/app/routers/admin.py`)
- Commerce records → Commerce database: maps records (evidence: `services/api/app/models.py`)
