# erzamadana-ui/supplier-id architecture

> Architecture diagram of the GitHub repository erzamadana-ui/supplier-id, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erzamadana-ui/supplier-id
- Repository: https://github.com/erzamadana-ui/supplier-id

## Overview

Supplier.id is a B2B marketplace for agricultural, livestock, and seafood goods, with supplier, buyer, and admin portals. Its documented lifecycle is DECLARE → PROVE → DELIVER → INSPECT → EVIDENCE → SETTLE: suppliers publish quality declarations and evidence, buyers discover listings and place orders, then receive and inspect goods; claims, returns, and financial settlement follow. The graph includes the visible web routing and API dispatch, plus documented pricing, quality, returns, and ledger capabilities. Most route and service source was not sampled, so uncertain internal wiring is omitted.

Main entry points: [`server/src/app.ts`](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/app.ts) (Express app), [`web/src/main.tsx`](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/main.tsx) (Portal router), [`web/src/lib/api.ts`](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/api.ts) (API client), [`web/src/lib/auth.tsx`](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/auth.tsx) (Session state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web portals"]
  node_webapp["Portal router<br/>[main.tsx]"]
  node_authui["Session state<br/>[auth.tsx]"]
  node_buyerpages["Buyer portal"]
  node_supplierpages["Supplier portal"]
  node_orderui["Order and returns<br/>[OrderDetail.tsx]"]
  node_adminui["Admin panel"]
  node_apiclient["API client<br/>[api.ts]"]
end

subgraph group_api["API workflows"]
  node_app["Express app<br/>[app.ts]"]
  node_authroutes["Authentication<br/>[auth.ts]"]
  node_catalog["Catalog and evidence<br/>[catalog.ts]"]
  node_evidence["Evidence uploads<br/>[evidence.ts]"]
  node_supplierapi["Supplier operations<br/>[supplier.ts]"]
  node_rfq["RFQ workflow<br/>[rfq.ts]"]
  node_ordersapi["Order workflow<br/>[orders.ts]"]
  node_returnsapi["Returns workflow<br/>[returns.ts]"]
  node_adminapi["Admin operations<br/>[admin.ts]"]
end

subgraph group_domain["Marketplace services"]
  node_pricing["Pricing and tax<br/>[pricing.ts]"]
  node_quality["Quality scoring<br/>[quality.ts]"]
  node_adjustment["Return adjustments<br/>[adjustment.ts]"]
  node_returnservice["Return service<br/>[returns.ts]"]
  node_orderservice["Order service<br/>[orders.ts]"]
  node_ledger["Double-entry ledger<br/>[ledger.ts]"]
  node_config["Marketplace config<br/>[config.ts]"]
end

subgraph group_state["State and evidence"]
  node_database[("PostgreSQL<br/>[db.ts]")]
  node_storage["Evidence storage<br/>[storage.ts]"]
end

node_supplier(("Supplier"))
node_buyer(("Buyer"))
node_admin(("Admin"))
node_supabase["Supabase Storage"]

node_supplier -->|"uses portal"| node_webapp
node_buyer -->|"uses portal"| node_webapp
node_admin -->|"uses portal"| node_webapp
node_webapp -->|"provides session"| node_authui
node_webapp -->|"routes supplier"| node_supplierpages
node_webapp -->|"routes buyer"| node_buyerpages
node_webapp -->|"routes orders"| node_orderui
node_webapp -->|"routes admin"| node_adminui
node_authui -->|"requests identity"| node_apiclient
node_supplierpages -->|"calls API"| node_apiclient
node_buyerpages -->|"calls API"| node_apiclient
node_orderui -->|"calls API"| node_apiclient
node_adminui -->|"calls API"| node_apiclient
node_apiclient -->|"sends requests"| node_app
node_app -->|"dispatches auth"| node_authroutes
node_app -->|"dispatches catalog"| node_catalog
node_app -->|"dispatches uploads"| node_evidence
node_app -->|"dispatches supplier"| node_supplierapi
node_app -->|"dispatches RFQ"| node_rfq
node_app -->|"dispatches orders"| node_ordersapi
node_app -->|"dispatches returns"| node_returnsapi
node_app -->|"dispatches admin"| node_adminapi
node_authroutes -->|"queries users"| node_database
node_evidence -->|"stores evidence"| node_storage
node_storage -.->|"uploads when configured"| node_supabase

click node_webapp "https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/main.tsx"
click node_authui "https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/auth.tsx"
click node_buyerpages "https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/buyer"
click node_supplierpages "https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/supplier"
click node_orderui "https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/pages/OrderDetail.tsx"
click node_adminui "https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/admin"
click node_apiclient "https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/api.ts"
click node_app "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/app.ts"
click node_authroutes "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/auth.ts"
click node_catalog "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/catalog.ts"
click node_evidence "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/evidence.ts"
click node_supplierapi "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/supplier.ts"
click node_rfq "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/rfq.ts"
click node_ordersapi "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/orders.ts"
click node_returnsapi "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/returns.ts"
click node_adminapi "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/admin.ts"
click node_pricing "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/pricing.ts"
click node_quality "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/quality.ts"
click node_adjustment "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/adjustment.ts"
click node_returnservice "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/returns.ts"
click node_orderservice "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/orders.ts"
click node_ledger "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/ledger.ts"
click node_config "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/config.ts"
click node_database "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/db.ts"
click node_storage "https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/lib/storage.ts"

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_authui,node_buyerpages,node_supplierpages,node_orderui,node_adminui,node_apiclient toneBlue
class node_app,node_authroutes,node_catalog,node_evidence,node_supplierapi,node_rfq,node_ordersapi,node_returnsapi,node_adminapi,node_supabase toneAmber
class node_pricing,node_quality,node_adjustment,node_returnservice,node_orderservice,node_ledger,node_config toneMint
class node_database,node_storage toneRose
class node_supplier,node_buyer,node_admin toneIndigo
```

## Components

### Web portals

- [Portal router](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/main.tsx): `web/src/main.tsx`
- [Session state](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/auth.tsx): `web/src/lib/auth.tsx`
- [Buyer portal](https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/buyer): `web/src/pages/buyer`
- [Supplier portal](https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/supplier): `web/src/pages/supplier`
- [Order and returns](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/pages/OrderDetail.tsx): `web/src/pages/OrderDetail.tsx`
- [Admin panel](https://github.com/erzamadana-ui/supplier-id/tree/main/web/src/pages/admin): `web/src/pages/admin`
- [API client](https://github.com/erzamadana-ui/supplier-id/blob/main/web/src/lib/api.ts): `web/src/lib/api.ts`

### API workflows

- [Express app](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`
- [Catalog and evidence](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/catalog.ts): `server/src/routes/catalog.ts`
- [Evidence uploads](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/evidence.ts): `server/src/routes/evidence.ts`
- [Supplier operations](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/supplier.ts): `server/src/routes/supplier.ts`
- [RFQ workflow](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/rfq.ts): `server/src/routes/rfq.ts`
- [Order workflow](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/orders.ts): `server/src/routes/orders.ts`
- [Returns workflow](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/returns.ts): `server/src/routes/returns.ts`
- [Admin operations](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/routes/admin.ts): `server/src/routes/admin.ts`

### Marketplace services

- [Pricing and tax](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/pricing.ts): `server/src/services/pricing.ts`
- [Quality scoring](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/quality.ts): `server/src/services/quality.ts`
- [Return adjustments](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/adjustment.ts): `server/src/services/adjustment.ts`
- [Return service](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/returns.ts): `server/src/services/returns.ts`
- [Order service](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/orders.ts): `server/src/services/orders.ts`
- [Double-entry ledger](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/ledger.ts): `server/src/services/ledger.ts`
- [Marketplace config](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/services/config.ts): `server/src/services/config.ts`

### State and evidence

- [PostgreSQL](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/db.ts): `server/src/db.ts`
- [Evidence storage](https://github.com/erzamadana-ui/supplier-id/blob/main/server/src/lib/storage.ts): `server/src/lib/storage.ts`

### Other components

- **Supplier**
- **Buyer**
- **Admin**
- **Supabase Storage**

## Connections

- Supplier → Portal router: uses portal
- Buyer → Portal router: uses portal
- Admin → Portal router: uses portal
- Portal router → Session state: provides session
- Portal router → Supplier portal: routes supplier
- Portal router → Buyer portal: routes buyer
- Portal router → Order and returns: routes orders
- Portal router → Admin panel: routes admin
- Session state → API client: requests identity
- Supplier portal → API client: calls API
- Buyer portal → API client: calls API
- Order and returns → API client: calls API
- Admin panel → API client: calls API
- API client → Express app: sends requests
- Express app → Authentication: dispatches auth
- Express app → Catalog and evidence: dispatches catalog
- Express app → Evidence uploads: dispatches uploads
- Express app → Supplier operations: dispatches supplier
- Express app → RFQ workflow: dispatches RFQ
- Express app → Order workflow: dispatches orders
- Express app → Returns workflow: dispatches returns
- Express app → Admin operations: dispatches admin
- Authentication → PostgreSQL: queries users
- Evidence uploads → Evidence storage: stores evidence
- Evidence storage → Supabase Storage: uploads when configured
