A full-stack restaurant ordering web application with user authentication, authorization, and order management.
- Backend: Node.js + Express.js
- Database: MongoDB + Mongoose
- Frontend: Pug (templating engine) + JavaScript (client-side)
- Authentication: Session-based with bcrypt password hashing
- Session Management: express-session (stored in DB)
- User registration with password hashing
- Secure login with session management
- Authorization checks on protected routes (/order, /users/:id/privacy)
- 401 Unauthorized responses for unauthenticated requests
- Public user directory with search functionality
- User profiles with order history
- Privacy toggle to make profiles private/public
- Profile privacy enforcement
- RESTful API endpoints for restaurants
/api/restaurants- List all restaurants (without menu data)/api/restaurants/:id- Get full restaurant details with menu- Dynamic menu loading from server
- Support for menu categories and items
- Dynamic order interface that loads restaurants from server
- Add/remove items from order
- Real-time order total calculation (subtotal, tax, delivery fee)
- Order submission with validation
- Order history tracking per user
- Order detail page with privacy controls
- Express-session for user sessions
- Session persistence across requests
- Automatic logout functionality
- Session user accessible in all templates via res.locals
- Node.js installed
- MongoDB running locally (default: mongodb://127.0.0.1:27017/restaurantDB)
- Install dependencies:
npm install- Start MongoDB (if not already running):
mongod- Seed the database with initial data:
node database-initializer.jsThis will:
- Clear the existing database
- Create 10 test users (passwords = usernames)
- Create 3 restaurants with menu items
- Start the server:
npm startor directly:
node server.js