FoodApp - Food Ordering Application
A full stack food ordering application built with Next.js and Supabase (PostgreSQL).
Layer
Technology
Frontend
React.js, Next.js
Backend
Next.js API Routes
Database
Supabase (PostgreSQL)
Auth
JWT and bcryptjs
Email
Nodemailer
Styling
Tailwind and Inline CSS
User Authentication - Register, Login, Forgot Password with OTP
Menu Display - Categories, Veg/Non veg indicators, Prices
Time Slot Booking - Color coded availability (Green/Orange/Red)
Order Management - Place orders, View order history
Order Cancellation - Cancel within 15 mins of pickup
Admin Dashboard - Manage orders, Update status, Edit menu
Email Notifications - Welcome email, Order confirmation
Race Condition Handling - PostgreSQL transactions with row locking
Node.js 18+
Supabase account
Gmail account (for email notifications)
Clone the repository
git clone < repository-url>
cd foodapp
Install dependencies
Configure Supabase
Create a new project at supabase.com
Go to Settings > Database > Connection string (URI)
Copy the connection string and add it to .env.local:
DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres
Run database schema
Go to SQL Editor in Supabase Dashboard
Copy and run the contents of database/supabase-schema.sql
Start development server
Open browser
foodapp/
├── app/
│ ├── api/ # API routes
│ │ ├── auth/ # Login, Register, Password reset
│ │ ├── menu/ # Menu CRUD
│ │ ├── orders/ # Orders CRUD
│ │ └── slots/ # Time slots
│ ├── admin/ # Admin dashboard
│ ├── orders/ # User orders page
│ └── page.tsx # Home page
├── components/
│ ├── AuthModal.jsx # Login/Register modal
│ ├── Header.jsx # Navigation
│ ├── Menu.jsx # Menu display
│ └── SlotPicker.jsx # Time slot selection
├── context/
│ └── AuthContext.jsx # Authentication state
├── lib/
│ ├── auth.js # JWT utilities
│ ├── db.js # Supabase PostgreSQL connection
│ └── email.js # Nodemailer setup
└── database/
└── supabase-schema.sql # PostgreSQL schema for Supabase
Slot Availability : Max 10 orders per slot
Cancellation Window : 15 minutes before pickup
Auto Status Update :
15 mins before → "In Making"
2 mins before → "Ready"
Create .env.local:
DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres
JWT_SECRET=your-secret-key
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-password
Command
Description
npm run dev
Start development server
npm start
Start production server
node test-supabase.js
Test Supabase connection