How avii-ks/foodiegoo works
Project Type and Purpose
• This is a full-stack MERN (MongoDB, Express.js, React.js, Node.js) food-delivery application with two React frontends (Customer App and Admin Panel), a Node/Express REST API backend, a MongoDB database, and Stripe for payments.
• The Customer App lets users browse items, manage carts, place orders (credit/debit card via Stripe or COD), and track order status. The Admin Panel enables restaurant staff to manage menu items, orders, and view analytics in real time.
File Structure
• Top-level directories:
• frontend/ – React customer application
• admin/ – React admin panel
• backend/ – Node.js/Express API server
• backend/ follows an MVC-style organization:
• config/ (db.js)
• models/ (Mongoose schemas)
• controllers/ (business logic)
• routes/ (Express routers)
• middleware/ (auth)
• Configuration and deployment files: .env.example, vercel.json, deploy scripts, start.sh.
• Frontends use Vite as build tool, React Router, Axios, and a Context API for state.
Main Components and Their Roles
• Customer Frontend (React):
• Pages: Home, Menu, Cart, Place Order, My Orders, Verify
• Components: Navbar, FoodDisplay, LoginPopup, etc.
• StoreContext (React Context) to manage cart and user state
• Admin Frontend (React):
• Pages: List, Add, Orders
• Components: Sidebar, Navbar, Tables, Forms
• Backend API (Node/Express):
• Exposes REST endpoints (/api/user, /api/food, /api/order, /api/cart)
• Uses JWT for auth, Stripe SDK for payments, Multer for image uploads
• Connects to MongoDB (via Mongoose) – collections: users, foods, orders
• MongoDB Atlas or local instance – persisting user profiles, cart data, menu items, and orders
• Stripe – external payment processing service
Relationships and Data Flows
• User Browser ↔ Customer React App
• HTTP requests for static assets and bundle from web server (Netlify/Vercel)
• Customer React App → Backend REST API
• Axios POST/GET for authentication, menu retrieval, cart operations, order placement
• Customer React App → Stripe Checkout (redirect or client SDK)
• Admin React App → Backend REST API
• Axios GET/POST to fetch/update food items and orders
• Backend → MongoDB
• Mongoose reads/writes documents
• Backend → Stripe
• Creates payment intent, verifies payment, updates order status
Architectural Patterns and Principles
• Separation of concerns: distinct codebases for customer UI, admin UI, and API
• MVC pattern on the backend with controllers → routes → models
• Stateless REST API with JWT-based authentication
• Real-time-style updates (Admin polls every 10s, can be replaced with WebSockets)
• Client-side state management via React Context in the Customer App
• Deployment via serverless (Vercel for frontends, Render or similar for backend)