# abumotlaq/raqami architecture

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

- Interactive diagram: https://gitdiagram.com/abumotlaq/raqami
- Repository: https://github.com/abumotlaq/raqami

## Overview

Raqami is a digital-download storefront. Customers browse products, register or sign in, add products to a cart, place orders, and access purchased files in their library; administrators manage products and review orders. The frontend calls the Express API, whose domain routes use PostgreSQL-backed data and serialize API responses. The graph preserves the documented storefront, checkout, library, and admin capabilities. Some page and route implementations were not sampled, so uncertain internal calls are omitted rather than inferred.

Main entry points: [`server/src/app.ts`](https://github.com/abumotlaq/raqami/blob/main/server/src/app.ts) (HTTP application), [`server/src/db/index.ts`](https://github.com/abumotlaq/raqami/blob/main/server/src/db/index.ts) (Database connection), [`client/src/services/api.ts`](https://github.com/abumotlaq/raqami/blob/main/client/src/services/api.ts) (API client), [`client/src/routes/AppRoutes.tsx`](https://github.com/abumotlaq/raqami/blob/main/client/src/routes/AppRoutes.tsx) (Page routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Storefront client"]
  node_routes["Page routing<br/>[AppRoutes.tsx]"]
  node_authstate["Authentication state<br/>[AuthContext.tsx]"]
  node_cartstate["Cart state<br/>[CartContext.tsx]"]
  node_productlist["Product browsing<br/>[useProducts.ts]"]
  node_clientapi["API client<br/>[api.ts]"]
  node_contracts["API data types<br/>[api.ts]"]
  node_productadmin["Product administration"]
end

subgraph group_api["API and access"]
  node_serverapp["HTTP application<br/>[app.ts]"]
  node_authmw["Authentication checks<br/>[auth.ts]"]
  node_authroutes["Account routes<br/>[auth.ts]"]
end

subgraph group_commerce["Commerce services"]
  node_productroutes["Product routes<br/>[products.ts]"]
  node_cartroutes["Cart routes<br/>[cart.ts]"]
  node_ordersroutes["Order routes<br/>[orders.ts]"]
  node_orderservice["Order processing<br/>[orders.ts]"]
  node_adminroutes["Admin routes<br/>[admin.ts]"]
  node_libraryroutes["Library and downloads<br/>[library.ts]"]
  node_paymentsandbox["Payment sandbox<br/>[sandbox.ts]"]
end

subgraph group_data["Persistence and files"]
  node_database[("PostgreSQL data<br/>[schema.ts]")]
  node_dbclient["Database connection<br/>[index.ts]"]
  node_serializer["Response serialization<br/>[serialize.ts]"]
  node_privatefiles["Private product files<br/>[env.ts]"]
end

node_customer(("Customer"))
node_admin(("Administrator"))

node_customer -->|"uses storefront"| node_routes
node_admin -->|"uses admin pages"| node_routes
node_routes -.->|"guards pages"| node_authstate
node_routes -->|"routes to"| node_productadmin
node_authstate -->|"requests account"| node_clientapi
node_cartstate -->|"requests cart"| node_clientapi
node_productlist -->|"fetches products"| node_clientapi
node_clientapi -->|"uses types"| node_contracts
node_clientapi -->|"calls API"| node_serverapp
node_serverapp -->|"mounts routes"| node_authroutes
node_serverapp -->|"mounts routes"| node_productroutes
node_serverapp -->|"mounts routes"| node_cartroutes
node_serverapp -->|"mounts routes"| node_ordersroutes
node_serverapp -->|"mounts routes"| node_libraryroutes
node_serverapp -->|"mounts routes"| node_adminroutes
node_authmw -->|"loads user"| node_dbclient
node_authmw -->|"checks user"| node_database
node_authroutes -->|"accesses data"| node_dbclient
node_productroutes -->|"queries products"| node_dbclient
node_cartroutes -->|"accesses cart"| node_dbclient
node_ordersroutes -.->|"delegates orders"| node_orderservice
node_adminroutes -->|"uses order service"| node_orderservice
node_adminroutes -->|"uses product logic"| node_productroutes
node_libraryroutes -->|"accesses purchases"| node_dbclient
node_orderservice -->|"requests payment"| node_paymentsandbox
node_orderservice -->|"accesses order data"| node_dbclient
node_dbclient -->|"uses schema"| node_database
node_serializer -->|"serializes rows"| node_database
node_libraryroutes -.->|"serves downloads"| node_privatefiles

click node_routes "https://github.com/abumotlaq/raqami/blob/main/client/src/routes/AppRoutes.tsx"
click node_authstate "https://github.com/abumotlaq/raqami/blob/main/client/src/context/AuthContext.tsx"
click node_cartstate "https://github.com/abumotlaq/raqami/blob/main/client/src/context/CartContext.tsx"
click node_productlist "https://github.com/abumotlaq/raqami/blob/main/client/src/hooks/useProducts.ts"
click node_clientapi "https://github.com/abumotlaq/raqami/blob/main/client/src/services/api.ts"
click node_contracts "https://github.com/abumotlaq/raqami/blob/main/client/src/types/api.ts"
click node_productadmin "https://github.com/abumotlaq/raqami/blob/main/client/src/pages/AdminProductsPage.tsx"
click node_serverapp "https://github.com/abumotlaq/raqami/blob/main/server/src/app.ts"
click node_authmw "https://github.com/abumotlaq/raqami/blob/main/server/src/middleware/auth.ts"
click node_authroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/auth.ts"
click node_productroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/products.ts"
click node_cartroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/cart.ts"
click node_ordersroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/orders.ts"
click node_orderservice "https://github.com/abumotlaq/raqami/blob/main/server/src/services/orders.ts"
click node_adminroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/admin.ts"
click node_libraryroutes "https://github.com/abumotlaq/raqami/blob/main/server/src/routes/library.ts"
click node_paymentsandbox "https://github.com/abumotlaq/raqami/blob/main/server/src/payment/sandbox.ts"
click node_database "https://github.com/abumotlaq/raqami/blob/main/server/src/db/schema.ts"
click node_dbclient "https://github.com/abumotlaq/raqami/blob/main/server/src/db/index.ts"
click node_serializer "https://github.com/abumotlaq/raqami/blob/main/server/src/lib/serialize.ts"
click node_privatefiles "https://github.com/abumotlaq/raqami/blob/main/server/src/env.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_routes,node_authstate,node_cartstate,node_productlist,node_clientapi,node_contracts,node_productadmin toneBlue
class node_serverapp,node_authmw,node_authroutes toneAmber
class node_productroutes,node_cartroutes,node_ordersroutes,node_orderservice,node_adminroutes,node_libraryroutes,node_paymentsandbox toneMint
class node_database,node_dbclient,node_serializer,node_privatefiles toneRose
class node_customer,node_admin toneIndigo
```

## Components

### Storefront client

- [Page routing](https://github.com/abumotlaq/raqami/blob/main/client/src/routes/AppRoutes.tsx): `client/src/routes/AppRoutes.tsx`
- [Authentication state](https://github.com/abumotlaq/raqami/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`
- [Cart state](https://github.com/abumotlaq/raqami/blob/main/client/src/context/CartContext.tsx): `client/src/context/CartContext.tsx`
- [Product browsing](https://github.com/abumotlaq/raqami/blob/main/client/src/hooks/useProducts.ts): `client/src/hooks/useProducts.ts`
- [API client](https://github.com/abumotlaq/raqami/blob/main/client/src/services/api.ts): `client/src/services/api.ts`
- [API data types](https://github.com/abumotlaq/raqami/blob/main/client/src/types/api.ts): `client/src/types/api.ts`
- [Product administration](https://github.com/abumotlaq/raqami/blob/main/client/src/pages/AdminProductsPage.tsx): `client/src/pages/AdminProductsPage.tsx`

### API and access

- [HTTP application](https://github.com/abumotlaq/raqami/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication checks](https://github.com/abumotlaq/raqami/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [Account routes](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`

### Commerce services

- [Product routes](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/products.ts): `server/src/routes/products.ts`
- [Cart routes](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/cart.ts): `server/src/routes/cart.ts`
- [Order routes](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/orders.ts): `server/src/routes/orders.ts`
- [Order processing](https://github.com/abumotlaq/raqami/blob/main/server/src/services/orders.ts): `server/src/services/orders.ts`
- [Admin routes](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/admin.ts): `server/src/routes/admin.ts`
- [Library and downloads](https://github.com/abumotlaq/raqami/blob/main/server/src/routes/library.ts): `server/src/routes/library.ts`
- [Payment sandbox](https://github.com/abumotlaq/raqami/blob/main/server/src/payment/sandbox.ts): `server/src/payment/sandbox.ts`

### Persistence and files

- [PostgreSQL data](https://github.com/abumotlaq/raqami/blob/main/server/src/db/schema.ts): `server/src/db/schema.ts`
- [Database connection](https://github.com/abumotlaq/raqami/blob/main/server/src/db/index.ts): `server/src/db/index.ts`
- [Response serialization](https://github.com/abumotlaq/raqami/blob/main/server/src/lib/serialize.ts): `server/src/lib/serialize.ts`
- [Private product files](https://github.com/abumotlaq/raqami/blob/main/server/src/env.ts): `server/src/env.ts`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Page routing: uses storefront (evidence: `client/src/routes/AppRoutes.tsx`)
- Administrator → Page routing: uses admin pages (evidence: `client/src/routes/AppRoutes.tsx`)
- Page routing → Authentication state: guards pages
- Page routing → Product administration: routes to (evidence: `client/src/routes/AppRoutes.tsx`)
- Authentication state → API client: requests account (evidence: `client/src/context/AuthContext.tsx`)
- Cart state → API client: requests cart (evidence: `client/src/context/CartContext.tsx`)
- Product browsing → API client: fetches products (evidence: `client/src/hooks/useProducts.ts`)
- API client → API data types: uses types (evidence: `client/src/services/api.ts`)
- API client → HTTP application: calls API (evidence: `client/src/services/api.ts`)
- HTTP application → Account routes: mounts routes (evidence: `server/src/app.ts`)
- HTTP application → Product routes: mounts routes (evidence: `server/src/app.ts`)
- HTTP application → Cart routes: mounts routes (evidence: `server/src/app.ts`)
- HTTP application → Order routes: mounts routes (evidence: `server/src/app.ts`)
- HTTP application → Library and downloads: mounts routes (evidence: `server/src/app.ts`)
- HTTP application → Admin routes: mounts routes (evidence: `server/src/app.ts`)
- Authentication checks → Database connection: loads user (evidence: `server/src/middleware/auth.ts`)
- Authentication checks → PostgreSQL data: checks user (evidence: `server/src/middleware/auth.ts`)
- Account routes → Database connection: accesses data (evidence: `server/src/routes/auth.ts`)
- Product routes → Database connection: queries products (evidence: `server/src/routes/products.ts`)
- Cart routes → Database connection: accesses cart (evidence: `server/src/routes/cart.ts`)
- Order routes → Order processing: delegates orders
- Admin routes → Order processing: uses order service (evidence: `server/src/routes/admin.ts`)
- Admin routes → Product routes: uses product logic (evidence: `server/src/routes/admin.ts`)
- Library and downloads → Database connection: accesses purchases (evidence: `server/src/routes/library.ts`)
- Order processing → Payment sandbox: requests payment (evidence: `server/src/services/orders.ts`)
- Order processing → Database connection: accesses order data (evidence: `server/src/services/orders.ts`)
- Database connection → PostgreSQL data: uses schema (evidence: `server/src/db/index.ts`)
- Response serialization → PostgreSQL data: serializes rows (evidence: `server/src/lib/serialize.ts`)
- Library and downloads → Private product files: serves downloads (evidence: `server/src/routes/library.ts`)
