Benjamin Bite is a full-stack canteen ordering platform for students and staff. It provides secure authentication, menu management, cart and checkout, order tracking, and a loyalty points system with tiering and redemption.
- Frontend:
React,TypeScript,React Router,Axios,Bootstrap - Backend:
Node.js,Express,TypeScript,MongoDB,Mongoose - Auth & Security:
JWT,bcryptjs, role-based access middleware - Storage: Supabase Storage (for menu image upload/remove)
- User and admin registration/login with JWT authentication
- Admin-only menu management (create/update/take-down items)
- Cart flow (add, update quantity, remove, checkout)
- Order history and admin order management
- Loyalty system:
- earn points on orders
- expiry handling
- Silver / Gold / Platinum tiers
- redeem points once per order
- Offline demo fallback:
- API can return built-in menu data when MongoDB is unavailable
- offline banner displayed on frontend menu page
BenjaminBite/
backend/
src/
config/
controllers/
data/
middleware/
models/
routes/
scripts/
services/
types/
server.ts
.env.example
package.json
tsconfig.json
frontend/
public/
menu/
logo.png
src/
assets/
components/
pages/
services/
App.tsx
main.tsx
styles.css
types.ts
.env.example
package.json
tsconfig.json
tsconfig.app.json
vite.config.ts
index.html
README.md
- Node.js 18+
- npm
- MongoDB (local or cloud URI)
Copy backend/.env.example to backend/.env and configure:
PORTMONGO_URIJWT_SECRETADMIN_SECRET_KEYFRONTEND_URL
Copy frontend/.env.example to frontend/.env and configure:
VITE_API_URL(example:http://localhost:5000/api)VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYVITE_SUPABASE_BUCKET(example:menu-images)
cd backend
npm installcd frontend
npm installcd backend
npm run devcd frontend
npm run devFrontend URL: http://localhost:5173
Run both builds before pushing/deploying:
cd backend
npm run build
cd ../frontend
npm run buildnpm run dev- start backend in dev modenpm run build- compile backend TypeScriptnpm run start- run compiled backendnpm run seed:menu- seed MongoDB with sample menu entriesnpm run generate:default-menu- regeneratebackend/src/data/defaultMenuItems.tsfromfrontend/public/menu
npm run dev- start Vite dev servernpm run build- build production bundlenpm run preview- preview production build
POST /api/user/registerPOST /api/user/loginGET /api/user/profile/:idPUT /api/user/updateGET /api/user/:userId/points
GET /api/menuGET /api/menu/searchPOST /api/menu(admin only)PUT /api/menu/:id(admin only)
POST /api/cartGET /api/cartPUT /api/cart/:menuItemIdDELETE /api/cart/:menuItemIdPOST /api/cart/checkout
POST /api/ordersGET /api/orders/:userIdGET /api/orders/admin(admin only)PUT /api/orders/:orderId/status(admin only)POST /api/orders/:orderId/redeemGET /api/orders/admin/search(admin only)GET /api/orders/admin/filter(admin only)GET /api/orders/admin/:orderId/history(admin only)
To register an admin account:
- Go to Register page.
- Select role
admin. - Provide the exact
ADMIN_SECRET_KEYfrom backend.env. - Submit and log in normally.
If the key is invalid, admin registration is rejected.
- Create a Supabase project.
- Open Storage and create a bucket (for example
menu-images). - Set frontend env values:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYVITE_SUPABASE_BUCKET
- Use Admin Menu Management page to:
- upload image
- remove image
- take down an item from public menu
When MongoDB is unavailable:
- backend still starts
/api/menuand/api/menu/searchreturn fallback meals fromdefaultMenuItems.ts- frontend displays an offline demo banner on the menu page
Fallback menu items are generated from local images in frontend/public/menu using:
cd backend
npm run generate:default-menu- Passwords are hashed with
bcryptjs - JWT token auth is enforced with middleware
- Admin-only routes are protected by role checks
- Cart totals are computed using menu prices from backend data
- Loyalty expiry and redemption guards are enforced server-side
- Root directory:
backend - Build command:
npm install && npm run build - Start command:
npm run start - Required environment variables:
PORTMONGO_URIJWT_SECRETADMIN_SECRET_KEYFRONTEND_URL(set to your deployed frontend URL)
- Root directory:
frontend - Build command:
npm run build - Publish directory:
dist - Required environment variables:
VITE_API_URL(set to deployed backend URL +/api)VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEYVITE_SUPABASE_BUCKET
- Register/login works
- Menu loads and images render
- Cart checkout creates orders
- Loyalty points update and redemption works
- Admin pages require admin role
# Run from project root
git init
git add .
git commit -m "Initial release: Benjamin Bite full-stack app"
# Add remote and push
git remote add origin <your-repo-url>
git branch -M main
git push -u origin main