How rushikesh0107/food-delivery-app works
1. Top-level shape
- This repo is a classic two-tier MERN application split into a Node/Express backend and a React frontend.
- The backend owns data access, authentication, file upload handling, and business rules.
- The frontend owns routing/UI state, calls the backend through service modules, and stores shared client state in Redux slices.
2. Backend runtime and entry points
- backend/src/index.js is the server bootstrap.
- backend/src/app.js is the Express application configuration layer.
- backend/src/db/index.js handles the MongoDB connection.
- The backend is organized around REST endpoints under backend/src/routes/*.
3. Backend layering
- The backend follows a standard route → controller → model flow.
- routes define HTTP endpoints.
- controllers implement request handling and orchestration.
- models define MongoDB collections for core domain objects.
- This separation suggests a fairly clean boundary between transport logic and domain/data logic.
4. Backend domain model
- Main persisted entities are:
- User
- Food
- Category
- Cart
- Order
- Address
- These map directly to the app’s core flows: browse catalog, manage cart, checkout, ship to address, and track orders.
- The presence of separate Category and Food models indicates the menu/catalog is structured rather than flat.
5. Backend business modules
- FoodController, CategoryController, and AdminController support catalog/admin management.
- CartController, OrderController, AddressController, and PaymentController support the buyer checkout flow.
- UserController handles authentication/profile-related actions.
- The route set includes both user-facing and admin-facing APIs, implying role-based access boundaries.
6. Backend security and cross-cutting concerns
- middlewares/auth.middleware.js protects authenticated routes.
- middlewares/verifyAdmin.js enforces admin-only access.
- utils/asyncHandler.js, ApiErrors.js, and ApiResponseHandler.js centralize request error handling and response formatting.
- This means controllers likely stay thin and delegate shared concerns to middleware and utility wrappers.
7. Backend file upload and external services
- middlewares/multer.middleware.js plus utils/cloundinary.js indicate image upload support for food/admin assets.
- Upload flow is likely: client sends multipart form data → Multer parses it → Cloudinary stores the asset → backend persists the returned URL in MongoDB.
- PaymentController and the README’s Stripe note indicate payment is integrated or optional, with the backend acting as the payment boundary.
8. Frontend runtime and app shell
- The frontend is a React application built with Vite (frontend/vite.config.js, frontend/src/main.jsx).
- App.jsx and the shared layout components (Header, NavBar, Footer, Layout) form the outer shell.
- Styling is handled with Tailwind and local CSS files (App.css, index.css).
9. Frontend state management
- Redux is the primary client-side state layer via frontend/src/app/Store.js.
- Feature slices exist for:
- authentication
- cart
- categories
- items/food
- orders
- address
- profile
- This shows the UI is driven by a shared store rather than local component-only state for core application data.
10. Frontend API boundary
- frontend/src/services/apiConnector.js and frontend/src/services/apis.js define the client’s API access layer.
- Feature-specific operation modules under frontend/src/services/Operations/* isolate backend calls for auth, cart, food, categories, orders, payment, address, admin, and profile.
- This creates a clear boundary: UI components dispatch store actions and invoke service operations, but do not talk to the backend directly.
11. Frontend page structure
- Pages are split by user journey: Home, Store, Cart, Checkout, Order, Profile, Auth, Admin, Address, About, Contact, Logout, and 404.
- This indicates route-level composition around functional user workflows rather than a single-page dashboard model.
- ProtectedRoutes.jsx suggests some pages are gated by authentication and role.
12. Frontend feature composition
- Reusable feature components are organized by domain: Auth, Cart, Order, Profile, Store, Admin, Home, Address.
- Admin features include adding/removing food, adding categories, viewing orders, and order details.
- User features include login/register, profile editing, address management, cart review, checkout, and order history.
13. Primary data flows
- Catalog flow: backend Food/Category APIs → frontend store/slices → store and home UI.
- Cart/checkout flow: user actions in cart UI → cart Redux slice → cart/order APIs → backend persistence in Cart/Order models.
- Profile/address flow: profile and address forms → profile/address service calls → backend User/Address models.
- Admin flow: admin dashboard forms → admin/food/category APIs → backend protected controllers and models.
- Payment flow: checkout UI → payment service → backend payment controller → external payment provider.
14. Deployment and hosting boundaries
- The README indicates a split deployment model: frontend on Vercel, backend on Render, database on MongoDB Atlas.
- That deployment shape reinforces the architectural boundary between a stateless client app, an API server, and an external managed database.
Main entry points: App.jsx UI shell · controllers Controllers · app.js Express app · middlewares Middleware
Components 17
Backend
Node/Express API, data access, and business rules
- Server bootstrap · Starts the backend process and boots the HTTP server
backend/src/index.js - Express app · Configures middleware and mounts API routes
backend/src/app.js - MongoDB · Establishes the MongoDB connection
backend/src/db/index.js - API routes · HTTP endpoint definitions for the backend
backend/src/routes - Controllers · Orchestrate request handling across auth, catalog, cart, orders, address, admin, and payment
backend/src/controllers - Models · Defines persisted domain entities such as users, food, categories, cart, orders, and addresses
backend/src/models - Middleware · Authentication, admin authorization, and multipart upload handling
backend/src/middlewares - Utils · Async wrapper, API error/response helpers, and external service wiring
backend/src/utils - Cloudinary · Image storage boundary used by the upload flow
backend/src/utils/cloundinary.js
Frontend
React UI, client state, and API orchestration
- App entry · Bootstraps the Vite React app
frontend/src/main.jsx - UI shell · Top-level app composition with layout, navigation, and shared chrome
frontend/src/App.jsx - Redux store · Central client state container for feature slices
frontend/src/app/Store.js - Feature slices · Authentication, cart, catalog, order, address, and profile state
frontend/src/Slices - API services · API connector and feature operation modules that call the backend
frontend/src/services - Pages · User journeys for home, store, cart, checkout, order, profile, auth, admin, address, and static pages
frontend/src/pages - Components · Reusable feature and common UI building blocks
frontend/src/components - Protected routes · Gates authenticated and role-restricted UI flows
frontend/src/components/core/Auth/ProtectedRoutes.jsx
Connections 20
- Server bootstrap → Express app: boots · Server bootstrap starts the Express application
- Express app → MongoDB: connects · App startup depends on MongoDB connectivity
- Express app → API routes: mounts · Express app mounts the REST route tree
- API routes → Controllers: dispatches to · Routes forward request handling to controllers
- Controllers → Models: persists via · Controllers read and write domain models
- Controllers → Middleware: protected by · Auth, admin, and upload middleware wrap controller flows
- Middleware → Utils: uses · Middleware and handlers share async/error helpers
- Middleware → Cloudinary: uploads to · File upload middleware hands assets to Cloudinary
- Controllers → Utils: formats responses · Controllers use shared response and error helpers
- App entry → UI shell: renders · React entry renders the application shell
- UI shell → Components: composes · Shell uses shared layout and feature components
- UI shell → Pages: navigates to · App shell drives page-level routing and composition
- UI shell → Protected routes: guards · Route protection wraps restricted pages
- UI shell → Redux store: reads state · UI shell is backed by central Redux state
- Redux store → Feature slices: combines · Redux store aggregates feature slices
- Components → Feature slices: consumes state · Components render from shared client state
- Pages → API services: calls · Pages trigger API operations through service modules
- API services → API routes: requests · Client service layer talks to backend REST endpoints
- API services → Cloudinary: uploads assets · Upload-related operations eventually depend on the backend upload boundary
- Pages → Components: assembles · Pages are composed from reusable domain components