Skip to content

SoftEngMuhammadAli/Foodify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” Foodify - Next Gen Food Delivery Platform

Foodify Banner

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.

License Node React MongoDB Status


πŸ“‘ Table of Contents


πŸš€ Key Features

πŸ” Authentication & Security

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.

πŸ‘€ User Experience (UX)

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.

πŸͺ Restaurant & Menu Management

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.

πŸ“¦ Order Lifecycle & Logistics

A complete end-to-end order processing engine:

  • Granular Tracking: Real-time status updates reflecting the physical world:
    1. Pending (Order received)
    2. Confirmed (Restaurant accepted)
    3. Preparing (Kitchen active)
    4. On the way (Driver picked up)
    5. Delivered (Complete)
    6. 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.

πŸ›  Technology Stack

Frontend (/client)

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: Axios with interceptors for seamless token refreshing.
  • Icons: Lucide React for consistent, lightweight iconography.

Backend (/server)

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-validator and custom middleware for input sanitization.
  • Logging: Custom error handling and console logging for debugging.

πŸ— System Architecture

Foodify follows a decoupled Client-Server Architecture:

  1. Client Layer: A Single Page Application (SPA) built with React that consumes JSON APIs. It handles routing, state management, and view rendering.
  2. API Layer: Express.js REST API that exposes resources via standard HTTP methods (GET, POST, PUT, DELETE). It handles authentication, authorization, and business logic.
  3. Data Layer: MongoDB Atlas cluster stores all persistent data (Users, Restaurants, Orders) in JSON-like documents.
  4. Storage Layer: Cloudinary (integrated) manages media assets like profile pictures and food images.

βš™οΈ Installation & Setup

Follow these steps to set up the project locally.

1. Prerequisites

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

2. Environment Configuration

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:5173

3. Backend Setup

Initialize 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 dev

The server should now be running at http://localhost:3000.

4. Frontend Setup

Initialize the client application.

# Navigate to client directory
cd ../client

# Install dependencies
npm install

# Start the development server
npm run dev

The client should now be running at http://localhost:5173.


πŸ“– API Documentation

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

Major Endpoint Groups

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

πŸ“‚ Project Structure

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

πŸ§ͺ Testing

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.js

Frontend Tests (Coming Soon) - Integration with Vitest and React Testing Library is planned.


πŸ—Ί Roadmap

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.

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.


πŸ“ž Contact

Project Logic Team - GitHub Profile

Project Link: https://github.com/yourusername/Foodify


Built with ❀️ by the Foodify Team

Releases

No releases published

Packages

 
 
 

Contributors

Languages