Skip to content

Latest commit

Β 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ Akio β€” Food Ordering System

A full-stack food ordering application: a customer-facing storefront, a role-based admin panel, and secure Razorpay payment integration. Built as a monorepo with an Express 5 API backend and a React 19 + Vite frontend.

The app is currently single-restaurant in practice β€” the schema is shaped for multi-tenancy (restaurant_id on most tables), but the frontend has no restaurant-selection UX; public queries always scope to the one active restaurant.

Live Demo

Hosted on free tiers (Vercel + Render) for demo purposes β€” the backend spins down after inactivity, so the first request after a quiet period can take up to ~50 seconds to wake up.

Screenshots

Home Menu
Home page Menu page
Cart & Bill Summary Checkout (Razorpay)
Cart page Razorpay checkout
Admin Dashboard Admin Ledger
Admin dashboard Admin ledger

Tech Stack

Backend: Node.js, Express 5, PostgreSQL, Redis (optional, ioredis), JWT, Razorpay, Google OAuth, MSG91 (SMS/OTP), Zod, Cloudinary, Pino Frontend: React 19, Vite, Tailwind CSS 4, GSAP, Three.js, Recharts, Sonner, Axios Security: Helmet, CORS whitelist, rate limiting, account lockout, HTTP-only cookies, input sanitization, token blacklist, OTP-gated registration

Project Structure

β”œβ”€β”€ backend/                # Express API server
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/         # Cloudinary, Razorpay, MSG91, DB test config
β”‚   β”‚   β”œβ”€β”€ controllers/    # Auth, Cart, Orders, Payments, Profile, Reviews,
β”‚   β”‚   β”‚                   # Coupons, Ledger, Restaurant, Upload, Admin*, Google auth
β”‚   β”‚   β”œβ”€β”€ db/              # PostgreSQL connection + numbered migrations
β”‚   β”‚   β”œβ”€β”€ middleware/      # Auth, adminAuth (role-gated), Validate, Sanitize,
β”‚   β”‚   β”‚                    # Rate limit, Upload, Error handler, Request ID
β”‚   β”‚   β”œβ”€β”€ routes/          # Customer + Admin API routes
β”‚   β”‚   β”œβ”€β”€ scripts/         # Database seed scripts (e.g. seedAdmin)
β”‚   β”‚   └── utils/           # Validation schemas, token blacklist, login lockout,
β”‚   β”‚                        # OTP store, coupon utils, Redis client, logger
β”‚   └── src/server.js
β”œβ”€β”€ frontend/                # React (Vite) client
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Navbar, Footer, Onboarding, OTP input, Star rating,
β”‚   β”‚   β”‚                    # animated UI (SplitText, MagicBento, AnimatedList,
β”‚   β”‚   β”‚                    # Counter, Aurora background), admin/ layout components
β”‚   β”‚   β”œβ”€β”€ context/         # AuthContext, AdminAuthContext, CartContext
β”‚   β”‚   β”œβ”€β”€ pages/            # Home, Menu, Cart, Orders, Profile, Contact, Login/Register
β”‚   β”‚   β”œβ”€β”€ pages/admin/      # Dashboard, Orders, Menu Items, Categories, Tables,
β”‚   β”‚   β”‚                     # Analytics, Reviews, Ledger, Settings
β”‚   β”‚   └── services/         # API client, Auth, Cart, Menu, Order services
β”‚   └── index.html
└── README.md

Features

Customer Side

  • Registration gated behind SMS OTP verification (MSG91), plus Google sign-in
  • JWT auth via HTTP-only cookies; guided onboarding stepper for new users
  • Browse menu by category with search/autocomplete and veg/non-veg filters
  • Item detail modal, cart with live totals, coupon codes, and discount display
  • Razorpay checkout with signature verification and a success animation
  • Order history, live order status, and order cancellation (restores cart)
  • Post-delivery item reviews & star ratings
  • Profile management and password change
  • SMS notification when an admin marks an order "ready" for pickup
  • Animated, responsive UI (GSAP, Three.js aurora background, mobile dock nav, desktop pill nav)

Admin Side

  • Separate admin authentication (own table, own JWT claim) with role-based access β€” owner / manager / staff, enforced per-route
  • Google sign-in for admin accounts
  • Menu item CRUD, featured-item toggle, availability toggle, category management
  • Restaurant profile & GST settings management
  • Coupon management (owner/manager only)
  • Table management
  • Order management with full status flow (pending β†’ accepted β†’ preparing β†’ ready β†’ completed); cancelling triggers an automatic Razorpay refund
  • Review moderation (view/delete)
  • Financial ledger (owner/manager only)
  • Analytics dashboard: revenue trends, popular items, payment breakdown, revenue calendar, date-filtered stats
  • Image upload via Cloudinary

Security

  • Helmet secure headers, CORS whitelist (frontend origin only), HPP prevention
  • Rate limiting (auth, OTP, and general API limits) with optional Redis-backed store for multi-instance deployments
  • Account lockout after repeated failed logins
  • Zod input validation + XSS input sanitization on every request
  • HTTP-only JWT cookies, separate type: "customer" | "admin" claims, real logout via token blacklist
  • Parameterized SQL queries, bcrypt password hashing, DB transactions for critical operations
  • Generic error responses (no user enumeration), request body size limits, structured request logging
  • Razorpay webhook signature verification
  • Ownership verification on all resource access

