# chahatkesh/food-delivery-app architecture

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

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

## Overview

##### Project type and purpose
- This is a full‑stack food‑delivery web application (“food‑delivery‑app”) built with React (client & admin UIs), Node/Express (API server), MongoDB (database), and Stripe (payment).

##### File structure
- Top‑level modules:
- **admin/** – React‑based admin panel for managing food items, orders, etc.
- **client/** – React‑based customer‑facing frontend for browsing menu, placing orders.
- **server/** – Express app exposing REST endpoints, handling business logic, connecting to MongoDB and Stripe, with MVC‑style folders:
◦ config/db.js (DB connection)
◦ models/ (Mongoose schemas)
◦ controllers/ (request handlers)
◦ routes/ (Express routers)
◦ middleware/auth.js (JWT or session auth)
◦ uploads/ (file storage, e.g. food images)
- Build config in each frontend (vite.config.js) and server config via .env.

##### Key insights from README
- Tech stack: React, Node.js, Express, MongoDB, Stripe.
- Deployment: Frontends and server hosted (e.g., Render).
- Two distinct frontends share the same backend API.

##### Detailed elements
- Labels: e.g., “/api/food”, “/api/order”, “auth middleware”
- Server sub‑components: config, routes, controllers, models, middleware
- Storage of uploaded files (server/uploads) or note external blob storage if used
- Security boundary around server’s auth‑protected routes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client and Admin UIs
    subgraph "Client Side"
        Client["Client React App"]:::frontend
    end
    subgraph "Admin Side"
        Admin["Admin React App"]:::frontend
    end

    %% API Server Layer
    subgraph "Express API Server" 
        direction TB
        ServerEntry["server.js"]:::backend
        Env[".env"]:::config
        DBConf["DB Config (db.js)"]:::config
        Middleware["Auth Middleware"]:::backend

        subgraph "Routes"
            direction TB
            URoute["/api/users"]:::backend
            FRRoute["/api/food"]:::backend
            CRRoute["/api/cart"]:::backend
            ORRoute["/api/orders"]:::backend
        end

        subgraph "Controllers"
            direction TB
            UCtrl["UserController"]:::backend
            FCtrl["FoodController"]:::backend
            CCtrl["CartController"]:::backend
            OCtrl["OrderController"]:::backend
        end

        subgraph "Models"
            direction TB
            UModel["UserModel"]:::model
            FModel["FoodModel"]:::model
            OModel["OrderModel"]:::model
        end

        Uploads["File Storage (uploads)"]:::storage
        StripeSvc["Stripe (Payment)"]:::external
        MongoDB["MongoDB Database"]:::database
    end

    %% Connections: Frontend to API
    Client -->|HTTPS REST API| ServerEntry
    Admin -->|HTTPS REST API| ServerEntry

    %% Server internals connections
    ServerEntry --> Env
    ServerEntry --> DBConf
    ServerEntry --> Middleware
    ServerEntry --> URoute
    ServerEntry --> FRRoute
    ServerEntry --> CRRoute
    ServerEntry --> ORRoute

    Middleware --> URoute
    Middleware --> FRRoute
    Middleware --> CRRoute
    Middleware --> ORRoute

    URoute --> UCtrl
    FRRoute --> FCtrl
    CRRoute --> CCtrl
    ORRoute --> OCtrl

    UCtrl --> UModel
    FCtrl --> FModel
    CCtrl --> UModel
    CCtrl --> FModel
    OCtrl --> OModel
    OCtrl --> StripeSvc
    FCtrl --> Uploads

    DBConf --> UModel
    DBConf --> FModel
    DBConf --> OModel
    UModel --> MongoDB
    FModel --> MongoDB
    OModel --> MongoDB

    %% Click Events
    click Admin "https://github.com/chahatkesh/food-delivery-app/tree/main/admin/"
    click Client "https://github.com/chahatkesh/food-delivery-app/tree/main/client/"
    click ServerEntry "https://github.com/chahatkesh/food-delivery-app/blob/main/server/server.js"
    click DBConf "https://github.com/chahatkesh/food-delivery-app/blob/main/server/config/db.js"
    click UModel "https://github.com/chahatkesh/food-delivery-app/blob/main/server/models/userModel.js"
    click FModel "https://github.com/chahatkesh/food-delivery-app/blob/main/server/models/foodModel.js"
    click OModel "https://github.com/chahatkesh/food-delivery-app/blob/main/server/models/orderModel.js"
    click UCtrl "https://github.com/chahatkesh/food-delivery-app/blob/main/server/controllers/userController.js"
    click FCtrl "https://github.com/chahatkesh/food-delivery-app/blob/main/server/controllers/foodController.js"
    click CCtrl "https://github.com/chahatkesh/food-delivery-app/blob/main/server/controllers/cartController.js"
    click OCtrl "https://github.com/chahatkesh/food-delivery-app/blob/main/server/controllers/orderController.js"
    click URoute "https://github.com/chahatkesh/food-delivery-app/blob/main/server/routes/userRoute.js"
    click FRRoute "https://github.com/chahatkesh/food-delivery-app/blob/main/server/routes/foodRoute.js"
    click CRRoute "https://github.com/chahatkesh/food-delivery-app/blob/main/server/routes/cartRoute.js"
    click ORRoute "https://github.com/chahatkesh/food-delivery-app/blob/main/server/routes/orderRoute.js"
    click Middleware "https://github.com/chahatkesh/food-delivery-app/blob/main/server/middleware/auth.js"
    click Uploads "https://github.com/chahatkesh/food-delivery-app/tree/main/server/uploads/"
    click Env "https://github.com/chahatkesh/food-delivery-app/blob/main/server/.env"
    click admin "https://github.com/chahatkesh/food-delivery-app/blob/main/admin/vite.config.js"
    click client "https://github.com/chahatkesh/food-delivery-app/blob/main/client/vite.config.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#3399FF,stroke-width:2px
    classDef backend fill:#DFF7D8,stroke:#33AA33,stroke-width:2px
    classDef config fill:#FFF4C2,stroke:#FFCC00,stroke-width:2px
    classDef model fill:#FFE5CC,stroke:#FF9933,stroke-width:2px
    classDef storage fill:#E8D0FF,stroke:#9933CC,stroke-width:2px
    classDef external fill:#F0D0F0,stroke:#CC33CC,stroke-width:2px
    classDef database fill:#FFD1A9,stroke:#FF6600,stroke-width:2px
```
