# ricrbhopal/cravings_fsd_6-7-8 architecture

> Architecture diagram of the GitHub repository ricrbhopal/cravings_fsd_6-7-8, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ricrbhopal/cravings_fsd_6-7-8
- Repository: https://github.com/ricrbhopal/cravings_fsd_6-7-8

## Overview

#### Purpose and topology
A full-stack food ordering and delivery platform. The `client` is a Vite/React single-page application for public ordering plus role-specific dashboards; the `server` is a Node.js API with authentication, restaurant/menu management, orders, and support/contact handling. Primary runtime entry points are `client/src/main.jsx`, `client/src/App.jsx`, and `server/index.js`.

#### Client composition and navigation
`client/src/App.jsx` is the application shell and likely route composition point, mounted by `client/src/main.jsx`. Public experiences are organized as page-level screens: home, catalog/order flow, restaurant detail, contact, login, and registration in `client/src/pages/Home.jsx`, `client/src/pages/OrderNow.jsx`, and `client/src/pages/RestaurantDetailsPage.jsx`. Shared chrome and interaction states reside in `client/src/components/Navbar.jsx`, `client/src/components/Footer.jsx`, and `client/src/components/Loader.jsx`.

#### Identity and API boundary
Client authentication state is centralized in `client/src/context/AuthContext.jsx`; frontend API targeting is isolated in `client/src/config/ApiConfig.jsx`. Server authentication enters through `server/src/router/auth.route.js`, is handled by `server/src/controller/auth.controller.js`, and is enforced for protected API flows by `server/src/middleware/auth.middelware.js`. Supporting services in `server/src/utils/auth.service.js` and `server/src/utils/email.service.js` indicate token/credential and email/OTP-related workflows.

#### Role-based dashboard boundary
The UI separates customer, restaurant, rider, and administrator operations into dedicated dashboard pages: `client/src/pages/dashboard/CustomerDashboard.jsx`, `client/src/pages/dashboard/RestaurantDashboard.jsx`, and `client/src/pages/dashboard/AdminDashboard.jsx`. Each role has its own sidebar, overview, order, and settings components, such as `client/src/components/customerDashboard/CustomerOrders.jsx`, `client/src/components/restaurantDashboard/RestaurantOrders.jsx`, and `client/src/components/riderDashboard/RiderOrders.jsx`. This is the main authorization/product boundary after login.

#### Restaurant onboarding and menu operations
Restaurant management is a substantial feature area. Restaurant users manage menus through `client/src/components/restaurantDashboard/RestaurantMenu.jsx` and modal-driven item editing in `client/src/components/restaurantDashboard/menuItems/AddNewItemModal.jsx`. Restaurant profile/onboarding captures core, legal, banking, address, social, and photo data under `client/src/components/restaurantDashboard/settings/`. Backend routes/controllers for this domain are `server/src/router/restaurant.route.js` and `server/src/controller/restaurant.controller.js`, backed by restaurant and menu records.

#### API routing, domain models, and order flow
`server/index.js` composes route groups for auth, public access, and each role: `server/src/router/public.route.js`, `server/src/router/customer.route.js`, `server/src/router/restaurant.route.js`, `server/src/router/rider.route.js`, and `server/src/router/admin.route.js`. Controllers divide public/common behavior from restaurant and auth behavior in `server/src/controller/public.controller.js`, `server/src/controller/common.controller.js`, and `server/src/controller/restaurant.controller.js`. Persistent core entities are represented by `server/src/models/user.model.js`, `server/src/models/customer.model.js`, `server/src/models/restaurant.model.js`, `server/src/models/rider.model.js`, `server/src/models/menu.model.js`, and `server/src/models/order.model.js`; orders connect customer ordering, restaurant fulfillment, and rider delivery views.

#### Infrastructure and external services
The server has explicit integrations for database access, Cloudinary media storage, and email delivery: `server/src/config/dbConnection.config.js`, `server/src/config/cloudinary.config.js`, and `server/src/config/email.config.js`. Image handling is abstracted in `server/src/utils/image.service.js`, supporting restaurant photos and likely menu media. Seed entry points in `server/src/seeders/seed.js` and `server/src/seeders/admin.seed.js` establish initial administrative/user data.

Main entry points: [`client/src/App.jsx`](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/App.jsx) (App Shell & Routes), [`server/index.js`](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/index.js) (API Entry), [`server/src/controller/restaurant.controller.js`](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/restaurant.controller.js) (Restaurant Management), [`server/src/models/user.model.js`](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/models/user.model.js) (Identity & Role Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_entry["Client Entry<br/>Vite bootstrap<br/>[main.jsx]"]
  node_app_shell["App Shell &amp; Routes<br/>React shell<br/>[App.jsx]"]
  node_public_pages["Public Ordering Screens<br/>React pages<br/>[OrderNow.jsx]"]
  node_shared_ui["Shared UI Chrome<br/>React components<br/>[Navbar.jsx]"]
  node_auth_context["Auth State<br/>React context<br/>[AuthContext.jsx]"]
  node_api_config["API Targeting<br/>client config<br/>[ApiConfig.jsx]"]
  node_role_dashboards["Role Dashboards<br/>React dashboards"]
  node_restaurant_menu_ui["Restaurant Menu Editor<br/>React feature<br/>[RestaurantMenu.jsx]"]
end

subgraph group_server["Node API"]
  node_api_entry{{"API Entry<br/>Express server<br/>[index.js]"}}
  node_auth_routes["Auth Routes<br/>Express routes<br/>[auth.route.js]"]
  node_protected_routes["Role &amp; Public Routes<br/>Express routes<br/>[public.route.js]"]
  node_auth_middleware["Auth Guard<br/>Express middleware<br/>[auth.middelware.js]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.js]"]
  node_public_controller["Public &amp; Common Logic<br/>controllers"]
  node_restaurant_routes["Restaurant Routes<br/>Express routes"]
  node_restaurant_controller["Restaurant Management<br/>controller"]
  node_auth_services["Credentials &amp; Email<br/>services<br/>[auth.service.js]"]
end

subgraph group_data["Persistence &amp; Integrations"]
  node_core_models[("Identity &amp; Role Models<br/>data models<br/>[user.model.js]")]
  node_commerce_models[("Menu &amp; Order Models<br/>data models<br/>[order.model.js]")]
  node_database[("Database Connection<br/>database integration")]
  node_media_storage["Cloudinary Media<br/>media integration"]
  node_seed_data["Initial Seed Data<br/>seeders<br/>[seed.js]"]
end

node_client_entry -->|"mounts"| node_app_shell
node_app_shell -->|"routes to"| node_public_pages
node_app_shell -->|"routes by role"| node_role_dashboards
node_app_shell -->|"uses"| node_shared_ui
node_auth_context -->|"supplies session"| node_app_shell
node_public_pages -->|"uses"| node_api_config
node_role_dashboards -->|"uses"| node_api_config
node_role_dashboards -->|"includes for restaurants"| node_restaurant_menu_ui
node_api_config -->|"API requests"| node_api_entry
node_api_entry -->|"mounts"| node_auth_routes
node_api_entry -->|"mounts"| node_protected_routes
node_api_entry -->|"mounts"| node_restaurant_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"uses"| node_auth_services
node_auth_controller -->|"reads and writes"| node_core_models
node_protected_routes -->|"protects role flows"| node_auth_middleware
node_auth_middleware -->|"authorizes"| node_public_controller
node_public_controller -->|"handles orders"| node_commerce_models
node_restaurant_routes -->|"protects"| node_auth_middleware
node_restaurant_routes -->|"dispatches"| node_restaurant_controller
node_restaurant_controller -->|"manages restaurant records"| node_core_models
node_restaurant_controller -->|"manages menus and orders"| node_commerce_models
node_restaurant_controller -->|"uploads images"| node_media_storage
node_core_models -->|"persists through"| node_database
node_commerce_models -->|"persists through"| node_database
node_seed_data -.->|"initializes"| node_core_models

click node_client_entry "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/main.jsx"
click node_app_shell "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/App.jsx"
click node_public_pages "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/pages/OrderNow.jsx"
click node_shared_ui "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/components/Navbar.jsx"
click node_auth_context "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/context/AuthContext.jsx"
click node_api_config "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/config/ApiConfig.jsx"
click node_role_dashboards "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/pages/dashboard/CustomerDashboard.jsx"
click node_restaurant_menu_ui "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/components/restaurantDashboard/RestaurantMenu.jsx"
click node_api_entry "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/index.js"
click node_auth_routes "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/auth.route.js"
click node_protected_routes "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/public.route.js"
click node_auth_middleware "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/middleware/auth.middelware.js"
click node_auth_controller "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/auth.controller.js"
click node_public_controller "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/public.controller.js"
click node_restaurant_routes "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/restaurant.route.js"
click node_restaurant_controller "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/restaurant.controller.js"
click node_auth_services "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/utils/auth.service.js"
click node_core_models "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/models/user.model.js"
click node_commerce_models "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/models/order.model.js"
click node_database "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/config/dbConnection.config.js"
click node_media_storage "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/config/cloudinary.config.js"
click node_seed_data "https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/seeders/seed.js"

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_client_entry,node_app_shell,node_public_pages,node_shared_ui,node_auth_context,node_api_config,node_role_dashboards,node_restaurant_menu_ui toneBlue
class node_api_entry,node_auth_routes,node_protected_routes,node_auth_middleware,node_auth_controller,node_public_controller,node_restaurant_routes,node_restaurant_controller,node_auth_services toneAmber
class node_core_models,node_commerce_models,node_database,node_media_storage,node_seed_data toneMint
```

## Components

### React Client

- [Client Entry](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/main.jsx): Vite bootstrap · `client/src/main.jsx`
- [App Shell & Routes](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/App.jsx): React shell · Composes public screens and role-specific routes. · `client/src/App.jsx`
- [Public Ordering Screens](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/pages/OrderNow.jsx): React pages · Home, catalog/order flow, and restaurant details. · `client/src/pages/OrderNow.jsx`
- [Shared UI Chrome](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/components/Navbar.jsx): React components · Navigation, footer, and loading states. · `client/src/components/Navbar.jsx`
- [Auth State](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/context/AuthContext.jsx): React context · `client/src/context/AuthContext.jsx`
- [API Targeting](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/config/ApiConfig.jsx): client config · `client/src/config/ApiConfig.jsx`
- [Role Dashboards](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/pages/dashboard/CustomerDashboard.jsx): React dashboards · Customer, restaurant, rider, and administrator operations. · `client/src/pages/dashboard/CustomerDashboard.jsx`
- [Restaurant Menu Editor](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/client/src/components/restaurantDashboard/RestaurantMenu.jsx): React feature · Menu management and modal item editing. · `client/src/components/restaurantDashboard/RestaurantMenu.jsx`

### Node API

- [API Entry](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/index.js): Express server · Composes public and role route groups. · `server/index.js`
- [Auth Routes](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/auth.route.js): Express routes · `server/src/router/auth.route.js`
- [Role & Public Routes](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/public.route.js): Express routes · Public, customer, restaurant, rider, and admin endpoints. · `server/src/router/public.route.js`
- [Auth Guard](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/middleware/auth.middelware.js): Express middleware · Enforces protected API access. · `server/src/middleware/auth.middelware.js`
- [Auth Controller](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/auth.controller.js): controller · `server/src/controller/auth.controller.js`
- [Public & Common Logic](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/public.controller.js): controllers · Serves common catalog and ordering behavior. · `server/src/controller/public.controller.js`
- [Restaurant Routes](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/router/restaurant.route.js): Express routes · Restaurant-specific management endpoints. · `server/src/router/restaurant.route.js`
- [Restaurant Management](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/controller/restaurant.controller.js): controller · Handles onboarding, profiles, menus, and fulfillment operations. · `server/src/controller/restaurant.controller.js`
- [Credentials & Email](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/utils/auth.service.js): services · Token/credential and email or OTP workflows. · `server/src/utils/auth.service.js`

### Persistence & Integrations

- [Identity & Role Models](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/models/user.model.js): data models · User, customer, restaurant, and rider records. · `server/src/models/user.model.js`
- [Menu & Order Models](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/models/order.model.js): data models · Orders link customer ordering, restaurant fulfillment, and rider delivery. · `server/src/models/order.model.js`
- [Database Connection](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/config/dbConnection.config.js): database integration · `server/src/config/dbConnection.config.js`
- [Cloudinary Media](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/config/cloudinary.config.js): media integration · Stores restaurant and menu imagery. · `server/src/config/cloudinary.config.js`
- [Initial Seed Data](https://github.com/ricrbhopal/cravings_fsd_6-7-8/blob/main/server/src/seeders/seed.js): seeders · Establishes administrative and user data. · `server/src/seeders/seed.js`

## Connections

- Client Entry → App Shell & Routes: mounts
- App Shell & Routes → Public Ordering Screens: routes to
- App Shell & Routes → Role Dashboards: routes by role
- App Shell & Routes → Shared UI Chrome: uses
- Auth State → App Shell & Routes: supplies session
- Public Ordering Screens → API Targeting: uses
- Role Dashboards → API Targeting: uses
- Role Dashboards → Restaurant Menu Editor: includes for restaurants
- API Targeting → API Entry: API requests
- API Entry → Auth Routes: mounts
- API Entry → Role & Public Routes: mounts
- API Entry → Restaurant Routes: mounts
- Auth Routes → Auth Controller: dispatches
- Auth Controller → Credentials & Email: uses
- Auth Controller → Identity & Role Models: reads and writes
- Role & Public Routes → Auth Guard: protects role flows
- Auth Guard → Public & Common Logic: authorizes
- Public & Common Logic → Menu & Order Models: handles orders
- Restaurant Routes → Auth Guard: protects
- Restaurant Routes → Restaurant Management: dispatches
- Restaurant Management → Identity & Role Models: manages restaurant records
- Restaurant Management → Menu & Order Models: manages menus and orders
- Restaurant Management → Cloudinary Media: uploads images
- Identity & Role Models → Database Connection: persists through
- Menu & Order Models → Database Connection: persists through
- Initial Seed Data → Identity & Role Models: initializes
