How theunstopabble/swadkart-pro works
1. System shape
- SwadKart is a full-stack, multi-role food delivery platform split into a React frontend and an Express/MongoDB backend.
- The main user roles are customer, restaurant owner, delivery partner, and admin; the UI and API are both organized around these boundaries.
2. Frontend application boundary
- The frontend is a Vite + React app with React Router for page navigation and Redux Toolkit for shared state, mainly cart and user/session state.
- Most UI is composed from domain-specific component groups: ordering, restaurant management, delivery workflows, and admin dashboards.
3. Frontend feature surfaces
- Customer-facing pages cover discovery, cart, checkout, payments, order history/details, profile, auth, and support-style pages.
- There are dedicated interfaces for admin dashboards, restaurant owner dashboards, and delivery partner dashboards, which means the frontend is not just a consumer app but a multi-portal system.
- The app also includes interactive extras like voice search, chatbot, PWA install prompts, and local notification helpers.
4. Backend application boundary
- The backend is structured in classic Express MVC style: routes map HTTP endpoints, controllers hold business logic, models define MongoDB schemas, and middleware handles auth/error behavior.
- server.js is the composition point where the app, database, auth, and realtime services are wired together.
5. Core data model
- MongoDB/Mongoose models center on users, restaurants, products, orders, coupons, coupon usage, and emergency records.
- This indicates the main domain entities are commerce and fulfillment, with support for promotions and delivery safety workflows.
6. Authentication and identity
- Authentication is hybrid: JWT-based email/password auth plus Firebase Google auth on the frontend side.
- There is also a WebAuthn biometric flow with backend config and routes, supporting device-native fingerprint/Face ID login.
- authMiddleware acts as the access-control boundary for role-based features and protected APIs.
7. Order lifecycle flow
- The primary data flow is: browse restaurants/products → add to cart → apply coupon → enter address → pay → create order → track status → confirm delivery.
- Order-related components and routes indicate that status changes are a first-class part of the architecture, not just a final checkout step.
8. Realtime and fulfillment
- Socket.io is used for realtime order tracking and live operational updates.
- This likely connects customer tracking views, restaurant “live orders” screens, and delivery partner dashboards through a shared event stream.
- Delivery verification includes OTP-based confirmation, which ties the backend order state to final handoff.
9. Admin and merchant operations
- The backend and frontend both support rich operational dashboards: restaurant menu management, live order handling, user administration, coupon management, and analytics.
- Admin-specific tooling includes revenue/order/user overview and demand heatmap visualization, showing that the system is built for operational decision-making, not only order placement.
10. External service integrations
- Cloudinary handles image uploads/media storage.
- Stripe and Razorpay appear as payment gateways.
- SMTP email is used for OTPs, notifications, and transactional messaging.
- A push-notification utility and Firebase config suggest additional messaging/device notification integration.
11. Caching and background processing
- There is an optional Redis configuration with a fallback to in-memory caching, so the app can run locally without Redis but benefit from it in production.
- Email sending is offloaded to a worker (emailWorker.js), which separates slow notification work from request/response handling.
12. Security and hardening
- The repo includes sanitization utilities and error middleware, indicating input hardening and centralized failure handling.
- The README also calls out role-based access, secure OTPs, cookie-based auth behavior, and production-vs-local differences in cookie settings.
13. Deployment boundary
- The frontend is intended for Vercel, and the backend for a Node host such as Render.
- vercel.json rewrites /api/* to the backend, which matters architecturally because it keeps frontend-origin requests compatible with cookie-based authentication in production.
14. What an architecture diagram should emphasize
- Draw three main zones: client UI, Express API backend, and external services/data stores.
- Show the frontend split into role-based portals, the backend split into route/controller/model layers, and the cross-cutting realtime channel via Socket.io.
- Include MongoDB as the system of record, Redis as optional cache, and Cloudinary/payment/email/biometric providers as external dependencies.
Main entry points: orderController.js Controllers · App.jsx App shell · Home.jsx Customer flows · server.js API entry
Components 23
Frontend
React client with role-based portals, shared state, and feature components
- App shell · Root client app with routing and shared session state
frontend/src/App.jsx - Shared state · Cart and user/session state management
frontend/src/redux/store.js - Customer flows · Discovery, cart, checkout, payment, orders, profile, and support pages
frontend/src/pages/Home.jsx - Merchant portal · Restaurant owner menu, live orders, and analytics views
frontend/src/pages/RestaurantOwnerDashboard.jsx - Delivery portal · Delivery workflow, OTP confirmation, earnings, and SOS support
frontend/src/pages/DeliveryPartnerDashboard.jsx - Admin portal · Operations overview, users, shops, orders, coupons, and heatmap tools
frontend/src/pages/AdminDashboard.jsx - UX extras · Chatbot, voice search, PWA install prompt, and notification helper
frontend/src/components/ChatBot.jsx - Order UI · Cart, address, coupon, tracking, summary, and success flow components
frontend/src/components/CheckoutSteps.jsx - Restaurant UI · Menu management, live orders, analytics, and item editing components
frontend/src/components/restaurant/MenuManagement.jsx - Delivery UI · Delivery card, OTP section, earnings history, and SOS button
frontend/src/components/delivery/DeliveryCard.jsx - Client integrations · Google auth, Firebase config, biometric client calls, and socket client
frontend/src/utils/firebaseConfig.js
Backend
Express API, domain logic, persistence, and background jobs
- API entry · App composition, database bootstrap, sockets, and route mounting
backend/server.js - API routes · Endpoint surface for auth, orders, products, restaurants, coupons, payments, chat, upload, and biometrics
backend/routes/orderRoutes.js - Controllers · Role-specific request handlers and workflow orchestration
backend/controllers/orderController.js - Data models · Users, restaurants, products, orders, coupons, coupon usage, and emergency records
backend/models/orderModel.js - Middleware · Auth protection, access control, sanitization, and centralized error handling
backend/middleware/authMiddleware.js - Backend config · Database, Cloudinary, Redis, and WebAuthn configuration
backend/config/db.js - Email worker · Asynchronous transactional email processing
backend/workers/emailWorker.js
External services
Datastores and third-party providers used by the app
- MongoDB · System of record for commerce, fulfillment, and identity data
- Redis · Shared cache with in-memory fallback for local runs
- Cloudinary · Image upload and asset storage provider
- Payments · External payment gateways for checkout
- Messaging · Email, push notifications, and device messaging providers
Connections 24
- App shell → Shared state: uses · App consumes shared cart and user state
- App shell → Customer flows: routes to · Primary customer navigation
- App shell → Merchant portal: routes to · Restaurant owner portal navigation
- App shell → Delivery portal: routes to · Delivery partner portal navigation
- App shell → Admin portal: routes to · Admin portal navigation
- Customer flows → Order UI: uses · Checkout and order lifecycle UI
- Merchant portal → Restaurant UI: uses · Menu and live order management UI
- Delivery portal → Delivery UI: uses · Delivery execution and handoff UI
- Customer flows → UX extras: augmented by · Voice search, chatbot, install prompt, and notifications
- Client integrations → API entry: calls · Authenticated API and realtime communication
- Client integrations → Messaging: auth/messaging · Firebase and notification helpers
- API entry → API routes: mounts · HTTP endpoint registration
- API routes → Controllers: dispatches · Routes hand off to business logic
- Controllers → Data models: reads/writes · Business logic persists domain entities
- Controllers → Middleware: protected by · Role checks, sanitization, and error handling
- API entry → Backend config: initializes · Database and service configuration
- Backend config → MongoDB: connects · MongoDB connection
- Backend config → Redis: optionally uses · Cache with fallback to memory
- Controllers → Cloudinary: uploads to · Media handling for restaurant and product images
- Controllers → Payments: charges via · Checkout payment processing
- Controllers → Messaging: notifies via · OTP, email, push, and transactional messaging
- Email worker → Messaging: sends · Async email delivery
- Controllers → Email worker: queues · Offloads slow email work
- Controllers → MongoDB: persists to · Primary data store