# tanqdev/acheter architecture

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

- Interactive diagram: https://gitdiagram.com/tanqdev/acheter
- Repository: https://github.com/tanqdev/acheter

## Overview

Acheter Hub is a React storefront backed by an Express API and PostgreSQL. The user journey runs from product browsing through cart management and authenticated checkout to order confirmation and order history; authentication is a supporting session-based workflow. The backend separates routes, controllers, and database-oriented services, with checkout protecting inventory inside a transaction. The README documents the broader client/API relationship and product capabilities; some individual page-to-endpoint calls were not shown in the sampled evidence.

Main entry points: [`client/src/App.tsx`](https://github.com/tanqdev/acheter/blob/main/client/src/App.tsx) (Client routing), [`server/src/db/pool.ts`](https://github.com/tanqdev/acheter/blob/main/server/src/db/pool.ts) (Postgres pool), [`server/src/server.ts`](https://github.com/tanqdev/acheter/blob/main/server/src/server.ts) (Express server), [`server/src/auth/auth.middleware.ts`](https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.middleware.ts) (Auth middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Client routing<br/>[App.tsx]"]
  node_catalog["Product browsing<br/>[Products.tsx]"]
  node_product_detail["Product details<br/>[ProductsDetail.tsx]"]
  node_cart_ui["Shopping cart<br/>[Cart.tsx]"]
  node_checkout_ui["Checkout form<br/>[Checkout.tsx]"]
  node_order_result["Order confirmation"]
  node_order_history["Order history<br/>[Orders.tsx]"]
  node_auth_ui["Auth screens<br/>[Login.tsx]"]
  node_auth_context["Session client<br/>[AuthContext.tsx]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_auth_service["Account service<br/>[auth.service.ts]"]
  node_sessions["Session handling<br/>[sessions.ts]"]
  node_auth_middleware["Auth middleware<br/>[auth.middleware.ts]"]
end

subgraph group_commerce["Commerce API"]
  node_api_server["Express server<br/>[server.ts]"]
  node_product_routes["Product routes<br/>[product.route.ts]"]
  node_product_controller["Product controller"]
  node_product_service["Product service<br/>[product.service.ts]"]
  node_cart_routes["Cart routes<br/>[cart.route.ts]"]
  node_cart_controller["Cart controller<br/>[cart.controller.ts]"]
  node_cart_service["Cart service<br/>[cart.services.ts]"]
  node_order_routes["Order routes<br/>[order.route.ts]"]
  node_order_controller["Order controller"]
  node_order_service["Order service<br/>[order.services.ts]"]
end

subgraph group_persistence["Persistence"]
  node_pool["Postgres pool<br/>[pool.ts]"]
  node_postgres[("PostgreSQL")]
end

node_shopper(("Shopper"))
node_api["HTTP API"]

node_shopper -->|"uses storefront"| node_app
node_app -->|"routes to"| node_catalog
node_app -->|"routes to"| node_product_detail
node_app -->|"routes to"| node_cart_ui
node_app -->|"routes to"| node_checkout_ui
node_app -->|"routes to"| node_order_result
node_app -->|"routes to"| node_order_history
node_app -->|"routes to"| node_auth_ui
node_auth_ui -->|"uses session"| node_auth_context
node_auth_context -->|"requests auth"| node_api
node_app -->|"makes API requests"| node_api
node_api -->|"HTTP requests"| node_api_server
node_api_server -->|"mounts"| node_product_routes
node_api_server -->|"mounts"| node_cart_routes
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_order_routes
node_product_routes -->|"dispatches"| node_product_controller
node_product_controller -->|"calls"| node_product_service
node_product_service -->|"queries"| node_pool
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_controller -->|"manages sessions"| node_sessions
node_auth_routes -->|"protects routes"| node_auth_middleware
node_auth_middleware -->|"checks session"| node_sessions
node_auth_service -->|"queries"| node_pool
node_sessions -->|"queries"| node_pool
node_cart_routes -->|"dispatches"| node_cart_controller
node_cart_routes -->|"protects routes"| node_auth_middleware
node_cart_controller -->|"calls"| node_cart_service
node_cart_service -->|"queries"| node_pool
node_order_routes -->|"dispatches"| node_order_controller
node_order_routes -->|"protects routes"| node_auth_middleware
node_order_controller -->|"calls"| node_order_service
node_order_service -->|"runs transactions"| node_pool
node_pool -->|"connects to"| node_postgres

click node_app "https://github.com/tanqdev/acheter/blob/main/client/src/App.tsx"
click node_catalog "https://github.com/tanqdev/acheter/blob/main/client/src/pages/Products.tsx"
click node_product_detail "https://github.com/tanqdev/acheter/blob/main/client/src/pages/ProductsDetail.tsx"
click node_cart_ui "https://github.com/tanqdev/acheter/blob/main/client/src/pages/Cart.tsx"
click node_checkout_ui "https://github.com/tanqdev/acheter/blob/main/client/src/pages/Checkout.tsx"
click node_order_result "https://github.com/tanqdev/acheter/blob/main/client/src/pages/OrderConfirmation.tsx"
click node_order_history "https://github.com/tanqdev/acheter/blob/main/client/src/pages/Orders.tsx"
click node_auth_ui "https://github.com/tanqdev/acheter/blob/main/client/src/pages/Login.tsx"
click node_auth_context "https://github.com/tanqdev/acheter/blob/main/client/src/context/AuthContext.tsx"
click node_api_server "https://github.com/tanqdev/acheter/blob/main/server/src/server.ts"
click node_product_routes "https://github.com/tanqdev/acheter/blob/main/server/src/routes/product.route.ts"
click node_product_controller "https://github.com/tanqdev/acheter/blob/main/server/src/controllers/product.controller.ts"
click node_product_service "https://github.com/tanqdev/acheter/blob/main/server/src/services/product.service.ts"
click node_auth_routes "https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.routes.ts"
click node_auth_controller "https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.service.ts"
click node_sessions "https://github.com/tanqdev/acheter/blob/main/server/src/auth/sessions.ts"
click node_auth_middleware "https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.middleware.ts"
click node_cart_routes "https://github.com/tanqdev/acheter/blob/main/server/src/routes/cart.route.ts"
click node_cart_controller "https://github.com/tanqdev/acheter/blob/main/server/src/controllers/cart.controller.ts"
click node_cart_service "https://github.com/tanqdev/acheter/blob/main/server/src/services/cart.services.ts"
click node_order_routes "https://github.com/tanqdev/acheter/blob/main/server/src/routes/order.route.ts"
click node_order_controller "https://github.com/tanqdev/acheter/blob/main/server/src/controllers/order.controller.ts"
click node_order_service "https://github.com/tanqdev/acheter/blob/main/server/src/services/order.services.ts"
click node_pool "https://github.com/tanqdev/acheter/blob/main/server/src/db/pool.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_app,node_catalog,node_product_detail,node_cart_ui,node_checkout_ui,node_order_result,node_order_history,node_auth_ui,node_auth_context toneBlue
class node_auth_routes,node_auth_controller,node_auth_service,node_sessions,node_auth_middleware toneAmber
class node_api_server,node_product_routes,node_product_controller,node_product_service,node_cart_routes,node_cart_controller,node_cart_service,node_order_routes,node_order_controller,node_order_service,node_api toneMint
class node_pool,node_postgres toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Client routing](https://github.com/tanqdev/acheter/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Product browsing](https://github.com/tanqdev/acheter/blob/main/client/src/pages/Products.tsx): `client/src/pages/Products.tsx`
- [Product details](https://github.com/tanqdev/acheter/blob/main/client/src/pages/ProductsDetail.tsx): `client/src/pages/ProductsDetail.tsx`
- [Shopping cart](https://github.com/tanqdev/acheter/blob/main/client/src/pages/Cart.tsx): `client/src/pages/Cart.tsx`
- [Checkout form](https://github.com/tanqdev/acheter/blob/main/client/src/pages/Checkout.tsx): `client/src/pages/Checkout.tsx`
- [Order confirmation](https://github.com/tanqdev/acheter/blob/main/client/src/pages/OrderConfirmation.tsx): `client/src/pages/OrderConfirmation.tsx`
- [Order history](https://github.com/tanqdev/acheter/blob/main/client/src/pages/Orders.tsx): `client/src/pages/Orders.tsx`
- [Auth screens](https://github.com/tanqdev/acheter/blob/main/client/src/pages/Login.tsx): `client/src/pages/Login.tsx`
- [Session client](https://github.com/tanqdev/acheter/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`

### Identity

- [Auth routes](https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.routes.ts): `server/src/auth/auth.routes.ts`
- [Auth controller](https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.controller.ts): `server/src/auth/auth.controller.ts`
- [Account service](https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.service.ts): `server/src/auth/auth.service.ts`
- [Session handling](https://github.com/tanqdev/acheter/blob/main/server/src/auth/sessions.ts): `server/src/auth/sessions.ts`
- [Auth middleware](https://github.com/tanqdev/acheter/blob/main/server/src/auth/auth.middleware.ts): `server/src/auth/auth.middleware.ts`

### Commerce API

- [Express server](https://github.com/tanqdev/acheter/blob/main/server/src/server.ts): `server/src/server.ts`
- [Product routes](https://github.com/tanqdev/acheter/blob/main/server/src/routes/product.route.ts): `server/src/routes/product.route.ts`
- [Product controller](https://github.com/tanqdev/acheter/blob/main/server/src/controllers/product.controller.ts): `server/src/controllers/product.controller.ts`
- [Product service](https://github.com/tanqdev/acheter/blob/main/server/src/services/product.service.ts): `server/src/services/product.service.ts`
- [Cart routes](https://github.com/tanqdev/acheter/blob/main/server/src/routes/cart.route.ts): `server/src/routes/cart.route.ts`
- [Cart controller](https://github.com/tanqdev/acheter/blob/main/server/src/controllers/cart.controller.ts): `server/src/controllers/cart.controller.ts`
- [Cart service](https://github.com/tanqdev/acheter/blob/main/server/src/services/cart.services.ts): `server/src/services/cart.services.ts`
- [Order routes](https://github.com/tanqdev/acheter/blob/main/server/src/routes/order.route.ts): `server/src/routes/order.route.ts`
- [Order controller](https://github.com/tanqdev/acheter/blob/main/server/src/controllers/order.controller.ts): `server/src/controllers/order.controller.ts`
- [Order service](https://github.com/tanqdev/acheter/blob/main/server/src/services/order.services.ts): `server/src/services/order.services.ts`

### Persistence

- [Postgres pool](https://github.com/tanqdev/acheter/blob/main/server/src/db/pool.ts): `server/src/db/pool.ts`
- **PostgreSQL**

### Other components

- **Shopper**
- **HTTP API**

## Connections

- Shopper → Client routing: uses storefront
- Client routing → Product browsing: routes to (evidence: `client/src/App.tsx`)
- Client routing → Product details: routes to (evidence: `client/src/App.tsx`)
- Client routing → Shopping cart: routes to (evidence: `client/src/App.tsx`)
- Client routing → Checkout form: routes to (evidence: `client/src/App.tsx`)
- Client routing → Order confirmation: routes to (evidence: `client/src/App.tsx`)
- Client routing → Order history: routes to (evidence: `client/src/App.tsx`)
- Client routing → Auth screens: routes to (evidence: `client/src/App.tsx`)
- Auth screens → Session client: uses session (evidence: `client/src/context/AuthContext.tsx`)
- Session client → HTTP API: requests auth (evidence: `client/src/context/AuthContext.tsx`)
- Client routing → HTTP API: makes API requests
- HTTP API → Express server: HTTP requests
- Express server → Product routes: mounts (evidence: `server/src/server.ts`)
- Express server → Cart routes: mounts (evidence: `server/src/server.ts`)
- Express server → Auth routes: mounts (evidence: `server/src/server.ts`)
- Express server → Order routes: mounts (evidence: `server/src/server.ts`)
- Product routes → Product controller: dispatches (evidence: `server/src/routes/product.route.ts`)
- Product controller → Product service: calls (evidence: `server/src/controllers/product.controller.ts`)
- Product service → Postgres pool: queries (evidence: `server/src/services/product.service.ts`)
- Auth routes → Auth controller: dispatches (evidence: `server/src/auth/auth.routes.ts`)
- Auth controller → Account service: calls (evidence: `server/src/auth/auth.controller.ts`)
- Auth controller → Session handling: manages sessions (evidence: `server/src/auth/auth.controller.ts`)
- Auth routes → Auth middleware: protects routes (evidence: `server/src/auth/auth.routes.ts`)
- Auth middleware → Session handling: checks session (evidence: `server/src/auth/auth.middleware.ts`)
- Account service → Postgres pool: queries (evidence: `server/src/auth/auth.service.ts`)
- Session handling → Postgres pool: queries (evidence: `server/src/auth/sessions.ts`)
- Cart routes → Cart controller: dispatches (evidence: `server/src/routes/cart.route.ts`)
- Cart routes → Auth middleware: protects routes (evidence: `server/src/routes/cart.route.ts`)
- Cart controller → Cart service: calls (evidence: `server/src/controllers/cart.controller.ts`)
- Cart service → Postgres pool: queries (evidence: `server/src/services/cart.services.ts`)
- Order routes → Order controller: dispatches (evidence: `server/src/routes/order.route.ts`)
- Order routes → Auth middleware: protects routes (evidence: `server/src/routes/order.route.ts`)
- Order controller → Order service: calls (evidence: `server/src/controllers/order.controller.ts`)
- Order service → Postgres pool: runs transactions (evidence: `server/src/services/order.services.ts`)
- Postgres pool → PostgreSQL: connects to
