Skip to content

Alphasf9/Food-Mesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” FoodMesh

Fresh โ€ข Fast โ€ข Delivered โ€” A full-stack food delivery platform built with microservices architecture

image

๐Ÿ“Œ Overview

FoodMesh is a modern food delivery web application that connects customers with nearby restaurants. It supports three user roles โ€” Customer, Seller (Restaurant Owner), and Rider โ€” each with their own dedicated dashboard and features.


๐Ÿš€ Features

Customer

  • Google OAuth login
  • Browse nearby restaurants using geolocation
  • Search restaurants by name or cuisine
  • View restaurant menus
  • Add items to cart (single restaurant at a time)
  • Checkout with delivery address selection
  • Pay securely via Razorpay
  • Download PDF receipt after payment
  • Manage saved delivery addresses (with interactive map)
  • Cart counter in navbar updates in real time

Seller (Restaurant Owner)

  • Create and manage restaurant profile
  • Upload restaurant images via Cloudinary
  • Toggle restaurant open/closed status
  • Add, edit, delete menu items
  • Toggle menu item availability
  • Restaurant verification system

General

  • JWT-based authentication with role-based access control
  • Automatic token refresh on API calls
  • Location detection using browser Geolocation API + Nominatim reverse geocoding
  • Responsive UI built with TailwindCSS

๐Ÿ› ๏ธ Tech Stack

Frontend

Technology Purpose
React + TypeScript UI framework
Vite Build tool
TailwindCSS Styling
ShadCN UI Component library
React Router v6 Client-side routing
Axios HTTP client
React Leaflet Interactive maps
jsPDF PDF receipt generation
React Hot Toast Notifications
Lucide React Icons

Backend (Microservices)

Service Port Responsibility
Auth Service 8080 Google OAuth, JWT, user management
Restaurant Service 8001 Restaurants, menus, cart, orders, addresses
Utils Service 8002 File uploads (Cloudinary), Razorpay payments

Infrastructure

Technology Purpose
MongoDB + Mongoose Database
RabbitMQ Message queue (payment events)
Cloudinary Image storage
Razorpay Payment gateway
Docker RabbitMQ container

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Frontend (React)                  โ”‚
โ”‚                   localhost:5173                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚              โ”‚              โ”‚
           โ–ผ              โ–ผ              โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Auth Service โ”‚ โ”‚  Restaurant  โ”‚ โ”‚    Utils     โ”‚
โ”‚  Port 8080   โ”‚ โ”‚   Service    โ”‚ โ”‚   Service    โ”‚
โ”‚              โ”‚ โ”‚  Port 8001   โ”‚ โ”‚  Port 8002   โ”‚
โ”‚ - Google     โ”‚ โ”‚              โ”‚ โ”‚              โ”‚
โ”‚   OAuth      โ”‚ โ”‚ - Restaurantsโ”‚ โ”‚ - Cloudinary โ”‚
โ”‚ - JWT tokens โ”‚ โ”‚ - Menus      โ”‚ โ”‚   uploads    โ”‚
โ”‚ - User mgmt  โ”‚ โ”‚ - Cart       โ”‚ โ”‚ - Razorpay   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ - Orders     โ”‚ โ”‚   payments   โ”‚
                 โ”‚ - Addresses  โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
                        โ”‚                โ”‚
                        โ–ผ                โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚         RabbitMQ         โ”‚
                 โ”‚   Payment Event Queue    โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
                        โ–ผ
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ”‚   MongoDB    โ”‚
                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โš™๏ธ Getting Started

Prerequisites

  • Node.js v18+
  • MongoDB (local or Atlas)
  • Docker Desktop (for RabbitMQ)
  • Razorpay account (test mode)
  • Google Cloud Console project (OAuth credentials)
  • Cloudinary account

1. Clone the repository

git clone https://github.com/Alphasf9/Food-Mesh.git
cd foodmesh

2. Start RabbitMQ via Docker

docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

RabbitMQ dashboard โ†’ http://localhost:15672 (guest/guest)


3. Setup Environment Variables

Auth Service (services/auth/.env)

PORT=8080
MONGODB_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

Restaurant Service (services/restaurant/.env)

PORT1=8001
MONGODB_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
RABBITMQ_URL=amqp://guest:guest@localhost:5672
PAYMENT_QUEUE=payment_event
INTERNAL_SERVICE_KEY=your_internal_key
UPLOAD_SERVICE_URL=http://localhost:8002/api/v1/media

Utils Service (services/utils/.env)

PORT2=8002
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxx
RAZORPAY_KEY_SECRET=your_razorpay_secret
RABBITMQ_URL=amqp://guest:guest@localhost:5672
PAYMENT_QUEUE=payment_event
ORDER_API_URL=http://localhost:8001/api/v1/orders
INTERNAL_SERVICE_KEY=your_internal_key

Frontend (frontend/.env)

VITE_API_URL=http://localhost:8080/api/v1/auth
VITE_RESTAURANT_API_URL=http://localhost:8001/api/v1/restaurants
VITE_MENU_API_URL=http://localhost:8001/api/v1/menu
VITE_CART_API_URL=http://localhost:8001/api/v1/cart
VITE_ADDRESS_API_URL=http://localhost:8001/api/v1/address
VITE_ORDER_API_URL=http://localhost:8001/api/v1/orders
VITE_PAYMENT_API_URL=http://localhost:8002/api/v1/payment

4. Install Dependencies & Run

Auth Service

cd services/auth
npm install
npm run dev

Restaurant Service

cd services/restaurant
npm install
npm run dev

Utils Service

cd services/utils
npm install
npm run dev

Frontend

