# mohithalduniya/backend architecture

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

- Interactive diagram: https://gitdiagram.com/mohithalduniya/backend
- Repository: https://github.com/mohithalduniya/backend

## Overview

Nestro is an Express API for a home-furnishings storefront and its administration: clients call category, room, product, user, and order endpoints, which route to controllers and persist domain records in MongoDB. The main customer workflow covers account registration and OTP verification, browsing catalog data, and placing and reviewing orders; administrative endpoints manage catalog records and order status. The graph also includes authentication, image upload, and response helpers. Several controllers and route modules are represented from the source index; their unsampled internals are not inferred.

Main entry points: [`src/index.js`](https://github.com/mohithalduniya/backend/blob/main/src/index.js) (Express API), [`src/controllers/user.controller.js`](https://github.com/mohithalduniya/backend/blob/main/src/controllers/user.controller.js) (Account workflows), [`src/controllers/product.controller.js`](https://github.com/mohithalduniya/backend/blob/main/src/controllers/product.controller.js) (Product management), [`src/controllers/order.controller.js`](https://github.com/mohithalduniya/backend/blob/main/src/controllers/order.controller.js) (Order workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Express API<br/>[index.js]"]
  node_category_routes["Category routes<br/>[category.router.js]"]
  node_room_routes["Room routes<br/>[room.router.js]"]
  node_product_routes["Product routes<br/>[product.router.js]"]
  node_user_routes["User routes<br/>[user.router.js]"]
  node_order_routes["Order routes<br/>[order.router.js]"]
end

subgraph group_identity["Accounts and access"]
  node_auth["Auth middleware<br/>[auth.middleware.js]"]
  node_user_controller["Account workflows<br/>[user.controller.js]"]
  node_user_model[("User records<br/>[user.model.js]")]
  node_auth_helpers["Token and OTP helpers<br/>[helper.js]"]
  node_otp_mail["OTP email sender<br/>[sendOtpMail.js]"]
end

subgraph group_catalog["Store catalog"]
  node_category_controller["Category management"]
  node_category_model[("Category records<br/>[category.model.js]")]
  node_room_controller["Room management<br/>[room.controller.js]"]
  node_room_model[("Room records<br/>[Room.model.js]")]
  node_product_controller["Product management"]
  node_product_model[("Product records<br/>[product.model.js]")]
  node_upload["Image upload<br/>[Middleware.js]"]
end

subgraph group_commerce["Orders and support"]
  node_order_controller["Order workflows"]
  node_order_model[("Order records<br/>[order.model.js]")]
  node_responses["HTTP response helpers<br/>[response.js]"]
end

node_client(("Store client"))
node_cloudinary["Cloudinary<br/>[cloudinary.js]"]

node_client -->|"calls API"| node_server
node_server -->|"mounts routes"| node_category_routes
node_server -->|"mounts routes"| node_room_routes
node_server -->|"mounts routes"| node_product_routes
node_server -->|"mounts routes"| node_user_routes
node_server -->|"mounts routes"| node_order_routes
node_category_routes -->|"dispatches to"| node_category_controller
node_room_routes -->|"dispatches to"| node_room_controller
node_product_routes -->|"dispatches to"| node_product_controller
node_product_routes -->|"uploads images"| node_upload
node_category_routes -->|"uses upload"| node_upload
node_user_routes -->|"dispatches to"| node_user_controller
node_user_routes -->|"checks access"| node_auth
node_order_routes -->|"dispatches to"| node_order_controller
node_order_routes -->|"checks access"| node_auth
node_auth -->|"loads user"| node_user_model
node_user_controller -->|"reads and writes"| node_user_model
node_user_controller -->|"generates OTP and tokens"| node_auth_helpers
node_user_controller -->|"sends OTP email"| node_otp_mail
node_category_controller -->|"manages records"| node_category_model
node_room_controller -->|"manages records"| node_room_model
node_product_controller -->|"manages records"| node_product_model
node_product_controller -->|"filters by category"| node_category_model
node_product_controller -->|"filters by room"| node_room_model
node_upload -->|"stores images"| node_cloudinary
node_order_controller -->|"creates and queries"| node_order_model
node_order_controller -->|"reads and updates user"| node_user_model
node_category_controller -->|"formats responses"| node_responses
node_product_controller -->|"formats responses"| node_responses
node_user_controller -->|"formats responses"| node_responses
node_order_controller -->|"formats responses"| node_responses

click node_server "https://github.com/mohithalduniya/backend/blob/main/src/index.js"
click node_category_routes "https://github.com/mohithalduniya/backend/blob/main/src/routers/category.router.js"
click node_room_routes "https://github.com/mohithalduniya/backend/blob/main/src/routers/room.router.js"
click node_product_routes "https://github.com/mohithalduniya/backend/blob/main/src/routers/product.router.js"
click node_user_routes "https://github.com/mohithalduniya/backend/blob/main/src/routers/user.router.js"
click node_order_routes "https://github.com/mohithalduniya/backend/blob/main/src/routers/order.router.js"
click node_auth "https://github.com/mohithalduniya/backend/blob/main/src/Middleware/auth.middleware.js"
click node_user_controller "https://github.com/mohithalduniya/backend/blob/main/src/controllers/user.controller.js"
click node_user_model "https://github.com/mohithalduniya/backend/blob/main/src/models/user.model.js"
click node_auth_helpers "https://github.com/mohithalduniya/backend/blob/main/src/utils/helper.js"
click node_otp_mail "https://github.com/mohithalduniya/backend/blob/main/src/utils/sendOtpMail.js"
click node_category_controller "https://github.com/mohithalduniya/backend/blob/main/src/controllers/Category.controller.js"
click node_category_model "https://github.com/mohithalduniya/backend/blob/main/src/models/category.model.js"
click node_room_controller "https://github.com/mohithalduniya/backend/blob/main/src/controllers/room.controller.js"
click node_room_model "https://github.com/mohithalduniya/backend/blob/main/src/models/Room.model.js"
click node_product_controller "https://github.com/mohithalduniya/backend/blob/main/src/controllers/product.controller.js"
click node_product_model "https://github.com/mohithalduniya/backend/blob/main/src/models/product.model.js"
click node_upload "https://github.com/mohithalduniya/backend/blob/main/src/Middleware/Middleware.js"
click node_cloudinary "https://github.com/mohithalduniya/backend/blob/main/src/config/cloudinary.js"
click node_order_controller "https://github.com/mohithalduniya/backend/blob/main/src/controllers/order.controller.js"
click node_order_model "https://github.com/mohithalduniya/backend/blob/main/src/models/order.model.js"
click node_responses "https://github.com/mohithalduniya/backend/blob/main/src/utils/response.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_server,node_category_routes,node_room_routes,node_product_routes,node_user_routes,node_order_routes,node_client toneBlue
class node_auth,node_user_controller,node_user_model,node_auth_helpers,node_otp_mail toneAmber
class node_category_controller,node_category_model,node_room_controller,node_room_model,node_product_controller,node_product_model,node_upload toneMint
class node_order_controller,node_order_model,node_responses toneRose
class node_cloudinary toneTeal
```

## Components

### API routing

- [Express API](https://github.com/mohithalduniya/backend/blob/main/src/index.js): `src/index.js`
- [Category routes](https://github.com/mohithalduniya/backend/blob/main/src/routers/category.router.js): `src/routers/category.router.js`
- [Room routes](https://github.com/mohithalduniya/backend/blob/main/src/routers/room.router.js): `src/routers/room.router.js`
- [Product routes](https://github.com/mohithalduniya/backend/blob/main/src/routers/product.router.js): `src/routers/product.router.js`
- [User routes](https://github.com/mohithalduniya/backend/blob/main/src/routers/user.router.js): `src/routers/user.router.js`
- [Order routes](https://github.com/mohithalduniya/backend/blob/main/src/routers/order.router.js): `src/routers/order.router.js`

### Accounts and access

- [Auth middleware](https://github.com/mohithalduniya/backend/blob/main/src/Middleware/auth.middleware.js): `src/Middleware/auth.middleware.js`
- [Account workflows](https://github.com/mohithalduniya/backend/blob/main/src/controllers/user.controller.js): `src/controllers/user.controller.js`
- [User records](https://github.com/mohithalduniya/backend/blob/main/src/models/user.model.js): `src/models/user.model.js`
- [Token and OTP helpers](https://github.com/mohithalduniya/backend/blob/main/src/utils/helper.js): `src/utils/helper.js`
- [OTP email sender](https://github.com/mohithalduniya/backend/blob/main/src/utils/sendOtpMail.js): `src/utils/sendOtpMail.js`

### Store catalog

- [Category management](https://github.com/mohithalduniya/backend/blob/main/src/controllers/Category.controller.js): `src/controllers/Category.controller.js`
- [Category records](https://github.com/mohithalduniya/backend/blob/main/src/models/category.model.js): `src/models/category.model.js`
- [Room management](https://github.com/mohithalduniya/backend/blob/main/src/controllers/room.controller.js): `src/controllers/room.controller.js`
- [Room records](https://github.com/mohithalduniya/backend/blob/main/src/models/Room.model.js): `src/models/Room.model.js`
- [Product management](https://github.com/mohithalduniya/backend/blob/main/src/controllers/product.controller.js): `src/controllers/product.controller.js`
- [Product records](https://github.com/mohithalduniya/backend/blob/main/src/models/product.model.js): `src/models/product.model.js`
- [Image upload](https://github.com/mohithalduniya/backend/blob/main/src/Middleware/Middleware.js): `src/Middleware/Middleware.js`

### Orders and support

- [Order workflows](https://github.com/mohithalduniya/backend/blob/main/src/controllers/order.controller.js): `src/controllers/order.controller.js`
- [Order records](https://github.com/mohithalduniya/backend/blob/main/src/models/order.model.js): `src/models/order.model.js`
- [HTTP response helpers](https://github.com/mohithalduniya/backend/blob/main/src/utils/response.js): `src/utils/response.js`

### Other components

- **Store client**
- [Cloudinary](https://github.com/mohithalduniya/backend/blob/main/src/config/cloudinary.js): `src/config/cloudinary.js`

## Connections

- Store client → Express API: calls API (evidence: `src/index.js`)
- Express API → Category routes: mounts routes (evidence: `src/index.js`)
- Express API → Room routes: mounts routes (evidence: `src/index.js`)
- Express API → Product routes: mounts routes (evidence: `src/index.js`)
- Express API → User routes: mounts routes (evidence: `src/index.js`)
- Express API → Order routes: mounts routes (evidence: `src/index.js`)
- Category routes → Category management: dispatches to (evidence: `src/routers/category.router.js`)
- Room routes → Room management: dispatches to (evidence: `src/routers/room.router.js`)
- Product routes → Product management: dispatches to (evidence: `src/routers/product.router.js`)
- Product routes → Image upload: uploads images (evidence: `src/routers/product.router.js`)
- Category routes → Image upload: uses upload (evidence: `src/routers/category.router.js`)
- User routes → Account workflows: dispatches to (evidence: `src/routers/user.router.js`)
- User routes → Auth middleware: checks access (evidence: `src/routers/user.router.js`)
- Order routes → Order workflows: dispatches to (evidence: `src/routers/order.router.js`)
- Order routes → Auth middleware: checks access (evidence: `src/routers/order.router.js`)
- Auth middleware → User records: loads user (evidence: `src/Middleware/auth.middleware.js`)
- Account workflows → User records: reads and writes (evidence: `src/controllers/user.controller.js`)
- Account workflows → Token and OTP helpers: generates OTP and tokens (evidence: `src/controllers/user.controller.js`)
- Account workflows → OTP email sender: sends OTP email (evidence: `src/controllers/user.controller.js`)
- Category management → Category records: manages records (evidence: `src/controllers/Category.controller.js`)
- Room management → Room records: manages records (evidence: `src/controllers/room.controller.js`)
- Product management → Product records: manages records (evidence: `src/controllers/product.controller.js`)
- Product management → Category records: filters by category (evidence: `src/controllers/product.controller.js`)
- Product management → Room records: filters by room (evidence: `src/controllers/product.controller.js`)
- Image upload → Cloudinary: stores images (evidence: `src/Middleware/Middleware.js`)
- Order workflows → Order records: creates and queries (evidence: `src/controllers/order.controller.js`)
- Order workflows → User records: reads and updates user (evidence: `src/controllers/order.controller.js`)
- Category management → HTTP response helpers: formats responses (evidence: `src/controllers/Category.controller.js`)
- Product management → HTTP response helpers: formats responses (evidence: `src/controllers/product.controller.js`)
- Account workflows → HTTP response helpers: formats responses (evidence: `src/controllers/user.controller.js`)
- Order workflows → HTTP response helpers: formats responses (evidence: `src/controllers/order.controller.js`)
