Skip to content

Ashusf90/Pizza-Delivery-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pizza App - Full Stack Application

A complete full-stack pizza ordering application with custom pizza builder, Razorpay payment integration, inventory management, and real-time order tracking.

Features

User Features

  • Complete authentication system (Register, Login, Email Verification, Forgot Password)
  • Interactive custom pizza builder with step-by-step process
  • Real-time order tracking with status updates
  • Razorpay payment integration (Test Mode)
  • Email notifications for order status changes
  • Responsive design with smooth animations

Admin Features

  • Comprehensive dashboard with order statistics
  • Complete inventory management system
  • Real-time stock tracking
  • Low stock alerts via email
  • Order status management (Received β†’ Kitchen β†’ Delivery β†’ Delivered)
  • Analytics and reporting

Tech Stack

Backend

  • Node.js & Express.js
  • MongoDB with Mongoose
  • JWT Authentication
  • Nodemailer for emails
  • Razorpay for payments
  • Node-cron for scheduled tasks

Frontend

  • React 18 with Vite
  • React Router v6
  • Tailwind CSS
  • Framer Motion for animations
  • Axios for API calls
  • React Hot Toast for notifications

Project Structure

pizza-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ db.js                 # MongoDB connection
β”‚   β”‚   └── email.js              # Email configuration
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── auth.js               # Authentication middleware
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js               # User model
β”‚   β”‚   β”œβ”€β”€ Order.js              # Order model
β”‚   β”‚   └── Inventory.js          # Inventory model
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js               # Authentication routes
β”‚   β”‚   β”œβ”€β”€ pizza.js              # Pizza routes
β”‚   β”‚   β”œβ”€β”€ order.js              # Order routes
β”‚   β”‚   β”œβ”€β”€ inventory.js          # Inventory routes
β”‚   β”‚   └── payment.js            # Payment routes
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ emailTemplates.js     # Email HTML templates
β”‚   β”‚   └── stockChecker.js       # Stock monitoring utility
β”‚   β”œβ”€β”€ .env                      # Environment variables
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js                 # Main server file
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/             # Authentication components
β”‚   β”‚   β”‚   β”œβ”€β”€ user/             # User components
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/            # Admin components
β”‚   β”‚   β”‚   └── shared/           # Shared components
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx   # Auth context provider
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── api.js            # Axios configuration
β”‚   β”‚   β”œβ”€β”€ App.jsx               # Main App component
β”‚   β”‚   β”œβ”€β”€ main.jsx              # Entry point
β”‚   β”‚   └── index.css             # Global styles
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
└── README.md

Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or MongoDB Atlas)
  • Gmail account for sending emails
  • Razorpay account (for payment integration)

Step 1: Clone the Repository

# Create project directory
mkdir pizza-app
cd pizza-app

Step 2: Backend Setup

# Navigate to backend directory
cd backend

# Install dependencies
npm install

# Configure environment variables
# Create a .env file and add the following:

.env Configuration:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/pizza-app
JWT_SECRET=your_super_secret_jwt_key_change_this
JWT_EXPIRE=7d

# Gmail Configuration (for sending emails)
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-gmail-app-password
ADMIN_EMAIL=admin@pizzaapp.com

# Razorpay Test Mode Credentials
RAZORPAY_KEY_ID=your_razorpay_test_key_id
RAZORPAY_KEY_SECRET=your_razorpay_test_secret

# Frontend URL
FRONTEND_URL=http://localhost:5173

# Stock Threshold
STOCK_THRESHOLD=20

Important Notes:

  • For Gmail, you need to generate an "App Password" from your Google Account settings
  • Go to: Google Account β†’ Security β†’ 2-Step Verification β†’ App passwords
  • Generate a new app password and use it in EMAIL_PASSWORD

Razorpay Setup:

  1. Sign up at https://razorpay.com/
  2. Go to Settings β†’ API Keys
  3. Generate Test Mode keys
  4. Copy Key ID and Key Secret to .env file

Step 3: MongoDB Setup

Option 1: Local MongoDB

# Install MongoDB locally and start the service
# On Windows:
net start MongoDB

# On Mac:
brew services start mongodb-community

# On Linux:
sudo systemctl start mongodb

Option 2: MongoDB Atlas (Cloud)

  1. Sign up at https://www.mongodb.com/cloud/atlas
  2. Create a free cluster
  3. Get connection string
  4. Update MONGODB_URI in .env file

