# helmihamdi/ecommerce-app architecture

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

- Interactive diagram: https://gitdiagram.com/helmihamdi/ecommerce-app
- Repository: https://github.com/helmihamdi/ecommerce-app

## Overview

This is a mobile commerce product backed by an Express/Mongoose API. The principal journey is browsing products and offers, managing a cart, placing an order, and tracking it; the API also supports administration and customer-service features. The graph emphasizes those domain stages and documented API wiring. Mobile-to-API links are omitted because the sampled mobile source does not expose its request wiring; some unsampled route internals are likewise left unconnected.

Main entry points: [`server/server.ts`](https://github.com/helmihamdi/ecommerce-app/blob/main/server/server.ts) (API server), [`server/controllers/orderController.ts`](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/orderController.ts) (Order lifecycle), [`server/middleware/auth.ts`](https://github.com/helmihamdi/ecommerce-app/blob/main/server/middleware/auth.ts) (Identity and roles), [`server/controllers/cartController.ts`](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/cartController.ts) (Cart operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_shop["Shopping screens<br/>[index.tsx]"]
  node_mobile_checkout["Checkout<br/>[checkout.tsx]"]
  node_mobile_orders["Orders and tracking<br/>[index.tsx]"]
  node_mobile_admin["Admin screens<br/>[index.tsx]"]
  node_cart_state["Cart state<br/>[CartContext.tsx]"]
end

subgraph group_api["API runtime"]
  node_server["API server<br/>[server.ts]"]
  node_auth["Identity and roles<br/>[auth.ts]"]
end

subgraph group_commerce["Commerce domain"]
  node_catalog["Product catalog"]
  node_products[("Product records<br/>[Products.ts]")]
  node_cart_api["Cart operations<br/>[cartController.ts]"]
  node_cart_data[("Cart records<br/>[Cart.ts]")]
  node_offers["Offers<br/>[offerController.ts]"]
  node_offer_data[("Offer records<br/>[Offer.ts]")]
  node_orders["Order lifecycle<br/>[orderController.ts]"]
  node_order_data[("Order records<br/>[Order.ts]")]
  node_payments["Payment API<br/>[paymentRoute.ts]"]
  node_invoice["Invoice generation"]
end

subgraph group_engagement["Customer engagement"]
  node_support["Support tickets"]
  node_support_data[("Ticket records<br/>[SupportTicket.ts]")]
  node_chat["Shopping assistant<br/>[chatController.ts]"]
  node_devis["Quote requests<br/>[devisController.ts]"]
  node_notifications["Notifications"]
  node_newsletter["Newsletter"]
end

subgraph group_admin["Operations"]
  node_admin_routes["Admin API<br/>[adminRoute.ts]"]
  node_admin_content["Content management<br/>[bannerRoute.ts]"]
  node_notes["Notes and meetings<br/>[noteRoute.ts]"]
  node_settings["App settings<br/>[settingsRouter.ts]"]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_mobile_shop
node_shopper -->|"checks out"| node_mobile_checkout
node_shopper -->|"tracks orders"| node_mobile_orders
node_server -->|"mounts product API"| node_catalog
node_server -->|"mounts cart API"| node_cart_api
node_server -->|"mounts order API"| node_orders
node_server -->|"mounts payment API"| node_payments
node_server -->|"mounts offers API"| node_offers
node_server -->|"mounts support API"| node_support
node_server -->|"mounts chat API"| node_chat
node_server -->|"mounts quote API"| node_devis
node_server -->|"mounts newsletter API"| node_newsletter
node_server -->|"mounts admin API"| node_admin_routes
node_server -->|"mounts banner API"| node_admin_content
node_server -->|"mounts notes API"| node_notes
node_server -->|"mounts settings API"| node_settings
node_auth -->|"protects routes"| node_support
node_auth -->|"authorizes admins"| node_offers
node_auth -->|"protects routes"| node_devis
node_auth -->|"protects admin listing"| node_newsletter
node_auth -->|"protects settings"| node_settings
node_cart_api -->|"reads and writes"| node_cart_data
node_cart_api -->|"checks products"| node_products
node_cart_api -->|"checks offers"| node_offer_data
node_orders -->|"creates and reads"| node_order_data
node_orders -->|"loads cart"| node_cart_data
node_orders -->|"checks stock"| node_products
node_orders -->|"checks payment"| node_payments
node_orders -->|"generates invoice"| node_invoice
node_offers -->|"reads and writes"| node_offer_data
node_catalog -->|"reads and writes"| node_products
node_support -->|"manages tickets"| node_support_data
node_support -->|"sends alerts"| node_notifications
node_chat -->|"consults catalog"| node_products
node_chat -->|"consults orders"| node_order_data
node_chat -->|"consults offers"| node_offer_data
node_cart_state -->|"supplies cart"| node_mobile_checkout

click node_server "https://github.com/helmihamdi/ecommerce-app/blob/main/server/server.ts"
click node_auth "https://github.com/helmihamdi/ecommerce-app/blob/main/server/middleware/auth.ts"
click node_mobile_shop "https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/(tabs)/index.tsx"
click node_mobile_checkout "https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/checkout.tsx"
click node_mobile_orders "https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/orders/index.tsx"
click node_mobile_admin "https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/admin/(tabs)/index.tsx"
click node_cart_state "https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/context/CartContext.tsx"
click node_catalog "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/productController.ts"
click node_products "https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Products.ts"
click node_cart_api "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/cartController.ts"
click node_cart_data "https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Cart.ts"
click node_offers "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/offerController.ts"
click node_offer_data "https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Offer.ts"
click node_orders "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/orderController.ts"
click node_order_data "https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Order.ts"
click node_payments "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/paymentRoute.ts"
click node_invoice "https://github.com/helmihamdi/ecommerce-app/blob/main/server/utils/generateInvoicePDF.ts"
click node_support "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/supportController.ts"
click node_support_data "https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/SupportTicket.ts"
click node_chat "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/chatController.ts"
click node_devis "https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/devisController.ts"
click node_notifications "https://github.com/helmihamdi/ecommerce-app/blob/main/server/utils/sendNotification.ts"
click node_admin_routes "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/adminRoute.ts"
click node_admin_content "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/bannerRoute.ts"
click node_notes "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/noteRoute.ts"
click node_settings "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/settingsRouter.ts"
click node_newsletter "https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/newsletterRoutes.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_mobile_shop,node_mobile_checkout,node_mobile_orders,node_mobile_admin,node_cart_state toneBlue
class node_server,node_auth toneAmber
class node_catalog,node_products,node_cart_api,node_cart_data,node_offers,node_offer_data,node_orders,node_order_data,node_payments,node_invoice toneMint
class node_support,node_support_data,node_chat,node_devis,node_notifications,node_newsletter toneRose
class node_admin_routes,node_admin_content,node_notes,node_settings,node_shopper toneIndigo
```

## Components

### Mobile app

- [Shopping screens](https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/(tabs)/index.tsx): `mobile/app/(tabs)/index.tsx`
- [Checkout](https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/checkout.tsx): `mobile/app/checkout.tsx`
- [Orders and tracking](https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/orders/index.tsx): `mobile/app/orders/index.tsx`
- [Admin screens](https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/app/admin/(tabs)/index.tsx): `mobile/app/admin/(tabs)/index.tsx`
- [Cart state](https://github.com/helmihamdi/ecommerce-app/blob/main/mobile/context/CartContext.tsx): `mobile/context/CartContext.tsx`

### API runtime

- [API server](https://github.com/helmihamdi/ecommerce-app/blob/main/server/server.ts): `server/server.ts`
- [Identity and roles](https://github.com/helmihamdi/ecommerce-app/blob/main/server/middleware/auth.ts): `server/middleware/auth.ts`

### Commerce domain

- [Product catalog](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/productController.ts): `server/controllers/productController.ts`
- [Product records](https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Products.ts): `server/models/Products.ts`
- [Cart operations](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/cartController.ts): `server/controllers/cartController.ts`
- [Cart records](https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Cart.ts): `server/models/Cart.ts`
- [Offers](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/offerController.ts): `server/controllers/offerController.ts`
- [Offer records](https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Offer.ts): `server/models/Offer.ts`
- [Order lifecycle](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/orderController.ts): `server/controllers/orderController.ts`
- [Order records](https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/Order.ts): `server/models/Order.ts`
- [Payment API](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/paymentRoute.ts): `server/routers/paymentRoute.ts`
- [Invoice generation](https://github.com/helmihamdi/ecommerce-app/blob/main/server/utils/generateInvoicePDF.ts): `server/utils/generateInvoicePDF.ts`

### Customer engagement

- [Support tickets](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/supportController.ts): `server/controllers/supportController.ts`
- [Ticket records](https://github.com/helmihamdi/ecommerce-app/blob/main/server/models/SupportTicket.ts): `server/models/SupportTicket.ts`
- [Shopping assistant](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/chatController.ts): `server/controllers/chatController.ts`
- [Quote requests](https://github.com/helmihamdi/ecommerce-app/blob/main/server/controllers/devisController.ts): `server/controllers/devisController.ts`
- [Notifications](https://github.com/helmihamdi/ecommerce-app/blob/main/server/utils/sendNotification.ts): `server/utils/sendNotification.ts`
- [Newsletter](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/newsletterRoutes.ts): `server/routers/newsletterRoutes.ts`

### Operations

- [Admin API](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/adminRoute.ts): `server/routers/adminRoute.ts`
- [Content management](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/bannerRoute.ts): `server/routers/bannerRoute.ts`
- [Notes and meetings](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/noteRoute.ts): `server/routers/noteRoute.ts`
- [App settings](https://github.com/helmihamdi/ecommerce-app/blob/main/server/routers/settingsRouter.ts): `server/routers/settingsRouter.ts`

### Other components

- **Shopper**

## Connections

- Shopper → Shopping screens: browses
- Shopper → Checkout: checks out
- Shopper → Orders and tracking: tracks orders
- API server → Product catalog: mounts product API (evidence: `server/server.ts`)
- API server → Cart operations: mounts cart API (evidence: `server/server.ts`)
- API server → Order lifecycle: mounts order API (evidence: `server/server.ts`)
- API server → Payment API: mounts payment API (evidence: `server/server.ts`)
- API server → Offers: mounts offers API (evidence: `server/server.ts`)
- API server → Support tickets: mounts support API (evidence: `server/server.ts`)
- API server → Shopping assistant: mounts chat API (evidence: `server/server.ts`)
- API server → Quote requests: mounts quote API (evidence: `server/server.ts`)
- API server → Newsletter: mounts newsletter API (evidence: `server/server.ts`)
- API server → Admin API: mounts admin API (evidence: `server/server.ts`)
- API server → Content management: mounts banner API (evidence: `server/server.ts`)
- API server → Notes and meetings: mounts notes API (evidence: `server/server.ts`)
- API server → App settings: mounts settings API (evidence: `server/server.ts`)
- Identity and roles → Support tickets: protects routes (evidence: `server/routers/supportRoutes.ts`)
- Identity and roles → Offers: authorizes admins (evidence: `server/routers/offerRoutes.ts`)
- Identity and roles → Quote requests: protects routes (evidence: `server/routers/devisRouter.ts`)
- Identity and roles → Newsletter: protects admin listing (evidence: `server/routers/newsletterRoutes.ts`)
- Identity and roles → App settings: protects settings (evidence: `server/routers/settingsRouter.ts`)
- Cart operations → Cart records: reads and writes (evidence: `server/controllers/cartController.ts`)
- Cart operations → Product records: checks products (evidence: `server/controllers/cartController.ts`)
- Cart operations → Offer records: checks offers (evidence: `server/controllers/cartController.ts`)
- Order lifecycle → Order records: creates and reads (evidence: `server/controllers/orderController.ts`)
- Order lifecycle → Cart records: loads cart (evidence: `server/controllers/orderController.ts`)
- Order lifecycle → Product records: checks stock (evidence: `server/controllers/orderController.ts`)
- Order lifecycle → Payment API: checks payment (evidence: `server/controllers/orderController.ts`)
- Order lifecycle → Invoice generation: generates invoice (evidence: `server/controllers/orderController.ts`)
- Offers → Offer records: reads and writes (evidence: `server/controllers/offerController.ts`)
- Product catalog → Product records: reads and writes (evidence: `server/controllers/productController.ts`)
- Support tickets → Ticket records: manages tickets (evidence: `server/controllers/supportController.ts`)
- Support tickets → Notifications: sends alerts (evidence: `server/controllers/supportController.ts`)
- Shopping assistant → Product records: consults catalog (evidence: `server/controllers/chatController.ts`)
- Shopping assistant → Order records: consults orders (evidence: `server/controllers/chatController.ts`)
- Shopping assistant → Offer records: consults offers (evidence: `server/controllers/chatController.ts`)
- Cart state → Checkout: supplies cart
