Foodify is a high-performance, enterprise-grade full-stack MERN (MongoDB, Express, React, Node.js) application engineered for the modern food delivery ecosystem. It provides a seamless, low-latency experience for users to discover restaurants, manage carts, and track orders, while offering a comprehensive, data-driven dashboard for administrators to manage the entire platform lifecycle.
- π Key Features
- π Technology Stack
- π System Architecture
- βοΈ Installation & Setup
- π API Documentation
- π Project Structure
- π§ͺ Testing
- πΊ Roadmap
- π€ Contributing
- π License
- π Contact
Security is paramount in Foodify. We employ a multi-layered security approach:
- JWT Architecture: Implements a robust dual-token system (Access & Refresh) for secure, persistent sessions with automatic token rotation.
- Secure Storage: Industry-standard password hashing using
bcryptjs(12 salt rounds) and HTTP-only, SameSite cookies for token storage to mitigate XSS and CSRF attacks. - Role-Based Access Control (RBAC): Granular middleware-protected routes ensuring only authorized users, vendors, or super-admins can access specific resources (e.g.,
authorizeRoles('admin')). - Account Recovery: Secure password reset flow using signed tokens and email integration (Nodemailer).
- Session Management: Secure logout functionality that invalidates refresh tokens.
Designed for speed and usability:
- Dynamic Profile: Personalized dashboard to manage multiple delivery addresses, order history, and profile avatars via Cloudinary integration.
- Smart Search & Filters: High-performance search for restaurants and menu items with debounced inputs and multi-criteria filtering (Cuisine, Price Range, Dietary Preferences).
- Real-time Cart: Persistent cart state managed via Redux Toolkit with instant price calculations, tax estimation, and delivery fee logic.
- Optimistic UI: Instant feedback on cart actions (Add/Remove/Update) to enhance perceived performance.
- Responsive Design: Mobile-first approach using Tailwind CSS 4 to ensure perfect rendering on Phones, Tablets, and Desktops.
Tools for vendors and admins to manage their digital presence:
- Vendor Dashboard: Comprehensive interface for managing restaurant metadata, operating hours, delivery radius, and geolocation.
- Hierarchical Menus: Complex menu structure supporting categories (Appetizers, Mains, Desserts, Drinks), customizable add-ons, and dynamic pricing logic.
- Dietary Tags: Native support for
isVegetarian,isGlutenFree, and Calorie counts to help users make informed choices. - Stock Management: Real-time toggle for dish availability (
isAvailable) to prevent orders for out-of-stock items. - Image Optimization: Automatic resizing and optimization of food images using Cloudinary's transformation API.
A complete end-to-end order processing engine:
- Granular Tracking: Real-time status updates reflecting the physical world:
Pending(Order received)Confirmed(Restaurant accepted)Preparing(Kitchen active)On the way(Driver picked up)Delivered(Complete)Cancelled(With reason)
- Discount Engine: Advanced coupon validation logic supporting percentage-based (
WELCOME50), fixed-amount (SAVE100), and expiry/usage limit checks. - Order History: Detailed breakdown of past orders with "Re-order" functionality for quick repeat purchases.
- Invoicing: Automatic generation of digital receipts containing order breakdowns, taxes, and applied discounts.
The user interface is built for speed and interactivity.
- Framework: React 19 - Utilizing Server Components and Actions.
- Build Tool: Vite - Lightning-fast HMR and optimized builds.
- State Management: Redux Toolkit - Centralized store for auth, cart, and UI state.
- Styling: Tailwind CSS 4 - Utility-first styling engine with zero runtime overhead.
- Routing: React Router 7 - Data loading routers and type-safe navigation.
- API Client:
Axioswith interceptors for seamless token refreshing. - Icons:
Lucide Reactfor consistent, lightweight iconography.
The core logic engine providing a scalable REST API.
- Runtime: Node.js (v18+) - Event-driven JavaScript runtime.
- Framework: Express 5 - Modern web framework with improved error handling.
- Database: MongoDB - NoSQL document database for flexible schema modeling.
- ODM: Mongoose 9 - Strict schema validation and business logic hooks.
- Documentation: Swagger (
swagger-jsdoc&swagger-ui-express) - Interactive API docs. - Validation:
express-validatorand custom middleware for input sanitization. - Logging: Custom error handling and console logging for debugging.
Foodify follows a decoupled Client-Server Architecture:
- Client Layer: A Single Page Application (SPA) built with React that consumes JSON APIs. It handles routing, state management, and view rendering.
- API Layer: Express.js REST API that exposes resources via standard HTTP methods (
GET,POST,PUT,DELETE). It handles authentication, authorization, and business logic. - Data Layer: MongoDB Atlas cluster stores all persistent data (Users, Restaurants, Orders) in JSON-like documents.
- Storage Layer: Cloudinary (integrated) manages media assets like profile pictures and food images.
Follow these steps to set up the project locally.
Ensure you have the following installed on your machine:
- Node.js: v18.0.0 or higher
- MongoDB: Local instance or MongoDB Atlas Cluster connection string
- Git: For version control
- Package Manager: npm (v9+), yarn, or pnpm
You must configure the server environment variables for the app to function.
Create a .env file in the server directory:
# Server Configuration
PORT=3000
NODE_ENV=development
# Database Configuration
# Local: mongodb://127.0.0.1:27017/foodify_db
# Cloud: mongodb+srv://<username>:<password>@cluster.mongodb.net/foodify_db
DATABASE_URL=mongodb://127.0.0.1:27017/foodify_db
# Security (JWT)
# Generate robust secrets using `openssl rand -base64 32`
JWT_ACCESS_SECRET=your_super_secret_access_key
JWT_ACCESS_EXPIRES=15m
JWT_REFRESH_SECRET=your_super_secret_refresh_key
JWT_REFRESH_EXPIRES=7d
# CORS Configuration
FRONTEND_URL=http://localhost:5173
FRONTEND_PRODUCTION_URL=http://localhost:5173Initialize the backend server.
# Navigate to server directory
cd server
# Install dependencies
npm install
# Seed the database (Optional but recommended for testing)
# This creates Admin, Demo User, Restaurants, Menu Items, and Coupons
node seedDatabase.js
# Start the development server (using Nodemon)
npm run devThe server should now be running at
http://localhost:3000.
Initialize the client application.
# Navigate to client directory
cd ../client
# Install dependencies
npm install
# Start the development server
npm run devThe client should now be running at
http://localhost:5173.
Foodify includes fully integrated Swagger/OpenAPI documentation. This allows developers to interact with the API endpoints directly from the browser without needing external tools like Postman.
Access the Docs:
π http://localhost:3000/foodify-web/api-docs
| Group | Description | Key Endpoints |
|---|---|---|
| Auth | User identity management | /auth/register, /auth/login, /auth/refresh-token |
| User | Profile and address management | /user/profile, /address/create-address |
| Restaurants | Vendor listing and details | /restaurants/get-all-restaurants, /restaurants/create-restaurant |
| Menu | Dish management | /menu/:restaurantId, /menu/create |
| Orders | Checkout and tracking | /orders/place-order, /orders/my-orders |
| Cart | Shopping session | /cart/add-to-cart, /cart/get-cart |
| Coupons | Discount logic | /coupons/validate, /coupons/create |
A high-level overview of the codebase structure.
Foodify/
βββ client/ # Frontend Application
β βββ public/ # Static assets (favicons, manifest)
β βββ src/
β β βββ assets/ # Images, fonts, and global CSS
β β βββ components/ # Atomic UI components (Button, Input, Card)
β β βββ features/ # Redux slices (authSlice, cartSlice)
β β βββ hooks/ # Custom hooks (useAuth, useDebounce)
β β βββ layouts/ # Page layouts (Main, Admin, Auth)
β β βββ pages/ # Route views (Home, RestaurantDetails, Cart)
β β βββ services/ # API integration (axios instances)
β β βββ utils/ # Helper functions (currency, dates)
β β βββ main.jsx # Application entry point
β βββ index.html # HTML template
β βββ vite.config.js # Vite configuration
β
βββ server/ # Backend Application
β βββ config/ # Configuration (DB, Swagger)
β βββ controllers/ # Request handlers (Business logic)
β βββ middlewares/ # Interceptors (Auth, Error, Validation)
β βββ models/ # Database schemas (Mongoose)
β βββ routes/ # API route definitions
β βββ scripts/ # Utility scripts (Test, Seed)
β βββ index.js # Server entry point
β βββ swagger.js # Swagger definition
β βββ seedDatabase.js # Data seeder
β
βββ README.md # Documentation
We ensure code quality through rigorous testing.
Backend Tests Currently, we use custom test scripts and Postman collections.
# Run manual test script (if available)
node scripts/test_api.jsFrontend Tests (Coming Soon) - Integration with Vitest and React Testing Library is planned.
Our future plans for Foodify:
- Real-time Notifications: Integration with Socket.io for live order tracking updates.
- Payment Gateway: Integration with Stripe/Razorpay for secure credit card processing.
- Mobile App: Developing a React Native version for iOS and Android.
- AI Recommendations: Personalized food suggestions based on order history.
- Dark Mode: Fully supported dark theme for the frontend.
- Multi-language: i18n support.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Project Logic Team - GitHub Profile
Project Link: https://github.com/yourusername/Foodify
Built with β€οΈ by the Foodify Team