How chandrakantamandal/bite-eat works
1. High-level shape
- BiteEat is split into a React/Vite frontend in client/ and an Express/MongoDB backend in server/.
- The browser talks to the API over HTTP, and authenticated requests rely on cookies carrying JWT auth state.
2. Frontend shell and navigation
- The client entrypoint (main.jsx) mounts the app, and AppRoutes.jsx centralizes route selection and protection.
- ProtectedRoute.jsx gates access based on authentication and account type, so the UI can separate normal users from food partners.
- AppLoader.jsx is used as a themed loading state during route transitions and auth checks.
3. Frontend feature boundaries
- src/pages/auth/ contains the complete auth flow: choose role, login/register screens for both account types, plus auth context/hook/service layers.
- src/pages/general/ holds user-facing screens like Home, Saved, and AccountProfile.
- src/pages/food-partner/ holds partner-only screens like CreateFood and Profile, plus a separate context/hook/service stack.
- src/components/ contains reusable UI pieces like ReelFeed and BottomNav, which are part of the main browsing experience.
4. Frontend state/data flow pattern
- The repo uses a consistent layering of service → context → hook → UI for both auth and food features.
- auth.api.js and food.api.js are the network boundaries; they call backend endpoints via Axios.
- auth.context.jsx / FoodContext.jsx store session and feature state, while useAuth.js / useFood.js expose that state to pages and components.
5. User browsing experience
- The core user loop is: fetch food posts, render them in ReelFeed, and allow like/save interactions.
- Home is the main feed entry point, Saved is the saved-items view, and AccountProfile is the shared account management page.
- BottomNav provides the persistent navigation for the user-facing flow.
6. Food partner workflow
- Food partners use CreateFood to publish posts and Profile to manage their account view.
- The partner flow is distinct from the user flow all the way from registration/login screens to routing and context.
- Video creation is the main partner write path; it is not just text content.
7. Backend app structure
- server.js is the runtime entrypoint, while src/app.js configures the Express app.
- src/db/db.js handles MongoDB connection setup.
- Routes are split cleanly by domain: auth.routes.js and food.routes.js, each backed by dedicated controllers.
8. Authentication backend
- auth.controller.js handles registration, login, logout, and me endpoints for both users and food partners.
- The existence of blacklistToken.model.js indicates logout/invalidation is tracked server-side, not just by clearing the client cookie.
- auth.middlerwares.js provides auth protection for endpoints that need a verified session.
9. Food backend
- food.controllers.js powers the feed and interaction APIs: listing posts, creating posts, liking, saving, and fetching partner-specific food items.
- food.model.js is the main content record, likely linking posts to their owner account and to engagement state.
- The route surface matches the feature set exposed by the frontend: browse, interact, and create.
10. Upload and storage boundary
- services/storage.services.js is the external integration point for ImageKit uploads.
- multer is used as the multipart ingestion layer before files are sent to storage.
- This means the create-food flow crosses three layers: frontend upload form, backend upload handling, and third-party media storage.
11. Persistence model
- MongoDB via Mongoose backs the main entities: user.model.js, foodpartner.modle.js, food.model.js, and token blacklist state.
- The backend therefore persists both identity/account data and content/feed data in the same database, but in separate collections.
12. Cross-cutting runtime constraints
- The frontend is developed with Vite and runs on http://localhost:5173.
- The backend is configured for CORS from the Vite origin, and the API runs on http://localhost:3000 by default.
- Environment variables cover MongoDB, JWT, and ImageKit credentials, so those are required infrastructure dependencies for the system to function.
13. What to show in an architecture diagram
- A useful diagram should emphasize four boundaries: client UI, client state/network layer, Express API, and MongoDB/ImageKit.
- The main flows are:
- auth request → JWT cookie/session → protected route rendering
- feed request → food API → MongoDB → ReelFeed
- create-food upload → multer/ImageKit → stored media URL → food document
Main entry points: AppRoutes.jsx Routes · auth.controller.js Auth controller · app.js Express app · auth Auth stack
Components 31
Client
React/Vite frontend with route, state, and feature pages
- App entry · Bootstraps the React app in the browser
client/src/main.jsx - Routes · Central route selection and access control
client/src/routes/AppRoutes.jsx - Protected route · Blocks or allows pages by session and account type
client/src/routes/ProtectedRoute.jsx - App loader · Shared loading view for auth and navigation transitions
client/src/components/AppLoader.jsx - Auth stack · Login and register flows with auth state and network calls
client/src/pages/auth - User pages · Home, saved items, and account profile screens
client/src/pages/general - Partner stack · Food partner create and profile flows with feature state and requests
client/src/pages/food-partner - Reel feed · Renders food posts and engagement actions in the main browsing loop
client/src/components/ReelFeed.jsx - Bottom nav · Persistent navigation for user-facing browsing
client/src/components/BottomNav.jsx - Auth API · Axios boundary for authentication requests
client/src/pages/auth/services/auth.api.js - Auth context · Stores auth session and account identity
client/src/pages/auth/auth.context.jsx - useAuth · Exposes auth state and actions to UI
client/src/pages/auth/hook/useAuth.js - Food API · Axios boundary for feed and create-food requests
client/src/pages/food-partner/services/food.api.js - Food context · Stores partner feature state and food-related data
client/src/pages/food-partner/FoodContext.jsx - useFood · Exposes food feature state and actions to UI
client/src/pages/food-partner/hooks/useFood.js
Server
Express API, controllers, models, and integrations
- Server entry · Starts the API process
server/server.js - Express app · Configures middleware and routes
server/src/app.js - Mongo connect · Initializes the MongoDB connection
server/src/db/db.js - Auth controller · Handles register, login, logout, and me endpoints
server/src/controllers/auth.controller.js - Food controller · Handles listing, creating, liking, saving, and partner food endpoints
server/src/controllers/food.controllers.js - Auth middleware · Verifies protected requests and session state
server/src/middlewares/auth.middlerwares.js - Auth routes · Authentication endpoint surface
server/src/routes/auth.routes.js - Food routes · Feed and creation endpoint surface
server/src/routes/food.routes.js - User model · Stores normal user account data
server/src/models/user.model.js - Partner model · Stores food partner account data
server/src/models/foodpartner.modle.js - Food model · Stores food posts and engagement data
server/src/models/food.model.js - Token blacklist · Tracks invalidated JWT sessions server-side
server/src/models/blacklistToken.model.js - Storage service · Integrates multipart uploads with ImageKit storage
server/src/services/storage.services.js
External
Infrastructure and third-party services
- MongoDB · Persistent backing store for accounts, posts, and token blacklist state
- ImageKit · External media storage and delivery for uploaded food content
- Browser · Client runtime that renders the React app and sends requests
Connections 36
- Browser → App entry: loads · The browser loads the React/Vite application
- App entry → Routes: mounts · App entry mounts the route shell
- Routes → Protected route: guards · Protected routes gate user and partner pages
- Routes → App loader: shows · Route transitions and auth checks can display the loader
- Routes → Auth stack: auth pages · Routes include the login and registration flow
- Routes → User pages: user pages · Routes include user-facing screens
- Routes → Partner stack: partner pages · Routes include food partner screens
- User pages → Reel feed: renders · Home uses the feed UI to display food posts
- User pages → Bottom nav: uses · User pages share persistent navigation
- Auth stack → Auth API: requests · Auth screens call the auth HTTP client
- Auth stack → Auth context: stores · Auth flow writes session state into context
- useAuth → Auth context: reads · The hook exposes auth context to components
- Partner stack → Food API: requests · Partner screens call the food HTTP client
- Partner stack → Food context: stores · Partner flow writes feature state into context
- useFood → Food context: reads · The hook exposes food feature state to components
- Auth API → Auth routes: HTTP · Auth requests go to the backend auth routes
- Food API → Food routes: HTTP · Food requests go to the backend food routes
- Server entry → Express app: starts · Server entry boots the Express app
- Express app → Mongo connect: connects · App startup initializes MongoDB connectivity
- Express app → Auth routes: mounts · Express mounts the auth route set
- Express app → Food routes: mounts · Express mounts the food route set
- Auth routes → Auth controller: delegates · Auth routes are handled by the auth controller
- Food routes → Food controller: delegates · Food routes are handled by the food controller
- Auth controller → Auth middleware: protects · Protected auth flows use session verification
- Auth controller → User model: reads/writes · User login and registration persist account records
- Auth controller → Partner model: reads/writes · Partner login and registration persist partner records
- Auth controller → Token blacklist: invalidates · Logout records revoked tokens server-side
- Food controller → Food model: reads/writes · Food controller manages post and engagement documents
- Food controller → Storage service: uploads · Create-food flow sends media through the storage service
- Storage service → ImageKit: stores media · Uploaded files are stored and delivered via ImageKit
- User model → MongoDB: persists · User accounts are stored in MongoDB
- Partner model → MongoDB: persists · Partner accounts are stored in MongoDB
- Food model → MongoDB: persists · Food posts are stored in MongoDB
- Token blacklist → MongoDB: persists · Blacklisted tokens are stored in MongoDB
- Auth context → Protected route: session state · Protected routing consumes auth session state
- Food context → Reel feed: feed state · Feed and create-food views consume food state