# mahmoud-eng1/nova-shop architecture

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

- Interactive diagram: https://gitdiagram.com/mahmoud-eng1/nova-shop
- Repository: https://github.com/mahmoud-eng1/nova-shop

## Overview

This is a Node.js/Express e-commerce REST API backed by MongoDB. Its main user workflow is authenticated product discovery, cart and order handling, then payment; administrators also manage catalog data, while customers can review products. The graph preserves the documented authentication, catalog, cart, order, payment, and security capabilities, plus the sampled review and product-query internals. Several route/controller links are supported by the SOURCE INDEX rather than excerpts; unsampled behavior and wiring are not inferred beyond those references.

Main entry points: [`index.js`](https://github.com/mahmoud-eng1/nova-shop/blob/main/index.js) (Express app), [`routes/productRouter.js`](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/productRouter.js) (Product routes), [`routes/reviewRouter.js`](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/reviewRouter.js) (Review routes), [`models/productSchema.js`](https://github.com/mahmoud-eng1/nova-shop/blob/main/models/productSchema.js) (Product records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_app["Express app<br/>[index.js]"]
  node_auth_routes["Authentication routes"]
  node_auth_controller["Authentication"]
  node_token["JWT verification<br/>[verifyToken.js]"]
  node_roles["Role authorization<br/>[allowedTo.js]"]
  node_validation["Request validation<br/>[joiMiddleware.js]"]
  node_users_routes["User routes<br/>[usersRoute.js]"]
  node_users["User management<br/>[usersControllar.js]"]
end

subgraph group_catalog["Catalog and reviews"]
  node_products_routes["Product routes<br/>[productRouter.js]"]
  node_products["Product management"]
  node_categories_routes["Category routes<br/>[categoryRouter.js]"]
  node_categories["Category management"]
  node_subcat_routes["Subcategory routes"]
  node_subcategories["Subcategory management"]
  node_brands_routes["Brand routes<br/>[BrandsRouter.js]"]
  node_brands["Brand management"]
  node_reviews_routes["Review routes<br/>[reviewRouter.js]"]
  node_reviews["Review management"]
  node_api_features["Product query features<br/>[apiFeature.js]"]
end

subgraph group_commerce["Commerce"]
  node_cart_routes["Cart routes<br/>[cartRouter.js]"]
  node_cart_controller["Cart management<br/>[cartController.js]"]
  node_order_routes["Order routes<br/>[orderRouter.js]"]
  node_orders["Order management<br/>[orderController.js]"]
  node_stripe["Stripe payments"]
  node_coupons["Coupon management"]
  node_coupon_routes["Coupon routes<br/>[couponRouter.js]"]
  node_addresses_routes["Address routes<br/>[addressesRouter.js]"]
  node_addresses["Address management"]
  node_wishlist_routes["Wishlist routes<br/>[wishlistRouter.js]"]
end

subgraph group_data["Persistence and utilities"]
  node_product_model[("Product records<br/>[productSchema.js]")]
  node_review_model[("Review records<br/>[reviewSchema.js]")]
  node_cart_model[("Cart records<br/>[cartSchema.js]")]
  node_order_model[("Order records<br/>[orderSchema.js]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_auth_routes
node_app -->|"mounts routes"| node_products_routes
node_app -->|"mounts routes"| node_categories_routes
node_app -->|"mounts routes"| node_subcat_routes
node_app -->|"mounts routes"| node_brands_routes
node_app -->|"mounts routes"| node_reviews_routes
node_app -->|"mounts routes"| node_cart_routes
node_app -->|"mounts routes"| node_order_routes
node_app -->|"mounts routes"| node_coupon_routes
node_app -->|"mounts routes"| node_users_routes
node_app -->|"mounts routes"| node_addresses_routes
node_app -->|"mounts routes"| node_wishlist_routes
node_auth_routes -->|"dispatches to"| node_auth_controller
node_products_routes -->|"dispatches to"| node_products
node_products_routes -->|"nests routes"| node_reviews_routes
node_products_routes -->|"checks token"| node_token
node_products_routes -->|"checks role"| node_roles
node_products_routes -->|"validates input"| node_validation
node_reviews_routes -->|"dispatches to"| node_reviews
node_reviews_routes -->|"checks token"| node_token
node_reviews_routes -->|"checks role"| node_roles
node_reviews_routes -->|"validates input"| node_validation
node_products -->|"reads and writes"| node_product_model
node_products -->|"builds queries"| node_api_features
node_reviews -->|"reads and writes"| node_review_model
node_reviews -->|"updates ratings"| node_product_model
node_reviews -->|"checks reviewer"| node_users
node_categories_routes -->|"dispatches to"| node_categories
node_subcat_routes -->|"dispatches to"| node_subcategories
node_brands_routes -->|"dispatches to"| node_brands
node_cart_routes -->|"dispatches to"| node_cart_controller
node_cart_controller -->|"reads and writes"| node_cart_model
node_order_routes -->|"dispatches to"| node_orders
node_orders -->|"reads cart"| node_cart_model
node_orders -->|"reads and writes"| node_order_model
node_orders -->|"updates stock"| node_product_model
node_orders -->|"creates session"| node_stripe
node_coupon_routes -->|"dispatches to"| node_coupons
node_users_routes -->|"dispatches to"| node_users
node_addresses_routes -->|"dispatches to"| node_addresses
node_auth_controller -.->|"manages accounts"| node_users
node_categories -.->|"links catalog"| node_product_model
node_subcategories -.->|"links catalog"| node_product_model
node_brands -.->|"links catalog"| node_product_model

click node_app "https://github.com/mahmoud-eng1/nova-shop/blob/main/index.js"
click node_auth_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/authentcationRoute.js"
click node_auth_controller "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/authentCationUsers.js"
click node_token "https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/verifyToken.js"
click node_roles "https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/allowedTo.js"
click node_validation "https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/joiMiddleware.js"
click node_products_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/productRouter.js"
click node_products "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/productController.js"
click node_product_model "https://github.com/mahmoud-eng1/nova-shop/blob/main/models/productSchema.js"
click node_categories_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/categoryRouter.js"
click node_categories "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/categoriesController.js"
click node_subcat_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/subCategoryRouter.js"
click node_subcategories "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/subCategortController.js"
click node_brands_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/BrandsRouter.js"
click node_brands "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/brandesController.js"
click node_reviews_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/reviewRouter.js"
click node_reviews "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/reviewsController.js"
click node_review_model "https://github.com/mahmoud-eng1/nova-shop/blob/main/models/reviewSchema.js"
click node_api_features "https://github.com/mahmoud-eng1/nova-shop/blob/main/utils/apiFeature.js"
click node_cart_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/cartRouter.js"
click node_cart_controller "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/cartController.js"
click node_cart_model "https://github.com/mahmoud-eng1/nova-shop/blob/main/models/cartSchema.js"
click node_order_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/orderRouter.js"
click node_orders "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/orderController.js"
click node_order_model "https://github.com/mahmoud-eng1/nova-shop/blob/main/models/orderSchema.js"
click node_coupons "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/couponController.js"
click node_coupon_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/couponRouter.js"
click node_users_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/usersRoute.js"
click node_users "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/usersControllar.js"
click node_addresses_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/addressesRouter.js"
click node_addresses "https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/addressesController.js"
click node_wishlist_routes "https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/wishlistRouter.js"

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_auth_routes,node_auth_controller,node_token,node_roles,node_validation,node_users_routes,node_users,node_client toneBlue
class node_products_routes,node_products,node_categories_routes,node_categories,node_subcat_routes,node_subcategories,node_brands_routes,node_brands,node_reviews_routes,node_reviews,node_api_features toneAmber
class node_cart_routes,node_cart_controller,node_order_routes,node_orders,node_stripe,node_coupons,node_coupon_routes,node_addresses_routes,node_addresses,node_wishlist_routes toneMint
class node_product_model,node_review_model,node_cart_model,node_order_model toneRose
```

## Components

### API and access

- [Express app](https://github.com/mahmoud-eng1/nova-shop/blob/main/index.js): `index.js`
- [Authentication routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/authentcationRoute.js): `routes/authentcationRoute.js`
- [Authentication](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/authentCationUsers.js): `controllars/authentCationUsers.js`
- [JWT verification](https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/verifyToken.js): `middlewares/verifyToken.js`
- [Role authorization](https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/allowedTo.js): `middlewares/allowedTo.js`
- [Request validation](https://github.com/mahmoud-eng1/nova-shop/blob/main/middlewares/joiMiddleware.js): `middlewares/joiMiddleware.js`
- [User routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/usersRoute.js): `routes/usersRoute.js`
- [User management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/usersControllar.js): `controllars/usersControllar.js`

### Catalog and reviews

- [Product routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/productRouter.js): `routes/productRouter.js`
- [Product management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/productController.js): `controllars/productController.js`
- [Category routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/categoryRouter.js): `routes/categoryRouter.js`
- [Category management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/categoriesController.js): `controllars/categoriesController.js`
- [Subcategory routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/subCategoryRouter.js): `routes/subCategoryRouter.js`
- [Subcategory management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/subCategortController.js): `controllars/subCategortController.js`
- [Brand routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/BrandsRouter.js): `routes/BrandsRouter.js`
- [Brand management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/brandesController.js): `controllars/brandesController.js`
- [Review routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/reviewRouter.js): `routes/reviewRouter.js`
- [Review management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/reviewsController.js): `controllars/reviewsController.js`
- [Product query features](https://github.com/mahmoud-eng1/nova-shop/blob/main/utils/apiFeature.js): `utils/apiFeature.js`

### Commerce

- [Cart routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/cartRouter.js): `routes/cartRouter.js`
- [Cart management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/cartController.js): `controllars/cartController.js`
- [Order routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/orderRouter.js): `routes/orderRouter.js`
- [Order management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/orderController.js): `controllars/orderController.js`
- **Stripe payments**
- [Coupon management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/couponController.js): `controllars/couponController.js`
- [Coupon routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/couponRouter.js): `routes/couponRouter.js`
- [Address routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/addressesRouter.js): `routes/addressesRouter.js`
- [Address management](https://github.com/mahmoud-eng1/nova-shop/blob/main/controllars/addressesController.js): `controllars/addressesController.js`
- [Wishlist routes](https://github.com/mahmoud-eng1/nova-shop/blob/main/routes/wishlistRouter.js): `routes/wishlistRouter.js`

### Persistence and utilities

- [Product records](https://github.com/mahmoud-eng1/nova-shop/blob/main/models/productSchema.js): `models/productSchema.js`
- [Review records](https://github.com/mahmoud-eng1/nova-shop/blob/main/models/reviewSchema.js): `models/reviewSchema.js`
- [Cart records](https://github.com/mahmoud-eng1/nova-shop/blob/main/models/cartSchema.js): `models/cartSchema.js`
- [Order records](https://github.com/mahmoud-eng1/nova-shop/blob/main/models/orderSchema.js): `models/orderSchema.js`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests (evidence: `index.js`)
- Express app → Authentication routes: mounts routes (evidence: `index.js`)
- Express app → Product routes: mounts routes (evidence: `index.js`)
- Express app → Category routes: mounts routes (evidence: `index.js`)
- Express app → Subcategory routes: mounts routes (evidence: `index.js`)
- Express app → Brand routes: mounts routes (evidence: `index.js`)
- Express app → Review routes: mounts routes (evidence: `index.js`)
- Express app → Cart routes: mounts routes (evidence: `index.js`)
- Express app → Order routes: mounts routes (evidence: `index.js`)
- Express app → Coupon routes: mounts routes (evidence: `index.js`)
- Express app → User routes: mounts routes (evidence: `index.js`)
- Express app → Address routes: mounts routes (evidence: `index.js`)
- Express app → Wishlist routes: mounts routes (evidence: `index.js`)
- Authentication routes → Authentication: dispatches to
- Product routes → Product management: dispatches to (evidence: `routes/productRouter.js`)
- Product routes → Review routes: nests routes (evidence: `routes/productRouter.js`)
- Product routes → JWT verification: checks token (evidence: `routes/productRouter.js`)
- Product routes → Role authorization: checks role (evidence: `routes/productRouter.js`)
- Product routes → Request validation: validates input (evidence: `routes/productRouter.js`)
- Review routes → Review management: dispatches to (evidence: `routes/reviewRouter.js`)
- Review routes → JWT verification: checks token (evidence: `routes/reviewRouter.js`)
- Review routes → Role authorization: checks role (evidence: `routes/reviewRouter.js`)
- Review routes → Request validation: validates input (evidence: `routes/reviewRouter.js`)
- Product management → Product records: reads and writes (evidence: `controllars/productController.js`)
- Product management → Product query features: builds queries (evidence: `controllars/productController.js`)
- Review management → Review records: reads and writes (evidence: `controllars/reviewsController.js`)
- Review management → Product records: updates ratings (evidence: `controllars/reviewsController.js`)
- Review management → User management: checks reviewer (evidence: `controllars/reviewsController.js`)
- Category routes → Category management: dispatches to (evidence: `routes/categoryRouter.js`)
- Subcategory routes → Subcategory management: dispatches to (evidence: `routes/subCategoryRouter.js`)
- Brand routes → Brand management: dispatches to (evidence: `routes/BrandsRouter.js`)
- Cart routes → Cart management: dispatches to (evidence: `routes/cartRouter.js`)
- Cart management → Cart records: reads and writes (evidence: `controllars/cartController.js`)
- Order routes → Order management: dispatches to (evidence: `routes/orderRouter.js`)
- Order management → Cart records: reads cart (evidence: `controllars/orderController.js`)
- Order management → Order records: reads and writes (evidence: `controllars/orderController.js`)
- Order management → Product records: updates stock (evidence: `controllars/orderController.js`)
- Order management → Stripe payments: creates session (evidence: `controllars/orderController.js`)
- Coupon routes → Coupon management: dispatches to (evidence: `routes/couponRouter.js`)
- User routes → User management: dispatches to
- Address routes → Address management: dispatches to
- Authentication → User management: manages accounts
- Category management → Product records: links catalog
- Subcategory management → Product records: links catalog
- Brand management → Product records: links catalog
