# rammache/jbf architecture

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

- Interactive diagram: https://gitdiagram.com/rammache/jbf
- Repository: https://github.com/rammache/jbf

## Overview

Jabour Phone is a React storefront and Express/Prisma commerce backend. Customers browse products, build a cart, apply a coupon and place an order; the API verifies and persists the order and sends notifications. Administrators sign in to manage catalog, orders, coupons and store operations. The graph preserves documented review, newsletter, localization and administration capabilities. Several route and page implementations were not sampled, so their documented roles are shown without inventing internal calls; dashed links mark relationships not verified in excerpts.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rammache/jbf/blob/main/frontend/src/App.tsx) (Route application), [`backend/src/routes/api.ts`](https://github.com/rammache/jbf/blob/main/backend/src/routes/api.ts) (API routes), [`backend/src/controllers/orderController.ts`](https://github.com/rammache/jbf/blob/main/backend/src/controllers/orderController.ts) (Order processing), [`frontend/src/context/CartContext.tsx`](https://github.com/rammache/jbf/blob/main/frontend/src/context/CartContext.tsx) (Cart state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront experience"]
  node_app["Route application<br/>[App.tsx]"]
  node_home["Home and catalog<br/>[Home.tsx]"]
  node_shop["Product search<br/>[Shop.tsx]"]
  node_detail["Product detail<br/>[ProductDetail.tsx]"]
  node_cart["Cart state<br/>[CartContext.tsx]"]
  node_checkout["Checkout<br/>[CheckoutModal.tsx]"]
  node_tracking["Order tracking<br/>[OrderTracking.tsx]"]
  node_locale["Language and settings"]
  node_client["API client<br/>[client.ts]"]
end

subgraph group_commerce["Commerce API"]
  node_server["Express app<br/>[server.ts]"]
  node_api["API routes<br/>[api.ts]"]
  node_products["Product catalog"]
  node_categories["Categories"]
  node_orders["Order processing<br/>[orderController.ts]"]
  node_coupons["Coupon rules"]
  node_reviews["Product reviews"]
  node_newsletter["Newsletter"]
  node_email["Order notifications<br/>[emailService.ts]"]
end

subgraph group_operations["Admin operations"]
  node_adminroutes["Admin API routes<br/>[admin.ts]"]
  node_admincatalog["Catalog administration"]
  node_adminorders["Order administration"]
  node_adminlogin["Admin authentication<br/>[authController.ts]"]
  node_adminui["Admin pages<br/>[AdminProducts.tsx]"]
  node_authcontext["Admin session<br/>[AuthContext.tsx]"]
end

subgraph group_platform["Shared platform"]
  node_dbclient["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
  node_cartitem["Cart and order types<br/>[index.ts]"]
  node_translationdata["Translation catalog<br/>[translations.ts]"]
  node_categorycontext["Category state"]
  node_settingscontext["Store settings"]
  node_slug["Product slug rules<br/>[slug.ts]"]
  node_decimal["Money conversion<br/>[decimal.ts]"]
end

node_shopper(("Shopper"))
node_admin(("Administrator"))

node_shopper -->|"opens storefront"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_shop
node_app -.->|"routes to"| node_detail
node_app -.->|"routes to"| node_tracking
node_home -.->|"loads products"| node_products
node_shop -.->|"queries catalog"| node_products
node_home -->|"uses categories"| node_categorycontext
node_detail -->|"adds items"| node_cart
node_cart -.->|"provides basket"| node_checkout
node_cart -->|"stores items"| node_cartitem
node_cart -->|"validates coupon"| node_coupons
node_checkout -.->|"submits order"| node_client
node_client -.->|"calls REST API"| node_server
node_server -->|"mounts routes"| node_api
node_api -->|"routes requests"| node_products
node_api -->|"routes requests"| node_categories
node_api -->|"routes requests"| node_orders
node_api -->|"routes requests"| node_coupons
node_api -->|"routes requests"| node_reviews
node_api -->|"routes requests"| node_newsletter
node_orders -->|"reads and writes"| node_dbclient
node_dbclient -.->|"persists records"| node_database
node_orders -->|"sends notifications"| node_email
node_orders -->|"calculates discount"| node_coupons
node_orders -->|"converts amounts"| node_decimal
node_admin -->|"opens administration"| node_app
node_app -->|"routes protected pages"| node_adminui
node_adminui -->|"uses API"| node_client
node_adminui -->|"uses categories"| node_categorycontext
node_adminui -->|"uses settings"| node_settingscontext
node_authcontext -.->|"uses API"| node_client
node_adminroutes -.->|"routes requests"| node_admincatalog
node_adminroutes -.->|"routes requests"| node_adminorders
node_adminroutes -.->|"routes requests"| node_adminlogin
node_admincatalog -->|"reads and writes"| node_dbclient
node_admincatalog -->|"generates handles"| node_slug
node_admincatalog -->|"converts amounts"| node_decimal
node_reviews -->|"reads and writes"| node_dbclient
node_locale -->|"loads translations"| node_translationdata
node_settingscontext -->|"uses language"| node_locale
node_app -->|"provides language"| node_locale
node_app -->|"provides settings"| node_settingscontext
node_app -->|"provides categories"| node_categorycontext

click node_app "https://github.com/rammache/jbf/blob/main/frontend/src/App.tsx"
click node_home "https://github.com/rammache/jbf/blob/main/frontend/src/pages/Home.tsx"
click node_shop "https://github.com/rammache/jbf/blob/main/frontend/src/pages/Shop.tsx"
click node_detail "https://github.com/rammache/jbf/blob/main/frontend/src/pages/ProductDetail.tsx"
click node_cart "https://github.com/rammache/jbf/blob/main/frontend/src/context/CartContext.tsx"
click node_checkout "https://github.com/rammache/jbf/blob/main/frontend/src/components/CheckoutModal.tsx"
click node_tracking "https://github.com/rammache/jbf/blob/main/frontend/src/pages/OrderTracking.tsx"
click node_locale "https://github.com/rammache/jbf/blob/main/frontend/src/context/LanguageContext.tsx"
click node_client "https://github.com/rammache/jbf/blob/main/frontend/src/api/client.ts"
click node_server "https://github.com/rammache/jbf/blob/main/backend/src/server.ts"
click node_api "https://github.com/rammache/jbf/blob/main/backend/src/routes/api.ts"
click node_products "https://github.com/rammache/jbf/blob/main/backend/src/controllers/productController.ts"
click node_categories "https://github.com/rammache/jbf/blob/main/backend/src/controllers/categoryController.ts"
click node_orders "https://github.com/rammache/jbf/blob/main/backend/src/controllers/orderController.ts"
click node_coupons "https://github.com/rammache/jbf/blob/main/backend/src/controllers/couponController.ts"
click node_reviews "https://github.com/rammache/jbf/blob/main/backend/src/controllers/reviewController.ts"
click node_newsletter "https://github.com/rammache/jbf/blob/main/backend/src/controllers/newsletterController.ts"
click node_email "https://github.com/rammache/jbf/blob/main/backend/src/services/emailService.ts"
click node_adminroutes "https://github.com/rammache/jbf/blob/main/backend/src/routes/admin.ts"
click node_admincatalog "https://github.com/rammache/jbf/blob/main/backend/src/controllers/adminProductController.ts"
click node_adminorders "https://github.com/rammache/jbf/blob/main/backend/src/controllers/adminOrderController.ts"
click node_adminlogin "https://github.com/rammache/jbf/blob/main/backend/src/controllers/authController.ts"
click node_adminui "https://github.com/rammache/jbf/blob/main/frontend/src/pages/admin/AdminProducts.tsx"
click node_authcontext "https://github.com/rammache/jbf/blob/main/frontend/src/context/AuthContext.tsx"
click node_dbclient "https://github.com/rammache/jbf/blob/main/backend/src/prisma.ts"
click node_cartitem "https://github.com/rammache/jbf/blob/main/frontend/src/types/index.ts"
click node_translationdata "https://github.com/rammache/jbf/blob/main/frontend/src/i18n/translations.ts"
click node_categorycontext "https://github.com/rammache/jbf/blob/main/frontend/src/context/CategoryContext.tsx"
click node_settingscontext "https://github.com/rammache/jbf/blob/main/frontend/src/context/SettingsContext.tsx"
click node_slug "https://github.com/rammache/jbf/blob/main/backend/src/utils/slug.ts"
click node_decimal "https://github.com/rammache/jbf/blob/main/backend/src/utils/decimal.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_home,node_shop,node_detail,node_cart,node_checkout,node_tracking,node_locale,node_client toneBlue
class node_server,node_api,node_products,node_categories,node_orders,node_coupons,node_reviews,node_newsletter,node_email toneAmber
class node_adminroutes,node_admincatalog,node_adminorders,node_adminlogin,node_adminui,node_authcontext toneMint
class node_dbclient,node_database,node_cartitem,node_translationdata,node_categorycontext,node_settingscontext,node_slug,node_decimal toneRose
class node_shopper,node_admin toneIndigo
```

## Components

### Storefront experience

- [Route application](https://github.com/rammache/jbf/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Home and catalog](https://github.com/rammache/jbf/blob/main/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [Product search](https://github.com/rammache/jbf/blob/main/frontend/src/pages/Shop.tsx): `frontend/src/pages/Shop.tsx`
- [Product detail](https://github.com/rammache/jbf/blob/main/frontend/src/pages/ProductDetail.tsx): `frontend/src/pages/ProductDetail.tsx`
- [Cart state](https://github.com/rammache/jbf/blob/main/frontend/src/context/CartContext.tsx): `frontend/src/context/CartContext.tsx`
- [Checkout](https://github.com/rammache/jbf/blob/main/frontend/src/components/CheckoutModal.tsx): `frontend/src/components/CheckoutModal.tsx`
- [Order tracking](https://github.com/rammache/jbf/blob/main/frontend/src/pages/OrderTracking.tsx): `frontend/src/pages/OrderTracking.tsx`
- [Language and settings](https://github.com/rammache/jbf/blob/main/frontend/src/context/LanguageContext.tsx): `frontend/src/context/LanguageContext.tsx`
- [API client](https://github.com/rammache/jbf/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Commerce API

- [Express app](https://github.com/rammache/jbf/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [API routes](https://github.com/rammache/jbf/blob/main/backend/src/routes/api.ts): `backend/src/routes/api.ts`
- [Product catalog](https://github.com/rammache/jbf/blob/main/backend/src/controllers/productController.ts): `backend/src/controllers/productController.ts`
- [Categories](https://github.com/rammache/jbf/blob/main/backend/src/controllers/categoryController.ts): `backend/src/controllers/categoryController.ts`
- [Order processing](https://github.com/rammache/jbf/blob/main/backend/src/controllers/orderController.ts): `backend/src/controllers/orderController.ts`
- [Coupon rules](https://github.com/rammache/jbf/blob/main/backend/src/controllers/couponController.ts): `backend/src/controllers/couponController.ts`
- [Product reviews](https://github.com/rammache/jbf/blob/main/backend/src/controllers/reviewController.ts): `backend/src/controllers/reviewController.ts`
- [Newsletter](https://github.com/rammache/jbf/blob/main/backend/src/controllers/newsletterController.ts): `backend/src/controllers/newsletterController.ts`
- [Order notifications](https://github.com/rammache/jbf/blob/main/backend/src/services/emailService.ts): `backend/src/services/emailService.ts`

### Admin operations

- [Admin API routes](https://github.com/rammache/jbf/blob/main/backend/src/routes/admin.ts): `backend/src/routes/admin.ts`
- [Catalog administration](https://github.com/rammache/jbf/blob/main/backend/src/controllers/adminProductController.ts): `backend/src/controllers/adminProductController.ts`
- [Order administration](https://github.com/rammache/jbf/blob/main/backend/src/controllers/adminOrderController.ts): `backend/src/controllers/adminOrderController.ts`
- [Admin authentication](https://github.com/rammache/jbf/blob/main/backend/src/controllers/authController.ts): `backend/src/controllers/authController.ts`
- [Admin pages](https://github.com/rammache/jbf/blob/main/frontend/src/pages/admin/AdminProducts.tsx): `frontend/src/pages/admin/AdminProducts.tsx`
- [Admin session](https://github.com/rammache/jbf/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`

### Shared platform

- [Prisma client](https://github.com/rammache/jbf/blob/main/backend/src/prisma.ts): `backend/src/prisma.ts`
- **PostgreSQL**
- [Cart and order types](https://github.com/rammache/jbf/blob/main/frontend/src/types/index.ts): `frontend/src/types/index.ts`
- [Translation catalog](https://github.com/rammache/jbf/blob/main/frontend/src/i18n/translations.ts): `frontend/src/i18n/translations.ts`
- [Category state](https://github.com/rammache/jbf/blob/main/frontend/src/context/CategoryContext.tsx): `frontend/src/context/CategoryContext.tsx`
- [Store settings](https://github.com/rammache/jbf/blob/main/frontend/src/context/SettingsContext.tsx): `frontend/src/context/SettingsContext.tsx`
- [Product slug rules](https://github.com/rammache/jbf/blob/main/backend/src/utils/slug.ts): `backend/src/utils/slug.ts`
- [Money conversion](https://github.com/rammache/jbf/blob/main/backend/src/utils/decimal.ts): `backend/src/utils/decimal.ts`

### Other components

- **Shopper**
- **Administrator**

## Connections

- Shopper → Route application: opens storefront
- Route application → Home and catalog: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Product search: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Product detail: routes to (evidence: `frontend/src/App.tsx`)
- Route application → Order tracking: routes to (evidence: `frontend/src/App.tsx`)
- Home and catalog → Product catalog: loads products
- Product search → Product catalog: queries catalog
- Home and catalog → Category state: uses categories (evidence: `frontend/src/pages/Home.tsx`)
- Product detail → Cart state: adds items (evidence: `frontend/src/pages/ProductDetail.tsx`)
- Cart state → Checkout: provides basket
- Cart state → Cart and order types: stores items (evidence: `frontend/src/context/CartContext.tsx`)
- Cart state → Coupon rules: validates coupon (evidence: `frontend/src/context/CartContext.tsx`)
- Checkout → API client: submits order
- API client → Express app: calls REST API
- Express app → API routes: mounts routes (evidence: `backend/src/server.ts`)
- API routes → Product catalog: routes requests (evidence: `backend/src/routes/api.ts`)
- API routes → Categories: routes requests (evidence: `backend/src/routes/api.ts`)
- API routes → Order processing: routes requests (evidence: `backend/src/routes/api.ts`)
- API routes → Coupon rules: routes requests (evidence: `backend/src/routes/api.ts`)
- API routes → Product reviews: routes requests (evidence: `backend/src/routes/api.ts`)
- API routes → Newsletter: routes requests (evidence: `backend/src/routes/api.ts`)
- Order processing → Prisma client: reads and writes (evidence: `backend/src/controllers/orderController.ts`)
- Prisma client → PostgreSQL: persists records
- Order processing → Order notifications: sends notifications (evidence: `backend/src/controllers/orderController.ts`)
- Order processing → Coupon rules: calculates discount (evidence: `backend/src/controllers/orderController.ts`)
- Order processing → Money conversion: converts amounts (evidence: `backend/src/controllers/orderController.ts`)
- Administrator → Route application: opens administration
- Route application → Admin pages: routes protected pages (evidence: `frontend/src/App.tsx`)
- Admin pages → API client: uses API (evidence: `frontend/src/pages/admin/AdminProducts.tsx`)
- Admin pages → Category state: uses categories (evidence: `frontend/src/pages/admin/AdminProducts.tsx`)
- Admin pages → Store settings: uses settings (evidence: `frontend/src/pages/admin/AdminProducts.tsx`)
- Admin session → API client: uses API
- Admin API routes → Catalog administration: routes requests
- Admin API routes → Order administration: routes requests
- Admin API routes → Admin authentication: routes requests
- Catalog administration → Prisma client: reads and writes (evidence: `backend/src/controllers/adminProductController.ts`)
- Catalog administration → Product slug rules: generates handles (evidence: `backend/src/controllers/adminProductController.ts`)
- Catalog administration → Money conversion: converts amounts (evidence: `backend/src/controllers/adminProductController.ts`)
- Product reviews → Prisma client: reads and writes (evidence: `backend/src/controllers/reviewController.ts`)
- Language and settings → Translation catalog: loads translations (evidence: `frontend/src/context/LanguageContext.tsx`)
- Store settings → Language and settings: uses language (evidence: `frontend/src/context/SettingsContext.tsx`)
- Route application → Language and settings: provides language (evidence: `frontend/src/App.tsx`)
- Route application → Store settings: provides settings (evidence: `frontend/src/App.tsx`)
- Route application → Category state: provides categories (evidence: `frontend/src/App.tsx`)
