# chiragbansal511/quickcrave architecture

> Architecture diagram of the GitHub repository chiragbansal511/quickcrave, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chiragbansal511/quickcrave
- Repository: https://github.com/chiragbansal511/quickcrave

## Overview

##### Project Type and Purpose
- This is a full-stack food-ordering platform (“QuickCrave”) with two React frontends (customer and admin) and a centralized Node.js/Express backend.
- Purpose: enable customers to browse restaurants and place orders, and enable restaurant administrators to manage menus and receive real-time order notifications.

##### File Structure Analysis
- Top-level:
- backend/             → Node.js entry point (app.js), Express routes, Socket.IO integration
- frontend/hungerbox/  → Customer React app
- frontend/userhungerbox/ → Admin React app
- Each frontend uses React Router, Axios for API calls, and Tailwind/PostCSS for styling.
- Authentication: JWT handled in backend.
- Real-time: Socket.IO server in backend, rooms keyed by restaurant.
- Persistence: MongoDB via Mongoose, dynamic collections per restaurant.

##### Key README Insights
- Dual-interface architecture with role-based JWT authentication.
- Core flows: customer browsing & ordering, admin menu management & real-time order tracking.
- Data flow model outlined with HTTP and WebSocket (Socket.IO) interactions.

##### Detail
- Every protected API route and whether it’s customer-only or admin-only.
- Dynamic collection creation for menus by restaurant name.
- Role separation: which frontend can call which backend controller.
- Real-time feedback loop: customer places order → backend emits to Socket.IO room → admin client receives event.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Clients
    subgraph "Customer App"
        direction TB
        CustomerApp["Customer App (React)"]:::frontend
        AppC["App.js"]:::frontend
        PrivC["PrivateRoute.js"]:::frontend
        PagesC["Pages"]:::frontend
    end

    subgraph "Admin App"
        direction TB
        AdminApp["Admin App (React)"]:::frontend
        AppA["App.js"]:::frontend
        PrivA["PrivateRoute.js"]:::frontend
        PagesA["Pages"]:::frontend
    end

    %% Backend Components
    subgraph "Backend API Server"
        direction TB
        API["API Server (Express + Socket.IO)"]:::backend
        Auth["Auth Middleware (JWT)"]:::auth
        OrderProc["Order Processor"]:::backend
        MenuCtrl["Menu Controller"]:::backend
        SocketIO["Socket.IO Server"]:::backend
        Package["package.json"]:::backend
    end

    %% Database
    Mongo["MongoDB (Mongoose)"]:::db

    %% Connections
    CustomerApp -->|HTTP: GET/POST /login, /hotellist, /menu, /order| API
    AdminApp -->|HTTP: GET/POST /login, /openhotel, /setmenu| API

    API --> Auth
    API --> OrderProc
    API --> MenuCtrl
    API --> SocketIO
    API -->|CRUD operations| Mongo

    SocketIO -.->|Socket.IO: emit newOrder to room| AdminApp

    %% Click events
    click CustomerApp "https://github.com/chiragbansal511/quickcrave/tree/master/frontend/hungerbox/"
    click AppC "https://github.com/chiragbansal511/quickcrave/blob/master/frontend/hungerbox/src/App.js"
    click PrivC "https://github.com/chiragbansal511/quickcrave/blob/master/frontend/hungerbox/src/components/privateroute.js"
    click PagesC "https://github.com/chiragbansal511/quickcrave/tree/master/frontend/hungerbox/src/pages/"
    click AdminApp "https://github.com/chiragbansal511/quickcrave/tree/master/frontend/userhungerbox/"
    click AppA "https://github.com/chiragbansal511/quickcrave/blob/master/frontend/userhungerbox/src/App.js"
    click PrivA "https://github.com/chiragbansal511/quickcrave/blob/master/frontend/userhungerbox/src/components/privateroute.js"
    click PagesA "https://github.com/chiragbansal511/quickcrave/tree/master/frontend/userhungerbox/src/pages/"
    click API "https://github.com/chiragbansal511/quickcrave/blob/master/backend/app.js"
    click Package "https://github.com/chiragbansal511/quickcrave/blob/master/backend/package.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,color:#000
    classDef backend fill:#90EE90,stroke:#000,color:#000
    classDef db fill:#FFA500,stroke:#000,color:#000
    classDef auth fill:#D3D3D3,stroke:#000,color:#000
```
