This is a simple but realistic Restaurant POS (Point of Sale) web application with:
- Backend: Node.js, Express.js, MongoDB, Mongoose, JWT auth, bcrypt, CORS
- Frontend: React.js, React Router, Axios, Context API
The app provides:
- User registration and login
- POS-style dashboard with live order stats
- Orders page with list, details, status and payment updates
- Order creation form with JSON
orderDetails
backend/– REST API (Node/Express/MongoDB)frontend/– React single-page application
Backend structure:
src/config/db.js– MongoDB connectionsrc/models/User.js– User schemasrc/models/Order.js– Order schemasrc/controllers/auth.controller.js– Register/login logicsrc/controllers/order.controller.js– CRUD for orderssrc/routes/auth.routes.js–/api/auth/*routessrc/routes/order.routes.js–/api/orders/*routes (protected)src/middleware/auth.middleware.js– JWT validationsrc/app.js– Express app, middlewares, routessrc/server.js– Entry point
Frontend structure:
src/context/AuthContext.js– Auth state & API integrationsrc/services/api.js– Axios instancesrc/hooks/useAuth.js– Auth hooksrc/components/Layout/*– Sidebar, Topbar, main layoutsrc/components/Auth/*– Login/Register formssrc/components/Dashboard/*– Stats cards, recent orderssrc/components/Orders/*– Order form, list, detailssrc/pages/*– Page-level components (Login, Register, Dashboard, Orders)
Create a .env file in backend/ with:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/restaurant_pos
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
CORS_ORIGIN=http://localhost:3000Create a .env file in frontend/ with:
REACT_APP_API_URL=http://localhost:5000/apicd backend
npm install
npm run dev # or: npm startThe backend will run on http://localhost:5000.
MongoDB must be running locally (or update MONGODB_URI accordingly).
cd frontend
npm install
npm startThe frontend will run on http://localhost:3000.
- Register a user at
/register(first user can be ADMIN or STAFF). - Login at
/loginto obtain a JWT (handled automatically by the frontend). - After login you are redirected to the Dashboard:
- See stats: Total Orders Today, Pending Orders, Completed Orders, Total Revenue.
- See recent orders in a table.
- Go to Orders:
- Left: list of all orders with badges for status and payment.
- Top-right: create new orders via the Order form.
- Bottom: see full JSON
orderDetailsand update order/payment status.
- All orders are stored in MongoDB and immediately reflected on the dashboard and orders list.
Base URL (backend): http://localhost:5000/api
POST /auth/registerPOST /auth/login
POST /orders– create a new orderGET /orders– list all orders (latest first)GET /orders/:id– get a single orderPATCH /orders/:id– updateorderStatusand/orpaymentStatus
- Passwords are hashed using bcrypt (
bcryptjs). - JWT tokens are signed with
JWT_SECRETand used to protect all order routes. orderDetailsis stored asMixedin MongoDB so you can send any JSON payload.- The UI is designed with a dark sidebar and light content to resemble a real POS dashboard.