Step 4: Initialize Database with Sample Data

Create a file backend/seedData.js:

require('dotenv').config();
const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const User = require('./models/User');
const Inventory = require('./models/Inventory');

const connectDB = async () => {
  await mongoose.connect(process.env.MONGODB_URI);
  console.log('MongoDB Connected');
};

const seedData = async () => {
  try {
    await connectDB();

    // Clear existing data
    await User.deleteMany({});
    await Inventory.deleteMany({});

    // Create Admin User
    const admin = await User.create({
      name: 'Admin',
      email: 'admin@pizzaapp.com',
      password: 'admin123',
      role: 'admin',
      isVerified: true,
    });

    // Create Test User
    const user = await User.create({
      name: 'Test User',
      email: 'user@test.com',
      password: 'user123',
      role: 'user',
      isVerified: true,
    });

    // Create Inventory Items
    const inventoryData = [
      // Bases
      { category: 'base', name: 'Thin Crust', quantity: 50, price: 100, threshold: 20 },
      { category: 'base', name: 'Thick Crust', quantity: 50, price: 120, threshold: 20 },
      { category: 'base', name: 'Cheese Burst', quantity: 40, price: 150, threshold: 20 },
      { category: 'base', name: 'Whole Wheat', quantity: 30, price: 130, threshold: 20 },
      { category: 'base', name: 'Gluten Free', quantity: 25, price: 180, threshold: 15 },

      // Sauces
      { category: 'sauce', name: 'Marinara', quantity: 60, price: 30, threshold: 20 },
      { category: 'sauce', name: 'BBQ Sauce', quantity: 55, price: 35, threshold: 20 },
      { category: 'sauce', name: 'Pesto', quantity: 45, price: 40, threshold: 20 },
      { category: 'sauce', name: 'White Sauce', quantity: 50, price: 35, threshold: 20 },
      { category: 'sauce', name: 'Hot Sauce', quantity: 40, price: 30, threshold: 20 },

      // Cheeses
      { category: 'cheese', name: 'Mozzarella', quantity: 70, price: 50, threshold: 25 },
      { category: 'cheese', name: 'Cheddar', quantity: 60, price: 55, threshold: 25 },
      { category: 'cheese', name: 'Parmesan', quantity: 50, price: 60, threshold: 20 },
      { category: 'cheese', name: 'Feta', quantity: 40, price: 65, threshold: 20 },
      { category: 'cheese', name: 'Vegan Cheese', quantity: 35, price: 70, threshold: 15 },

      // Veggies
      { category: 'veggie', name: 'Tomatoes', quantity: 80, price: 20, threshold: 30 },
      { category: 'veggie', name: 'Onions', quantity: 80, price: 15, threshold: 30 },
      { category: 'veggie', name: 'Bell Peppers', quantity: 70, price: 25, threshold: 25 },
      { category: 'veggie', name: 'Mushrooms', quantity: 65, price: 30, threshold: 25 },
      { category: 'veggie', name: 'Olives', quantity: 60, price: 35, threshold: 20 },
      { category: 'veggie', name: 'JalapeΓ±os', quantity: 55, price: 25, threshold: 20 },
      { category: 'veggie', name: 'Corn', quantity: 70, price: 20, threshold: 25 },
      { category: 'veggie', name: 'Spinach', quantity: 50, price: 25, threshold: 20 },

      // Meat
      { category: 'meat', name: 'Pepperoni', quantity: 60, price: 60, threshold: 25 },
      { category: 'meat', name: 'Chicken', quantity: 55, price: 65, threshold: 25 },
      { category: 'meat', name: 'Bacon', quantity: 50, price: 70, threshold: 20 },
      { category: 'meat', name: 'Sausage', quantity: 45, price: 65, threshold: 20 },
      { category: 'meat', name: 'Ham', quantity: 40, price: 60, threshold: 20 },
    ];

    await Inventory.insertMany(inventoryData);

    console.log(' Database seeded successfully!');
    console.log('\n Admin Credentials:');
    console.log('Email: admin@pizzaapp.com');
    console.log('Password: admin123');
    console.log('\n User Credentials:');
    console.log('Email: user@test.com');
    console.log('Password: user123');
    
    process.exit(0);
  } catch (error) {
    console.error('Error seeding database:', error);
    process.exit(1);
  }
};

