How anshul-sharma01/u-laundry works
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: app.js Express app · App.tsx App · pricingEngine.js Server utils · user.model.js Mongo models
Components 32
Client
Vite React SPA with routed pages, role guards, state, and API integration
- main.tsx · Client entrypoint that mounts the React app
client/src/main.tsx - App · Top-level routing and application composition
client/src/App.tsx - Shell layout · Common navigation frame with header and footer
client/src/layouts/NavigationLayout.tsx - Auth hydrator · Restores authentication state before route decisions
client/src/components/AuthHydrator.tsx - Route guards · Protected, admin, and moderator route boundaries
client/src/components/ProtectedRoute.tsx - User pages · Public and signed-in user-facing pages
client/src/pages/HomePage.tsx - Auth pages · Login, signup, recovery, and verification flows
client/src/pages/auth/LoginPage.tsx - Admin pages · Operational dashboards for users, orders, pricing, and verifications
client/src/pages/admin/AdminDashboardPage.tsx - Moderator pages · Laundry catalog and order handling screens for moderators
client/src/pages/moderator/LaundryModeratorPage.tsx - Order timeline · Order progress visualization in the UI
client/src/components/OrderTimeline.tsx - Chatbot · Interactive support or guidance entrypoint
client/src/components/Chatbot.tsx - API client · Main REST boundary from UI to backend
client/src/helpers/axiosInstance.ts - Socket service · Browser real-time channel for live updates
client/src/helpers/socketService.ts - Redux store · Client state container and slice wiring
client/src/store/store.ts - State 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 · Node process entrypoint
server/src/server.js - Express app · Middleware and route composition
server/src/app.js - DB connection · MongoDB connection setup
server/src/config/dbConnection.js - User API · Registration, login, verification, and account recovery
server/src/controllers/user.controller.js - Order API · Order lifecycle, status, and operational handling
server/src/controllers/order.controller.js - Pricing API · Pricing rules and calculation orchestration
server/src/controllers/pricing.controller.js - Laundry API · Laundry item management for admin and moderator workflows
server/src/controllers/laundryItem.controller.js - Chatbot API · Backend routes and logic for chatbot interactions
server/src/controllers/chatbot.controller.js - Razorpay webhook · Asynchronous payment confirmation endpoint
server/src/controllers/razorpayWebhook.controller.js - Auth middleware · Request authentication and authorization checks
server/src/middlewares/auth.middleware.js - Upload middleware · Multipart upload handling and temp file staging
server/src/middlewares/multer.middleware.js - Mongo models · Users, orders, OTPs, slots, pricing rules, and laundry items
server/src/models/user.model.js - Server utils · Pricing, invoices, email, cloud storage, sockets, and payment helpers
server/src/utils/pricingEngine.js
External
Outside services and runtime dependencies
- MongoDB · Primary application datastore
- Razorpay · External payment processing and webhook source
- Cloudinary · External asset hosting for uploaded files
- Email delivery · Outbound email channel for OTPs and account/order messages
Connections 36
- 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