# 3mr3yyad/e-commerce-be architecture

> Architecture diagram of the GitHub repository 3mr3yyad/e-commerce-be, 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/3mr3yyad/e-commerce-be
- Repository: https://github.com/3mr3yyad/e-commerce-be

## Overview

This is a NestJS e-commerce backend: clients use authentication and catalog, cart, and order endpoints, with services coordinating business rules and MongoDB-backed repositories. The sampled code confirms product creation validates its category and brand, and order/cart services reference one another. The README is only a NestJS starter description, so the feature map comes from the source tree and sampled imports; unsampled feature internals and several runtime links are not asserted.

Main entry points: [`src/app.module.ts`](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/app.module.ts) (Application modules), [`src/modules/product/product.service.ts`](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/product/product.service.ts) (Product management), [`src/modules/auth/auth.service.ts`](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.service.ts) (Auth workflows), [`src/modules/cart/cart.service.ts`](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/cart/cart.service.ts) (Cart management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_bootstrap["Nest bootstrap<br/>[main.ts]"]
  node_app["Application modules<br/>[app.module.ts]"]
  node_http["HTTP cross-cutting"]
end

subgraph group_identity["Identity and access"]
  node_auth_api["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_logic["Auth workflows<br/>[auth.service.ts]"]
  node_identity_store[("User and customer data")]
  node_mail["Email delivery"]
  node_jwt_google["JWT and Google login<br/>[auth.service.ts]"]
  node_customers["Customer management"]
end

subgraph group_catalog["Product catalog"]
  node_product["Product management<br/>[product.service.ts]"]
  node_category["Category management"]
  node_brand["Brand management<br/>[brand.service.ts]"]
end

subgraph group_commerce["Shopping and orders"]
  node_cart["Cart management<br/>[cart.service.ts]"]
  node_orders["Order management<br/>[order.service.ts]"]
  node_coupons["Coupon management"]
end

subgraph group_persistence["Persistence"]
  node_catalog_store[("Catalog models")]
  node_commerce_store[("Commerce models")]
end

node_client(("API client"))

node_client -.->|"sends requests"| node_bootstrap
node_bootstrap -->|"creates"| node_app
node_app -->|"registers"| node_auth_api
node_app -->|"registers"| node_product
node_app -->|"registers"| node_category
node_app -->|"registers"| node_brand
node_app -->|"registers"| node_cart
node_app -->|"registers"| node_orders
node_app -->|"registers"| node_coupons
node_app -->|"registers"| node_customers
node_app -->|"configures MongoDB"| node_commerce_store
node_auth_api -->|"calls"| node_auth_logic
node_auth_logic -->|"reads and writes"| node_identity_store
node_auth_logic -->|"sends verification mail"| node_mail
node_auth_logic -->|"uses token services"| node_jwt_google
node_product -->|"reads and writes"| node_catalog_store
node_product -->|"validates category"| node_category
node_product -->|"validates brand"| node_brand
node_category -.->|"uses repositories"| node_catalog_store
node_brand -.->|"uses repositories"| node_catalog_store
node_cart -->|"reads and writes"| node_commerce_store
node_cart -->|"calls"| node_product
node_orders -.->|"reads and writes"| node_commerce_store
node_orders -->|"calls"| node_cart

click node_bootstrap "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/main.ts"
click node_app "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/app.module.ts"
click node_http "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/common"
click node_auth_api "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.controller.ts"
click node_auth_logic "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.service.ts"
click node_identity_store "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models"
click node_mail "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/common/helpers/send-mail.helper.ts"
click node_jwt_google "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.service.ts"
click node_product "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/product/product.service.ts"
click node_category "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/category/category.service.ts"
click node_brand "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/brand/brand.service.ts"
click node_catalog_store "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models"
click node_cart "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/cart/cart.service.ts"
click node_orders "https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/order/order.service.ts"
click node_commerce_store "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models"
click node_coupons "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/modules/coupon"
click node_customers "https://github.com/3mr3yyad/e-commerce-be/tree/main/src/modules/customer"

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_bootstrap,node_app,node_http,node_client toneBlue
class node_auth_api,node_auth_logic,node_identity_store,node_mail,node_jwt_google,node_customers toneAmber
class node_product,node_category,node_brand toneMint
class node_cart,node_orders,node_coupons toneRose
class node_catalog_store,node_commerce_store toneIndigo
```

## Components

### Application runtime

- [Nest bootstrap](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/main.ts): `src/main.ts`
- [Application modules](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/app.module.ts): `src/app.module.ts`
- [HTTP cross-cutting](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/common): `src/common`

### Identity and access

- [Auth endpoints](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.controller.ts): `src/modules/auth/auth.controller.ts`
- [Auth workflows](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`
- [User and customer data](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models): `src/models`
- [Email delivery](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/common/helpers/send-mail.helper.ts): `src/common/helpers/send-mail.helper.ts`
- [JWT and Google login](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/auth/auth.service.ts): `src/modules/auth/auth.service.ts`
- [Customer management](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/modules/customer): `src/modules/customer`

### Product catalog

- [Product management](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/product/product.service.ts): `src/modules/product/product.service.ts`
- [Category management](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/category/category.service.ts): `src/modules/category/category.service.ts`
- [Brand management](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/brand/brand.service.ts): `src/modules/brand/brand.service.ts`

### Shopping and orders

- [Cart management](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/cart/cart.service.ts): `src/modules/cart/cart.service.ts`
- [Order management](https://github.com/3mr3yyad/e-commerce-be/blob/main/src/modules/order/order.service.ts): `src/modules/order/order.service.ts`
- [Coupon management](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/modules/coupon): `src/modules/coupon`

### Persistence

- [Catalog models](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models): `src/models`
- [Commerce models](https://github.com/3mr3yyad/e-commerce-be/tree/main/src/models): `src/models`

### Other components

- **API client**

## Connections

- API client → Nest bootstrap: sends requests
- Nest bootstrap → Application modules: creates (evidence: `src/main.ts`)
- Application modules → Auth endpoints: registers (evidence: `src/app.module.ts`)
- Application modules → Product management: registers (evidence: `src/app.module.ts`)
- Application modules → Category management: registers (evidence: `src/app.module.ts`)
- Application modules → Brand management: registers (evidence: `src/app.module.ts`)
- Application modules → Cart management: registers (evidence: `src/app.module.ts`)
- Application modules → Order management: registers (evidence: `src/app.module.ts`)
- Application modules → Coupon management: registers (evidence: `src/app.module.ts`)
- Application modules → Customer management: registers (evidence: `src/app.module.ts`)
- Application modules → Commerce models: configures MongoDB (evidence: `src/app.module.ts`)
- Auth endpoints → Auth workflows: calls (evidence: `src/modules/auth/auth.controller.ts`)
- Auth workflows → User and customer data: reads and writes (evidence: `src/modules/auth/auth.service.ts`)
- Auth workflows → Email delivery: sends verification mail (evidence: `src/modules/auth/auth.service.ts`)
- Auth workflows → JWT and Google login: uses token services (evidence: `src/modules/auth/auth.service.ts`)
- Product management → Catalog models: reads and writes (evidence: `src/modules/product/product.service.ts`)
- Product management → Category management: validates category (evidence: `src/modules/product/product.service.ts`)
- Product management → Brand management: validates brand (evidence: `src/modules/product/product.service.ts`)
- Category management → Catalog models: uses repositories (evidence: `src/modules/category/category.service.ts`)
- Brand management → Catalog models: uses repositories
- Cart management → Commerce models: reads and writes (evidence: `src/modules/cart/cart.service.ts`)
- Cart management → Product management: calls (evidence: `src/modules/cart/cart.service.ts`)
- Order management → Commerce models: reads and writes (evidence: `src/modules/order/order.service.ts`)
- Order management → Cart management: calls (evidence: `src/modules/order/order.service.ts`)