cd frontend
npm install
npm run dev

๐Ÿ“ Project Structure

FoodMesh/
โ”œโ”€โ”€ frontend/                  # React + TypeScript frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/        # Reusable components
โ”‚   โ”‚   โ”œโ”€โ”€ context/           # AppContext (auth, cart, location)
โ”‚   โ”‚   โ”œโ”€โ”€ pages/             # Page components
โ”‚   โ”‚   โ””โ”€โ”€ types/             # TypeScript interfaces
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ””โ”€โ”€ services/
    โ”œโ”€โ”€ auth/                  # Auth microservice
    โ”‚   โ”œโ”€โ”€ src/
    โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
    โ”‚   โ”‚   โ”œโ”€โ”€ middlewares/
    โ”‚   โ”‚   โ”œโ”€โ”€ model/
    โ”‚   โ”‚   โ””โ”€โ”€ routes/
    โ”‚   โ””โ”€โ”€ package.json
    โ”‚
    โ”œโ”€โ”€ restaurant/            # Restaurant microservice
    โ”‚   โ”œโ”€โ”€ src/
    โ”‚   โ”‚   โ”œโ”€โ”€ controllers/
    โ”‚   โ”‚   โ”œโ”€โ”€ middlewares/
    โ”‚   โ”‚   โ”œโ”€โ”€ models/
    โ”‚   โ”‚   โ””โ”€โ”€ routes/
    โ”‚   โ””โ”€โ”€ package.json
    โ”‚
    โ””โ”€โ”€ utils/                 # Utils microservice
        โ”œโ”€โ”€ src/
        โ”‚   โ”œโ”€โ”€ controllers/
        โ”‚   โ”œโ”€โ”€ config/
        โ”‚   โ””โ”€โ”€ routes/
        โ””โ”€โ”€ package.json

๐Ÿ” Authentication Flow

User clicks "Login with Google"
    โ†’ Google OAuth popup opens
    โ†’ User grants permission
    โ†’ Auth code sent to backend
    โ†’ Backend exchanges code for tokens
    โ†’ JWT issued with { id, name, email, role, restaurantId }
    โ†’ Token stored in localStorage
    โ†’ User redirected based on role

๐Ÿ’ณ Payment Flow

Customer clicks "Pay"
    โ†’ Order created in DB (status: pending)
    โ†’ Utils service creates Razorpay order
    โ†’ Razorpay modal opens
    โ†’ Customer pays
    โ†’ Backend verifies payment signature
    โ†’ Message published to RabbitMQ queue
    โ†’ Restaurant service consumes message
    โ†’ Order updated (status: placed, paymentStatus: paid)
    โ†’ Customer redirected to receipt page
    โ†’ PDF receipt available for download

๐Ÿ‘ค User Roles

Role Access
Customer Browse restaurants, order food, manage cart, checkout, view orders
Seller Manage restaurant, menu items, toggle availability, view dashboard
Rider (Coming soon) Accept deliveries, track orders

๐Ÿ—บ๏ธ API Endpoints

Auth Service (8080)

Method Route Description
POST /api/v1/auth/login Google OAuth login
POST /api/v1/auth/logout Logout
GET /api/v1/auth/my-user Get current user
PUT /api/v1/auth/add-role Set user role

Restaurant Service (8001)

Method Route Description
GET /api/v1/restaurants/nearby-restaurants Get nearby restaurants
GET /api/v1/restaurants/my-restaurant Get seller's restaurant
POST /api/v1/restaurants/add-restaurant Create restaurant
PUT /api/v1/restaurants/update-restaurant Update restaurant
PATCH /api/v1/restaurants/update-status Toggle open/closed
DELETE /api/v1/restaurants/delete-restaurant Delete restaurant
GET /api/v1/menu/get-all-menu-items/:id Get menu items
POST /api/v1/menu/add-menu-item Add menu item
PATCH /api/v1/menu/edit-menu-item/:id Edit menu item
DELETE /api/v1/menu/delete-menu-item/:id Delete menu item
PATCH /api/v1/menu/toggle-availability/:id Toggle availability
GET /api/v1/cart/my-cart Get cart
POST /api/v1/cart/add-to-cart Add to cart
PUT /api/v1/cart/increment-cart-item Increase quantity
PUT /api/v1/cart/decrement-cart-item Decrease quantity
DELETE /api/v1/cart/remove-cart-item/:itemId Remove item
DELETE /api/v1/cart/clear-cart Clear cart
POST /api/v1/orders/create-order Create order
GET /api/v1/orders/order-by-payment/:paymentId Get order by payment

Utils Service (8002)

Method Route Description
POST /api/v1/media/upload Upload image to Cloudinary
POST /api/v1/payment/create-razorpay-order Create Razorpay order
POST /api/v1/payment/verify-payment Verify payment signature

๐Ÿงช Testing Payments

Use Razorpay test credentials:

Card Number : 5267 3181 8797 5449
Expiry      : 02/26
CVV         : 123
OTP         : 1234

Or use Net Banking:

Username : success
Password : success

๐Ÿ”ฎ Roadmap

  • Rider service (delivery tracking)
  • Real-time order tracking with Socket.io
  • Push notifications
  • Admin panel (restaurant verification)
  • Reviews and ratings system
  • Order history page
  • Loyalty points system
  • Mobile app (React Native)

๐Ÿ‘จโ€๐Ÿ’ป Author

Haseeb

  • Building FoodMesh as a full-stack microservices project

๐Ÿ“„ License

This project is licensed under the ISC License.


Built with โค๏ธ using React, Node.js, MongoDB, RabbitMQ, and Razorpay

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages