How ricrbhopal/cravings_fsd_6-7-8 works
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: App.jsx App Shell & Routes · index.js API Entry · restaurant.controller.js Restaurant Management · user.model.js Identity & Role Models
Components 22
React Client
- Client Entry
client/src/main.jsx - App Shell & Routes · Composes public screens and role-specific routes.
client/src/App.jsx - Public Ordering Screens · Home, catalog/order flow, and restaurant details.
client/src/pages/OrderNow.jsx - Shared UI Chrome · Navigation, footer, and loading states.
client/src/components/Navbar.jsx - Auth State
client/src/context/AuthContext.jsx - API Targeting
client/src/config/ApiConfig.jsx - Role Dashboards · Customer, restaurant, rider, and administrator operations.
client/src/pages/dashboard/CustomerDashboard.jsx - Restaurant Menu Editor · Menu management and modal item editing.
client/src/components/restaurantDashboard/RestaurantMenu.jsx
Node API
- API Entry · Composes public and role route groups.
server/index.js - Auth Routes
server/src/router/auth.route.js - Role & Public Routes · Public, customer, restaurant, rider, and admin endpoints.
server/src/router/public.route.js - Auth Guard · Enforces protected API access.
server/src/middleware/auth.middelware.js - Auth Controller
server/src/controller/auth.controller.js - Public & Common Logic · Serves common catalog and ordering behavior.
server/src/controller/public.controller.js - Restaurant Routes · Restaurant-specific management endpoints.
server/src/router/restaurant.route.js - Restaurant Management · Handles onboarding, profiles, menus, and fulfillment operations.
server/src/controller/restaurant.controller.js - Credentials & Email · Token/credential and email or OTP workflows.
server/src/utils/auth.service.js
Persistence & Integrations
- Identity & Role Models · User, customer, restaurant, and rider records.
server/src/models/user.model.js - Menu & Order Models · Orders link customer ordering, restaurant fulfillment, and rider delivery.
server/src/models/order.model.js - Database Connection
server/src/config/dbConnection.config.js - Cloudinary Media · Stores restaurant and menu imagery.
server/src/config/cloudinary.config.js - Initial Seed Data · Establishes administrative and user data.
server/src/seeders/seed.js
Connections 26
- 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