# sidali-kh/northwind architecture

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

- Interactive diagram: https://gitdiagram.com/sidali-kh/northwind
- Repository: https://github.com/sidali-kh/northwind

## Overview

This repository is an early-stage commerce application: the frontend currently exposes Clerk sign-in and sign-up, while the backend accepts Clerk user webhooks and synchronizes user records into PostgreSQL. The schema also models products, checkout sessions, orders, and order items, but the provided source shows no purchase or catalog workflow. Polar, Stream, ImageKit, and Sentry appear in configuration or dependencies only; their runtime behavior is not established by the excerpts.

Main entry points: [`Backend/src/webhooks/clerk.ts`](https://github.com/sidali-kh/northwind/blob/main/Backend/src/webhooks/clerk.ts) (User webhook), [`Frontend/src/main.jsx`](https://github.com/sidali-kh/northwind/blob/main/Frontend/src/main.jsx) (React bootstrap), [`Backend/src/db/index.ts`](https://github.com/sidali-kh/northwind/blob/main/Backend/src/db/index.ts) (Drizzle adapter), [`Backend/src/index.ts`](https://github.com/sidali-kh/northwind/blob/main/Backend/src/index.ts) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_frontend_entry["React bootstrap<br/>[main.jsx]"]
  node_auth_ui["Sign-in UI<br/>[App.jsx]"]
end

subgraph group_service["Backend and identity"]
  node_api_server["Express server<br/>[index.ts]"]
  node_clerk_webhook["User webhook<br/>[clerk.ts]"]
  node_env_config["Environment config<br/>[env.ts]"]
  node_role_rules["Role parsing<br/>[roles.ts]"]
end

subgraph group_data["Commerce data"]
  node_db_adapter["Drizzle adapter<br/>[index.ts]"]
  node_commerce_schema["Commerce schema<br/>[schema.ts]"]
end

node_visitor(("Visitor"))
node_clerk{{"Clerk identity"}}
node_postgres[("PostgreSQL")]

node_visitor -->|"opens app"| node_frontend_entry
node_frontend_entry -->|"renders"| node_auth_ui
node_frontend_entry -->|"provides identity"| node_clerk
node_auth_ui -->|"shows auth controls"| node_clerk
node_api_server -->|"routes webhook"| node_clerk_webhook
node_api_server -->|"loads settings"| node_env_config
node_clerk -.->|"sends user events"| node_clerk_webhook
node_clerk_webhook -->|"verifies signature"| node_clerk
node_clerk_webhook -->|"reads secret"| node_env_config
node_clerk_webhook -->|"parses role"| node_role_rules
node_clerk_webhook -->|"upserts users"| node_db_adapter
node_role_rules -->|"uses role type"| node_commerce_schema
node_db_adapter -->|"loads schema"| node_commerce_schema
node_db_adapter -.->|"stores records"| node_postgres

click node_frontend_entry "https://github.com/sidali-kh/northwind/blob/main/Frontend/src/main.jsx"
click node_auth_ui "https://github.com/sidali-kh/northwind/blob/main/Frontend/src/App.jsx"
click node_api_server "https://github.com/sidali-kh/northwind/blob/main/Backend/src/index.ts"
click node_clerk_webhook "https://github.com/sidali-kh/northwind/blob/main/Backend/src/webhooks/clerk.ts"
click node_env_config "https://github.com/sidali-kh/northwind/blob/main/Backend/src/lib/env.ts"
click node_role_rules "https://github.com/sidali-kh/northwind/blob/main/Backend/src/lib/roles.ts"
click node_db_adapter "https://github.com/sidali-kh/northwind/blob/main/Backend/src/db/index.ts"
click node_commerce_schema "https://github.com/sidali-kh/northwind/blob/main/Backend/src/db/schema.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_frontend_entry,node_auth_ui toneBlue
class node_api_server,node_clerk_webhook,node_env_config,node_role_rules,node_postgres toneAmber
class node_db_adapter,node_commerce_schema toneMint
class node_visitor,node_clerk toneIndigo
```

## Components

### Web client

- [React bootstrap](https://github.com/sidali-kh/northwind/blob/main/Frontend/src/main.jsx): `Frontend/src/main.jsx`
- [Sign-in UI](https://github.com/sidali-kh/northwind/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`

### Backend and identity

- [Express server](https://github.com/sidali-kh/northwind/blob/main/Backend/src/index.ts): `Backend/src/index.ts`
- [User webhook](https://github.com/sidali-kh/northwind/blob/main/Backend/src/webhooks/clerk.ts): `Backend/src/webhooks/clerk.ts`
- [Environment config](https://github.com/sidali-kh/northwind/blob/main/Backend/src/lib/env.ts): `Backend/src/lib/env.ts`
- [Role parsing](https://github.com/sidali-kh/northwind/blob/main/Backend/src/lib/roles.ts): `Backend/src/lib/roles.ts`

### Commerce data

- [Drizzle adapter](https://github.com/sidali-kh/northwind/blob/main/Backend/src/db/index.ts): `Backend/src/db/index.ts`
- [Commerce schema](https://github.com/sidali-kh/northwind/blob/main/Backend/src/db/schema.ts): `Backend/src/db/schema.ts`

### Other components

- **Visitor**
- **Clerk identity**
- **PostgreSQL**

## Connections

- Visitor → React bootstrap: opens app (evidence: `Frontend/src/main.jsx`)
- React bootstrap → Sign-in UI: renders (evidence: `Frontend/src/main.jsx`)
- React bootstrap → Clerk identity: provides identity (evidence: `Frontend/src/main.jsx`)
- Sign-in UI → Clerk identity: shows auth controls (evidence: `Frontend/src/App.jsx`)
- Express server → User webhook: routes webhook (evidence: `Backend/src/index.ts`)
- Express server → Environment config: loads settings (evidence: `Backend/src/index.ts`)
- Clerk identity → User webhook: sends user events
- User webhook → Clerk identity: verifies signature (evidence: `Backend/src/webhooks/clerk.ts`)
- User webhook → Environment config: reads secret (evidence: `Backend/src/webhooks/clerk.ts`)
- User webhook → Role parsing: parses role (evidence: `Backend/src/webhooks/clerk.ts`)
- User webhook → Drizzle adapter: upserts users (evidence: `Backend/src/webhooks/clerk.ts`)
- Role parsing → Commerce schema: uses role type (evidence: `Backend/src/lib/roles.ts`)
- Drizzle adapter → Commerce schema: loads schema (evidence: `Backend/src/db/index.ts`)
- Drizzle adapter → PostgreSQL: stores records
