This is a full-stack Food Ordering Web Application built as part of the Slooze Take-Home Assignment.
It allows users (Admin, Managers, and Team Members) to browse restaurants and menus, create and manage orders, and handle payments β all with Role-Based Access Control (RBAC) and country-based data segregation.
Nick Fury is a business owner with 5 employees:
| Name | Role | Country |
|---|---|---|
| Nick Fury | Admin | Global |
| Captain Marvel | Manager | India |
| Captain America | Manager | America |
| Thanos | Member | India |
| Thor | Member | India |
| Travis | Member | America |
Nick wants a web-based food ordering application with the following functionalities:
| Function | Admin | Manager | Member |
|---|---|---|---|
| View restaurants & menu items | β | β | β |
| Create order (add food items) | β | β | β |
| Place order (checkout & pay) | β | β | β |
| Cancel order | β | β | β |
| Update payment method | β | β | β |
Additional rules:
- Managers and Members can only access data from their own country (India or America).
- Admin has global access.
- Node.js / Express
- TypeScript
- MongoDB / Mongoose
- JWT Authentication
- RBAC Middleware
- Next.js 16
- React 19
- Tailwind CSS
- Axios for API integration
- ShadCN UI
β Authentication & RBAC
- JWT-based login with role validation middleware
- Role-based and country-based authorization
β Restaurants & Menu
- View restaurants and their menu items
- Filter access by country
β Orders & Cart
- Create and manage orders
- Add food items to cart
- Checkout and payment simulation (Admin/Manager only)
- Cancel orders (Admin/Manager only)
β Payment Management
- Admin can add or update payment methods
β Data Isolation
- Managers and Members can only access data from their assigned country
Flow:
Frontend (Next.js)
β
API Gateway (Express + JWT)
β
RBAC Middleware (role + country check)
β
MongoDB (Users, Restaurants, Orders, Cart, Payment)
| Route | Admin | Manager | Member | Description |
|---|---|---|---|---|
| GET /restaurants | β | β | β | View all restaurants |
| GET /menu/:id | β | β | β | View menu items |
| POST /cart/add | β | β | β | Add food items to cart |
| POST /order/checkout | β | β | β | Checkout and pay |
| POST /order/cancel/:id | β | β | β | Cancel an order |
| PATCH /payment-method | β | β | β | Update payment method |
git clone https://github.com/rupesh-dev30/Slooze-Full-Stack-Assessment.git
cd Slooze-Full-Stack-Assessmentcd backend
npm installCreate a .env file inside backend/:
PORT=9001
MONGO_URI=<YOUR_MONGO_DB_URL>
JWT_SECRET=<YOUR_JWT_SECRET>
COOKIE_NAME=token
NODE_ENV=developmentRun the seed file to insert initial users and data:
# If tsx is not installed globally
npm install -g tsx
# Then run seed
tsx src/database/seed.tsStart the server:
npm run devcd ../frontend
npm install
npm run devOpen π http://localhost:3000
| Name | Password | Role | Country | |
|---|---|---|---|---|
| Nick Fury | nick@avengers.com |
password123 |
Admin | America |
| Captain Marvel | cm@company.com |
password123 |
Manager | India |
| Captain America | ca@company.com |
password123 |
Manager | America |
| Thanos | thanos@company.com |
password123 |
Member | India |
| Thor | thor@company.com |
password123 |
Member | India |
| Travis | travis@company.com |
password123 |
Member | America |
POST /api/auth/registerβ Register a new userPOST /api/auth/loginβ Login and get JWT token in cookiesPOST /api/auth/logoutβ Logout userGET /api/auth/meβ Get current logged-in user info
GET /api/restaurantsβ Get all restaurantsGET /api/restaurants/:id/menuβ Get menu items
GET /api/cartβ Get user cartPOST /api/cartβ Add itemPUT /api/cartβ Update quantityDELETE /api/cart/:menuItemIdβ Remove itemDELETE /api/cartβ Clear entire cart
POST /api/ordersβ Create new orderGET /api/ordersβ List orders (filtered by role/country)POST /api/orders/:id/checkoutβ Checkout & payPOST /api/orders/:id/cancelβ Cancel orderGET /api/orders/:idβ Get single order details
GET /api/paymentsβ List payment methodsPOST /api/paymentsβ Create payment methodPUT /api/payments/:idβ Update payment method (Admin only)
authMiddleware:
- Checks JWT token in cookies
- Verifies user and attaches to
req.user - Returns 401 if unauthorized
permit(...roles):
- Restricts access to certain roles
- Example:
permit("ADMIN", "MANAGER")
restrictByCountry(getResourceCountry):
- Blocks users from accessing another countryβs data
- Admin bypasses this check
Your seed script automatically creates:
- 6 users (Admin, Managers, Members)
- Sample restaurants for India and America
- Menu items for each restaurant
π¬ Watch the demo video here:
| Login | Restaurants | Cart | Orders |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| Restaurants-Details | Payment | Profile |
|---|---|---|
![]() |
![]() |
![]() |
- β Role-based Access Control (RBAC)
- β Country-based data filtering
- β JWT Auth with cookie storage
- β Seed script for auto data setup
- β Payment management system
Rupesh Kumar π GitHub
This project is open-sourced under the MIT License.