seedData();

Run the seed script:

node seedData.js

Step 5: Start Backend Server

# Development mode (with nodemon)
npm run dev

# Production mode
npm start

The backend will run on http://localhost:5000

Step 6: Frontend Setup

# Open a new terminal and navigate to frontend directory
cd frontend

# Install dependencies
npm install

# Start development server
npm run dev

The frontend will run on http://localhost:5173

Usage Guide

For Users:

  1. Register Account

  2. Login

    • Use verified email and password
    • You'll be redirected to dashboard
  3. Build Custom Pizza

    • Click "Start Building" button
    • Choose base, sauce, cheese, veggies, and meat
    • Review your pizza and total price
    • Click "Checkout"
  4. Make Payment

    • Click "Pay Now"
    • Razorpay test mode will open
    • Use test card: 4111 1111 1111 1111
    • Any future date and CVV
    • Click "Success" to complete payment
  5. Track Order

    • Go to "My Orders"
    • See real-time status updates
    • Receive email notifications

For Admin:

  1. Login as Admin

  2. View Dashboard

    • See all orders and statistics
    • Monitor order status
    • Update order progress
  3. Manage Inventory

    • Click "Inventory" in navbar
    • Add/Edit/Delete items
    • Monitor stock levels
    • Receive low stock alerts
  4. Update Order Status

    • Click "Move to [Next Status]" button
    • Customer receives email notification
    • Status updates in real-time

πŸ“§ Email Notifications

The system sends emails for:

  • Account verification
  • Password reset
  • Order status updates
  • Low stock alerts (to admin)

πŸ”’ Security Features

  • JWT-based authentication
  • Password hashing with bcrypt
  • Protected API routes
  • Email verification required
  • Admin-only routes
  • Secure payment integration

πŸ› Troubleshooting

MongoDB Connection Error

# Check if MongoDB is running
# Windows:
net start MongoDB

# Mac/Linux:
sudo systemctl status mongodb

Email Not Sending

  • Verify Gmail App Password is correct
  • Enable "Less secure app access" if needed
  • Check EMAIL_USER and EMAIL_PASSWORD in .env

Razorpay Integration Issues

  • Ensure you're using TEST mode keys
  • Check RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET
  • Verify frontend can access the backend

Port Already in Use

# Kill process on port 5000
# Windows:
netstat -ano | findstr :5000
taskkill /PID <PID> /F

# Mac/Linux:
lsof -ti:5000 | xargs kill -9

πŸ“ API Endpoints

Authentication

  • POST /api/auth/register - Register user
  • POST /api/auth/login - Login user
  • POST /api/auth/verify-email/:token - Verify email
  • POST /api/auth/forgot-password - Request password reset
  • POST /api/auth/reset-password/:token - Reset password

Orders

  • POST /api/orders - Create order
  • GET /api/orders/my-orders - Get user orders
  • GET /api/orders - Get all orders (Admin)
  • PUT /api/orders/:id/status - Update order status (Admin)

Inventory

  • GET /api/inventory - Get all inventory
  • GET /api/inventory/available - Get available items
  • POST /api/inventory - Add item (Admin)
  • PUT /api/inventory/:id - Update item (Admin)
  • DELETE /api/inventory/:id - Delete item (Admin)

Payment

  • POST /api/payment/create-order - Create Razorpay order
  • POST /api/payment/verify - Verify payment

🎨 UI Features

  • Smooth animations with Framer Motion
  • Responsive design for all devices
  • Interactive pizza builder
  • Real-time order tracking
  • Beautiful gradient backgrounds
  • Toast notifications
  • Loading states
  • Error handling

πŸš€ Production Deployment

Backend Deployment (Heroku/Railway/Render)

  1. Set environment variables
  2. Update FRONTEND_URL
  3. Deploy backend

Frontend Deployment (Vercel/Netlify)

  1. Build frontend: npm run build
  2. Update API_URL in api.js
  3. Deploy frontend

πŸ“„ License

MIT License - feel free to use this project for learning or commercial purposes.

πŸ‘¨β€πŸ’» Developer

Built with ❀️ using React, Node.js, MongoDB, and Razorpay


Happy Coding! πŸ•

About

Full-stack pizza delivery web application with cart, order management, and responsive UI built using React, Node.js, Express, and MongoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors