Highlights
Project snapshot
- Four-tier RBAC (customer / admin / employee / super-admin) with restaurant-scoped tenant data isolation enforced in code.
- Dual authentication: NextAuth (Google OAuth) layered with a custom edge-compatible JWT verifier, gated in middleware.
- Full operational lifecycle — reservations, Stripe payments, receipt verification, reviews, loyalty points, and audit logging.
Overview
A role-based platform for restaurants and diners
Dine With Foody is a full-stack Next.js 14 application for restaurant discovery, table reservations, reviews, and a points-based loyalty/referral program.
It is built around a multi-tenant model with four distinct roles — customer, restaurant admin, employee, and super-admin — each with its own dashboard and granular permission boundaries. Stripe handles payments, Cloudinary stores imagery, and MongoDB (via Mongoose) backs every domain entity.
Problem
Restaurant operations need scoped, multi-role tooling
- Diners lack one place to discover restaurants, reserve in real time, and be rewarded for loyalty.
- Owners need to manage their venue and staff without seeing other tenants' data.
- A platform operator needs to approve restaurants, manage cities, and audit cross-tenant activity.
- Granular staff permissions (e.g. who may verify receipts) are hard to express in a simple owner/user model.
Solution
Scoped dashboards over a code-enforced tenant model
- A four-tier RBAC model with per-employee permission assignment and restaurant-scoped data isolation.
- Edge middleware resolves the authenticated user and role and gates every protected route group before it runs.
- Stripe, Cloudinary, and SMTP integrated for payments, imagery, and role-targeted notifications.
Core Features
From booking to cross-tenant administration
Diner Experience
- Discovery by city / cuisine / rating
- Time-slot table booking with reservation history
- Ratings and reviews
Loyalty & Payments
- Points ledger with earned/redeemed transactions
- Unique-code referral program
- Stripe Checkout with webhooks and staff receipt verification
Owner & Staff Operations
- Restaurant-scoped management dashboards
- Per-employee permission grants (receipt verification, customer contact, reservations)
- Role-targeted email notifications via SMTP
Platform Administration
- Restaurant approval workflow and city management
- Cross-tenant user management and analytics
- Audit logging of domain actions
Architecture
Next.js App Router with edge-gated, role-aware APIs
Client (Next.js App Router UI)
→ Edge middleware (resolve user + role, gate route groups)
→ API route handlers (role/permission checks)
→ MongoDB via Mongoose
→ Stripe (payments/webhooks) + Cloudinary (images) + Nodemailer/SMTP (email)
- Stripe webhooks write back payment/receipt state; the points ledger and audit log update as side effects of domain actions.
- Domain models cover Users, Restaurants, Reservations, Reviews, Receipts, Points, Referrals, Cities, Applications, Employee Assignments, Notifications, and Audit Logs.
Technical Highlights
Layered auth and tenant isolation enforced at the edge
- Dual authentication: lib/auth.ts tries the NextAuth (Google OAuth, JWT) token first, then falls back to a custom jose-verified JWT so both flows work in middleware.
- Tenant data isolation enforced in authorization helpers, not just convention — admins/employees are scoped to assigned restaurants.
- Zod + React Hook Form on the client with shared server-side validation schemas.
- Pluggable rate limiting with an in-memory store and a documented Redis upgrade path (ioredis/connect-redis present).
Business Value
A production-shaped multi-tenant SaaS
- Covers the full lifecycle from discovery and booking through payment, receipts, reviews, loyalty, and administration.
- Demonstrates the ability to design and secure a non-trivial role hierarchy across real third-party integrations.
- Note: email is sent via Nodemailer over SMTP (verified in code); the project does not use Resend.