API Endpoints

All routes are mounted under /api.

Auth (/api/auth)

  • POST /register/send-otp β€” Validate + send registration OTP (SMS)
  • POST /register/verify-otp β€” Verify OTP and create the account
  • POST /login β€” Login
  • POST /google β€” Google sign-in
  • POST /logout β€” Logout (auth required)

Menu (/api/menu, public)

  • GET /categories β€” All categories
  • GET /items β€” All items (filterable by category)
  • GET /featured β€” Featured items for the home page

Cart (/api/cart, protected)

  • GET / β€” Get cart with item details
  • POST /add β€” Add item (supports food_type_choice)
  • PUT /update β€” Update quantity
  • DELETE /remove/:itemId β€” Remove item
  • DELETE /clear β€” Clear cart

Coupons (/api/coupons, protected)

  • POST /validate β€” Validate a coupon code against the current cart

Orders (/api/orders, protected)

  • POST /place β€” Place order from cart
  • GET / β€” Order history with items
  • GET /:id β€” Order details
  • GET /:id/status β€” Order status
  • POST /:id/cancel β€” Cancel & restore cart

Payments (/api/payments, protected)

  • POST /create-order β€” Create Razorpay order
  • POST /verify β€” Verify payment signature
  • GET /:orderId β€” Payment status
  • POST /refund β€” Refund payment

Profile (/api/profile, protected)

  • GET / β€” Get profile
  • PUT / β€” Update name & phone
  • PUT /password β€” Change password
  • GET /orders β€” Order history with payment details

Reviews (/api/reviews)

  • POST / β€” Create/update a review (auth required)
  • GET /reviewable β€” Items the current user can review (auth required)
  • GET /item/:itemId β€” Reviews for an item (public)

Webhooks (/api/webhooks)

  • POST /razorpay β€” Razorpay payment events

Admin (/api/admin/*, admin auth required)

  • POST /auth/login, POST /auth/google, POST /auth/register (owner only), POST /auth/logout, GET /auth/me
  • GET|PUT /restaurant, POST /restaurant (owner), PUT /restaurant/toggle (owner), GET|PUT /restaurant/gst
  • GET|POST|PUT|DELETE /categories β€” Category CRUD
  • GET|POST|PUT|DELETE /menu-items, PUT /menu-items/:id/featured, PUT /menu-items/:id/availability
  • GET|POST|PUT|DELETE /tables β€” Table management
  • GET|PUT /orders β€” View & update order status
  • GET /analytics β€” Analytics data
  • GET /ledger, GET /ledger/summary β€” Financial ledger (owner/manager only)
  • GET /reviews, DELETE /reviews/:id β€” Review moderation
  • GET|POST|PUT|DELETE /coupons β€” Coupon management (owner/manager only)
  • POST /upload β€” Image upload (Cloudinary)

Setup

Backend

cd backend
npm install
# Copy .env.example to .env and fill in your values
npm run dev

Frontend

cd frontend
npm install
# Copy .env.example to .env and fill in your values
npm run dev

Database

Migrations are plain numbered .sql files with no migration-runner β€” apply manually in order:

psql -U postgres -d akio_db -f backend/src/db/migrations/001_create_users.sql
# ... through the highest-numbered file in backend/src/db/migrations/

All migrations use CREATE TABLE IF NOT EXISTS / ADD COLUMN IF NOT EXISTS, so they're safe to re-run.

Seed Admin

cd backend
node src/scripts/seedAdmin.js

Creates the first admin user from ADMIN_EMAIL / ADMIN_PASSWORD in backend/.env.

Environment Variables

See backend/.env.example and frontend/.env.example for the full list with descriptions. Required:

  • Database credentials (DB_*)
  • JWT_SECRET
  • Razorpay keys (RAZORPAY_*)
  • Cloudinary keys (CLOUDINARY_*)
  • FRONTEND_URL (backend) / VITE_API_URL (frontend)

Optional (each degrades gracefully when unset):

  • REDIS_URL β€” shared rate-limit/lockout/token-blacklist state across multiple backend instances; falls back to in-memory otherwise
  • GOOGLE_CLIENT_ID / VITE_GOOGLE_CLIENT_ID β€” enables Google sign-in for customers and admins
  • MSG91_* β€” sends real OTP/order-ready SMS; without it, OTPs are logged server-side and returned as dev_otp for local dev

Running Locally

Both servers must run simultaneously (separate terminals): backend on PORT from backend/.env (default 5000), frontend via Vite (default 5173). Make sure frontend/.env's VITE_API_URL points at wherever the backend is actually running β€” Vite bakes this in at dev-server startup, so changing it requires restarting the Vite process.

Team

  • Customer side (Backend + Frontend): Nikunj
  • Admin side (Backend + Frontend): Bhavya

Releases

Packages

Contributors

Languages