# anshul-sharma01/u-laundry architecture

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

- Interactive diagram: https://gitdiagram.com/anshul-sharma01/u-laundry
- Repository: https://github.com/anshul-sharma01/u-laundry

## Overview

1. **Overall shape**
   - This is a two-tier monorepo: a **Vite + React + TypeScript client** in `client/` and a **Node.js + Express API server** in `server/`.
   - The client is a browser SPA; the server owns persistence, business rules, payments, file handling, email, and real-time coordination.

2. **Client application boundary**
   - The frontend is organized around **pages**, **shared components**, **layouts**, and **Redux state slices**.
   - `main.tsx` bootstraps the app, `App.tsx` wires routing, and the layout layer (`Navbar`, `Footer`, `NavigationLayout`) provides the common shell.
   - `AuthHydrator` suggests the app restores authentication state on load before route decisions are made.

3. **Role-based navigation and access control**
   - The client has explicit route guards for different personas: `ProtectedRoute`, `AdminRoute`, and `ModeratorRoute`.
   - This indicates three main access domains: **general user**, **admin**, and **moderator**, each with separate page sets and UI controls.

4. **Frontend feature areas**
   - User-facing pages: `HomePage`, `ContactPage`, `OrdersPage`, `ProfilePage`, plus auth pages like login, signup, forgot/reset password, and verification pending.
   - Admin pages: dashboards for users, orders, pricing rules, and pending verifications.
   - Moderator pages: laundry-item management and moderator order handling, backed by modal components for add/manage workflows.

5. **Client state and API integration**
   - Redux slices in `store/slices` separate concerns for `auth`, `admin`, and `moderator`.
   - `helpers/axiosInstance.ts` is the main HTTP boundary from UI to API.
   - `helpers/socketService.ts` indicates a real-time channel alongside REST, likely used for order/status updates or live admin/moderator interactions.

6. **Server application boundary**
   - The backend is a classic layered Express app: `server.js` starts the process, `app.js` composes middleware and routes, and `config/dbConnection.js` connects to MongoDB.
   - The server is split into `routes`, `controllers`, `models`, `middlewares`, and `utils`, with each controller owning a business capability.

7. **Core backend domains**
   - **Users/auth**: `user.controller.js`, `user.routes.js`, `auth.middleware.js`, and `otp.model.js` support login, registration, verification, and password reset flows.
   - **Orders**: `order.controller.js` and `order.model.js` handle the central laundry order lifecycle.
   - **Pricing**: `pricing.controller.js`, `pricingRule.model.js`, and `pricingEngine.js` encapsulate pricing logic.
   - **Laundry catalog**: `laundryItem.controller.js` and `laundryItem.model.js` manage the items that moderators/admins can configure.

8. **Order lifecycle and operational data**
   - The order flow appears to combine user input, pricing calculation, slot availability, and fulfillment tracking.
   - `pickupSlotInventory.model.js` suggests pickup scheduling is capacity-aware.
   - `OrderTimeline` on the client and order-related controllers on the server imply status progression is a first-class concept.

9. **Payments and financial side**
   - `razorpayService.js` and `razorpayWebhook.controller.js` show that payment handling is integrated through **Razorpay**.
   - The webhook controller implies asynchronous payment confirmation from the payment provider back into the server before order/payment state is finalized.

10. **Files, media, and storage**
   - `multer.middleware.js` plus `public/temp/` indicate temporary server-side upload handling.
   - `cloudinary.js` suggests uploaded assets are pushed to **Cloudinary**, with the server acting as the staging and validation layer.

11. **Notifications and documents**
   - `sendEmail.js` is the outbound notification channel currently visible in the tree.
   - `invoiceGenerator.js` implies orders can produce downloadable or stored invoice artifacts after payment or completion.

12. **Real-time and conversational features**
   - The presence of `socketManager.js`, `socketService.ts`, and a `chatbot` controller/routes pair shows the app is not purely request/response.
   - Real-time events likely support live order updates, status broadcasts, or interactive assistant/chat flows.

13. **Operational/admin concerns**
   - `adminSlice.ts` and the admin page set show the backend exposes operational controls for moderation, user management, order oversight, and pricing rule maintenance.
   - `seedPricingRules.js` indicates the system can initialize or repair pricing configuration data.

14. **Key architectural boundaries for a diagram**
   - **Browser UI boundary**: pages/components/layouts and role guards.
   - **Client state/API boundary**: Redux + axios/socket services.
   - **Server business boundary**: controllers acting on MongoDB models and utility services.
   - **External service boundary**: MongoDB, Razorpay, Cloudinary, email delivery, and socket-based real-time updates.

