# rushikesh0107/food-delivery-app architecture

> Architecture diagram of the GitHub repository rushikesh0107/food-delivery-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rushikesh0107/food-delivery-app
- Repository: https://github.com/rushikesh0107/food-delivery-app

## Overview

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: [`frontend/src/App.jsx`](https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/App.jsx) (UI shell), [`backend/src/controllers`](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/controllers) (Controllers), [`backend/src/app.js`](https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/app.js) (Express app), [`backend/src/middlewares`](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/middlewares) (Middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_entry(("Server bootstrap<br/>express entry<br/>[index.js]"))
  node_backend_app["Express app<br/>app config<br/>[app.js]"]
  node_backend_db[("MongoDB<br/>db connector<br/>[index.js]")]
  node_backend_routes["API routes<br/>route layer"]
  node_backend_controllers["Controllers<br/>request handlers"]
  node_backend_models[("Models")]
  node_backend_middleware["Middleware<br/>guards/upload"]
  node_backend_utils["Utils<br/>shared helpers"]
  node_backend_cloudinary(("Cloudinary<br/>upload service<br/>[cloundinary.js]"))
end

subgraph group_frontend["Frontend"]
  node_frontend_main(("App entry<br/>react entry<br/>[main.jsx]"))
  node_frontend_shell["UI shell<br/>layout<br/>[App.jsx]"]
  node_frontend_store[("Redux store<br/>state root<br/>[Store.js]")]
  node_frontend_slices["Feature slices<br/>redux slices"]
  node_frontend_services["API services<br/>client api"]
  node_frontend_pages["Pages"]
  node_frontend_components["Components"]
  node_frontend_protected{{"Protected routes<br/>route guard"}}
end

node_backend_entry -->|"boots"| node_backend_app
node_backend_app -->|"connects"| node_backend_db
node_backend_app -->|"mounts"| node_backend_routes
node_backend_routes -->|"dispatches to"| node_backend_controllers
node_backend_controllers -->|"persists via"| node_backend_models
node_backend_controllers -->|"protected by"| node_backend_middleware
node_backend_middleware -->|"uses"| node_backend_utils
node_backend_middleware -->|"uploads to"| node_backend_cloudinary
node_backend_controllers -->|"formats responses"| node_backend_utils
node_frontend_main -->|"renders"| node_frontend_shell
node_frontend_shell -->|"composes"| node_frontend_components
node_frontend_shell -->|"navigates to"| node_frontend_pages
node_frontend_shell -->|"guards"| node_frontend_protected
node_frontend_shell -->|"reads state"| node_frontend_store
node_frontend_store -->|"combines"| node_frontend_slices
node_frontend_components -->|"consumes state"| node_frontend_slices
node_frontend_pages -->|"calls"| node_frontend_services
node_frontend_services -->|"requests"| node_backend_routes
node_frontend_services -.->|"uploads assets"| node_backend_cloudinary
node_frontend_pages -->|"assembles"| node_frontend_components

click node_backend_entry "https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/index.js"
click node_backend_app "https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/app.js"
click node_backend_db "https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/db/index.js"
click node_backend_routes "https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/routes"
click node_backend_controllers "https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/controllers"
click node_backend_models "https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/models"
click node_backend_middleware "https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/middlewares"
click node_backend_utils "https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/utils"
click node_backend_cloudinary "https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/utils/cloundinary.js"
click node_frontend_main "https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/main.jsx"
click node_frontend_shell "https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/App.jsx"
click node_frontend_store "https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/app/Store.js"
click node_frontend_slices "https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/Slices"
click node_frontend_services "https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/services"
click node_frontend_pages "https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/pages"
click node_frontend_components "https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/components"
click node_frontend_protected "https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/components/core/Auth/ProtectedRoutes.jsx"

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_backend_entry,node_backend_app,node_backend_db,node_backend_routes,node_backend_controllers,node_backend_models,node_backend_middleware,node_backend_utils,node_backend_cloudinary toneBlue
class node_frontend_main,node_frontend_shell,node_frontend_store,node_frontend_slices,node_frontend_services,node_frontend_pages,node_frontend_components,node_frontend_protected toneAmber
```

## Components

### Backend

Node/Express API, data access, and business rules

- [Server bootstrap](https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/index.js): express entry · Starts the backend process and boots the HTTP server · `backend/src/index.js`
- [Express app](https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/app.js): app config · Configures middleware and mounts API routes · `backend/src/app.js`
- [MongoDB](https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/db/index.js): db connector · Establishes the MongoDB connection · `backend/src/db/index.js`
- [API routes](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/routes): route layer · HTTP endpoint definitions for the backend · `backend/src/routes`
- [Controllers](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/controllers): request handlers · Orchestrate request handling across auth, catalog, cart, orders, address, admin, and payment · `backend/src/controllers`
- [Models](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/models): mongoose models · Defines persisted domain entities such as users, food, categories, cart, orders, and addresses · `backend/src/models`
- [Middleware](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/middlewares): guards/upload · Authentication, admin authorization, and multipart upload handling · `backend/src/middlewares`
- [Utils](https://github.com/rushikesh0107/food-delivery-app/tree/main/backend/src/utils): shared helpers · Async wrapper, API error/response helpers, and external service wiring · `backend/src/utils`
- [Cloudinary](https://github.com/rushikesh0107/food-delivery-app/blob/main/backend/src/utils/cloundinary.js): upload service · Image storage boundary used by the upload flow · `backend/src/utils/cloundinary.js`

### Frontend

React UI, client state, and API orchestration

- [App entry](https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/main.jsx): react entry · Bootstraps the Vite React app · `frontend/src/main.jsx`
- [UI shell](https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/App.jsx): layout · Top-level app composition with layout, navigation, and shared chrome · `frontend/src/App.jsx`
- [Redux store](https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/app/Store.js): state root · Central client state container for feature slices · `frontend/src/app/Store.js`
- [Feature slices](https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/Slices): redux slices · Authentication, cart, catalog, order, address, and profile state · `frontend/src/Slices`
- [API services](https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/services): client api · API connector and feature operation modules that call the backend · `frontend/src/services`
- [Pages](https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/pages): route pages · User journeys for home, store, cart, checkout, order, profile, auth, admin, address, and static pages · `frontend/src/pages`
- [Components](https://github.com/rushikesh0107/food-delivery-app/tree/main/frontend/src/components): ui components · Reusable feature and common UI building blocks · `frontend/src/components`
- [Protected routes](https://github.com/rushikesh0107/food-delivery-app/blob/main/frontend/src/components/core/Auth/ProtectedRoutes.jsx): route guard · Gates authenticated and role-restricted UI flows · `frontend/src/components/core/Auth/ProtectedRoutes.jsx`

## Connections

- 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