Main entry points: [`server/src/app.js`](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/app.js) (Express app), [`client/src/App.tsx`](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/App.tsx) (App), [`server/src/utils/pricingEngine.js`](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/utils/pricingEngine.js) (Server utils), [`server/src/models/user.model.js`](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/models/user.model.js) (Mongo models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_main["main.tsx<br/>bootstrap<br/>[main.tsx]"]
  node_client_app["App<br/>router shell<br/>[App.tsx]"]
  node_client_layout["Shell layout"]
  node_client_auth_hydrator["Auth hydrator<br/>auth restore<br/>[AuthHydrator.tsx]"]
  node_client_route_guards["Route guards<br/>access control<br/>[ProtectedRoute.tsx]"]
  node_client_home["User pages<br/>[HomePage.tsx]"]
  node_client_auth_pages["Auth pages<br/>[LoginPage.tsx]"]
  node_client_admin_pages["Admin pages"]
  node_client_moderator_pages["Moderator pages"]
  node_client_order_timeline(("Order timeline<br/>status ui<br/>[OrderTimeline.tsx]"))
  node_client_chatbot(("Chatbot<br/>assistant ui<br/>[Chatbot.tsx]"))
  node_client_axios["API client<br/>http client<br/>[axiosInstance.ts]"]
  node_client_socket["Socket service<br/>realtime client<br/>[socketService.ts]"]
  node_client_store["Redux store<br/>state<br/>[store.ts]"]
  node_client_slices["State slices<br/>[authSlice.ts]"]
end

subgraph group_server["Server"]
  node_server_entry["server.js<br/>bootstrap<br/>[server.js]"]
  node_server_app["Express app<br/>api shell<br/>[app.js]"]
  node_server_db[("DB connection<br/>database<br/>[dbConnection.js]")]
  node_server_users["User API<br/>auth domain<br/>[user.controller.js]"]
  node_server_orders["Order API<br/>orders domain"]
  node_server_pricing["Pricing API<br/>pricing domain"]
  node_server_catalog["Laundry API<br/>catalog domain"]
  node_server_chatbot["Chatbot API<br/>assistant domain"]
  node_server_webhook["Razorpay webhook<br/>payments"]
  node_server_auth_mw["Auth middleware<br/>security<br/>[auth.middleware.js]"]
  node_server_upload_mw["Upload middleware<br/>files"]
  node_server_models[("Mongo models<br/>persistence<br/>[user.model.js]")]
  node_server_utils["Server utils<br/>services<br/>[pricingEngine.js]"]
end

subgraph group_external["External"]
  node_external_mongo[("MongoDB<br/>database")]
  node_external_razorpay["Razorpay<br/>payments provider"]
  node_external_cloudinary["Cloudinary<br/>media storage"]
  node_external_email["Email delivery<br/>notification service"]
end

node_client_main -->|"mounts"| node_client_app
node_client_app -->|"wraps"| node_client_layout
node_client_app -->|"hydrates"| node_client_auth_hydrator
node_client_app -->|"guards"| node_client_route_guards
node_client_app -->|"renders"| node_client_home
node_client_app -->|"renders"| node_client_auth_pages
node_client_app -->|"renders"| node_client_admin_pages
node_client_app -->|"renders"| node_client_moderator_pages
node_client_home -->|"shows"| node_client_order_timeline
node_client_home -->|"offers"| node_client_chatbot
node_client_slices -->|"compose"| node_client_store
node_client_store -->|"fetches"| node_client_axios
node_client_store -->|"subscribes"| node_client_socket
node_client_axios -->|"calls"| node_server_app
node_client_socket -->|"connects"| node_server_app
node_server_entry -->|"starts"| node_server_app
node_server_app -->|"connects"| node_server_db
node_server_app -->|"uses"| node_server_auth_mw
node_server_app -->|"uses"| node_server_upload_mw
node_server_app -->|"routes to"| node_server_users
node_server_app -->|"routes to"| node_server_orders
node_server_app -->|"routes to"| node_server_pricing
node_server_app -->|"routes to"| node_server_catalog
node_server_app -->|"routes to"| node_server_chatbot
node_server_webhook -->|"receives"| node_external_razorpay
node_server_users -->|"reads/writes"| node_server_models
node_server_orders -->|"reads/writes"| node_server_models
node_server_pricing -->|"reads/writes"| node_server_models
node_server_catalog -->|"reads/writes"| node_server_models
node_server_users -->|"uses"| node_server_utils
node_server_orders -->|"uses"| node_server_utils
node_server_catalog -->|"uses"| node_server_utils
node_server_utils -->|"uploads"| node_external_cloudinary
node_server_utils -->|"sends"| node_external_email
node_server_utils -->|"charges"| node_external_razorpay
node_server_models -->|"persists"| node_external_mongo

click node_client_main "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/main.tsx"
click node_client_app "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/App.tsx"
click node_client_layout "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/layouts/NavigationLayout.tsx"
click node_client_auth_hydrator "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/AuthHydrator.tsx"
click node_client_route_guards "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/ProtectedRoute.tsx"
click node_client_home "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/HomePage.tsx"
click node_client_auth_pages "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/auth/LoginPage.tsx"
click node_client_admin_pages "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/admin/AdminDashboardPage.tsx"
click node_client_moderator_pages "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/moderator/LaundryModeratorPage.tsx"
click node_client_order_timeline "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/OrderTimeline.tsx"
click node_client_chatbot "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/Chatbot.tsx"
click node_client_axios "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/helpers/axiosInstance.ts"
click node_client_socket "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/helpers/socketService.ts"
click node_client_store "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/store/store.ts"
click node_client_slices "https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/store/slices/authSlice.ts"
click node_server_entry "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/server.js"
click node_server_app "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/app.js"
click node_server_db "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/config/dbConnection.js"
click node_server_users "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/user.controller.js"
click node_server_orders "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/order.controller.js"
click node_server_pricing "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/pricing.controller.js"
click node_server_catalog "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/laundryItem.controller.js"
click node_server_chatbot "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/chatbot.controller.js"
click node_server_webhook "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/razorpayWebhook.controller.js"
click node_server_auth_mw "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/middlewares/auth.middleware.js"
click node_server_upload_mw "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/middlewares/multer.middleware.js"
click node_server_models "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/models/user.model.js"
click node_server_utils "https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/utils/pricingEngine.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_client_main,node_client_app,node_client_layout,node_client_auth_hydrator,node_client_route_guards,node_client_home,node_client_auth_pages,node_client_admin_pages,node_client_moderator_pages,node_client_order_timeline,node_client_chatbot,node_client_axios,node_client_socket,node_client_store,node_client_slices toneBlue
class node_server_entry,node_server_app,node_server_db,node_server_users,node_server_orders,node_server_pricing,node_server_catalog,node_server_chatbot,node_server_webhook,node_server_auth_mw,node_server_upload_mw,node_server_models,node_server_utils toneAmber
class node_external_mongo,node_external_razorpay,node_external_cloudinary,node_external_email toneMint
```

## Components

### Client

Vite React SPA with routed pages, role guards, state, and API integration

- [main.tsx](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/main.tsx): bootstrap · Client entrypoint that mounts the React app · `client/src/main.tsx`
- [App](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/App.tsx): router shell · Top-level routing and application composition · `client/src/App.tsx`
- [Shell layout](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/layouts/NavigationLayout.tsx): layout · Common navigation frame with header and footer · `client/src/layouts/NavigationLayout.tsx`
- [Auth hydrator](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/AuthHydrator.tsx): auth restore · Restores authentication state before route decisions · `client/src/components/AuthHydrator.tsx`
- [Route guards](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/ProtectedRoute.tsx): access control · Protected, admin, and moderator route boundaries · `client/src/components/ProtectedRoute.tsx`
- [User pages](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/HomePage.tsx): pages · Public and signed-in user-facing pages · `client/src/pages/HomePage.tsx`
- [Auth pages](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/auth/LoginPage.tsx): pages · Login, signup, recovery, and verification flows · `client/src/pages/auth/LoginPage.tsx`
- [Admin pages](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/admin/AdminDashboardPage.tsx): pages · Operational dashboards for users, orders, pricing, and verifications · `client/src/pages/admin/AdminDashboardPage.tsx`
- [Moderator pages](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/pages/moderator/LaundryModeratorPage.tsx): pages · Laundry catalog and order handling screens for moderators · `client/src/pages/moderator/LaundryModeratorPage.tsx`
- [Order timeline](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/OrderTimeline.tsx): status ui · Order progress visualization in the UI · `client/src/components/OrderTimeline.tsx`
- [Chatbot](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/components/Chatbot.tsx): assistant ui · Interactive support or guidance entrypoint · `client/src/components/Chatbot.tsx`
- [API client](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/helpers/axiosInstance.ts): http client · Main REST boundary from UI to backend · `client/src/helpers/axiosInstance.ts`
- [Socket service](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/helpers/socketService.ts): realtime client · Browser real-time channel for live updates · `client/src/helpers/socketService.ts`
- [Redux store](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/store/store.ts): state · Client state container and slice wiring · `client/src/store/store.ts`
- [State slices](https://github.com/anshul-sharma01/u-laundry/blob/main/client/src/store/slices/authSlice.ts): slices · Auth, admin, and moderator state domains · `client/src/store/slices/authSlice.ts`

### Server

Express API layered by routes, controllers, models, middleware, and utilities

- [server.js](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/server.js): bootstrap · Node process entrypoint · `server/src/server.js`
- [Express app](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/app.js): api shell · Middleware and route composition · `server/src/app.js`
- [DB connection](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/config/dbConnection.js): database · MongoDB connection setup · `server/src/config/dbConnection.js`
- [User API](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/user.controller.js): auth domain · Registration, login, verification, and account recovery · `server/src/controllers/user.controller.js`
- [Order API](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/order.controller.js): orders domain · Order lifecycle, status, and operational handling · `server/src/controllers/order.controller.js`
- [Pricing API](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/pricing.controller.js): pricing domain · Pricing rules and calculation orchestration · `server/src/controllers/pricing.controller.js`
- [Laundry API](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/laundryItem.controller.js): catalog domain · Laundry item management for admin and moderator workflows · `server/src/controllers/laundryItem.controller.js`
- [Chatbot API](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/chatbot.controller.js): assistant domain · Backend routes and logic for chatbot interactions · `server/src/controllers/chatbot.controller.js`
- [Razorpay webhook](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/controllers/razorpayWebhook.controller.js): payments · Asynchronous payment confirmation endpoint · `server/src/controllers/razorpayWebhook.controller.js`
- [Auth middleware](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/middlewares/auth.middleware.js): security · Request authentication and authorization checks · `server/src/middlewares/auth.middleware.js`
- [Upload middleware](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/middlewares/multer.middleware.js): files · Multipart upload handling and temp file staging · `server/src/middlewares/multer.middleware.js`
- [Mongo models](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/models/user.model.js): persistence · Users, orders, OTPs, slots, pricing rules, and laundry items · `server/src/models/user.model.js`
- [Server utils](https://github.com/anshul-sharma01/u-laundry/blob/main/server/src/utils/pricingEngine.js): services · Pricing, invoices, email, cloud storage, sockets, and payment helpers · `server/src/utils/pricingEngine.js`

### External

Outside services and runtime dependencies

- **MongoDB**: database · Primary application datastore
- **Razorpay**: payments provider · External payment processing and webhook source
- **Cloudinary**: media storage · External asset hosting for uploaded files
- **Email delivery**: notification service · Outbound email channel for OTPs and account/order messages

## Connections

- main.tsx → App: mounts · Bootstraps the routed app
- App → Shell layout: wraps · Provides the shared UI shell
- App → Auth hydrator: hydrates · Restores auth before route rendering
- App → Route guards: guards · Separates public, user, admin, and moderator routes
- App → User pages: renders · Routes to user-facing pages
- App → Auth pages: renders · Routes to authentication flows
- App → Admin pages: renders · Routes to admin dashboards
- App → Moderator pages: renders · Routes to moderator screens
- User pages → Order timeline: shows · Uses timeline UI for order progress
- User pages → Chatbot: offers · Exposes assistant support entrypoint
- State slices → Redux store: compose · Slices are wired into the Redux store
- Redux store → API client: fetches · State actions call REST endpoints
- Redux store → Socket service: subscribes · State listens to live events
- API client → Express app: calls · HTTP requests go to the API
- Socket service → Express app: connects · Real-time client connects to server-side socket handling
- server.js → Express app: starts · Launches the Express application
- Express app → DB connection: connects · Initializes database connectivity
- Express app → Auth middleware: uses · Protects API routes with auth checks
- Express app → Upload middleware: uses · Handles uploads in request pipeline
- Express app → User API: routes to · User and auth API
- Express app → Order API: routes to · Order API
- Express app → Pricing API: routes to · Pricing API
- Express app → Laundry API: routes to · Laundry item API
- Express app → Chatbot API: routes to · Chatbot API
- Razorpay webhook → Razorpay: receives · Payment provider webhook callbacks
- User API → Mongo models: reads/writes · Persists users and OTP records
- Order API → Mongo models: reads/writes · Persists orders and pickup slot data
- Pricing API → Mongo models: reads/writes · Persists pricing rules
- Laundry API → Mongo models: reads/writes · Persists laundry catalog items
- User API → Server utils: uses · Delegates email and response helpers
- Order API → Server utils: uses · Delegates invoice, pricing, payment, and socket helpers
- Laundry API → Server utils: uses · Delegates file and media helpers
- Server utils → Cloudinary: uploads · Stores media assets externally
- Server utils → Email delivery: sends · Delivers outbound notifications
- Server utils → Razorpay: charges · Initiates payment flows
- Mongo models → MongoDB: persists · All domain data is stored in MongoDB
