Full-stack canteen ordering app — React + Vite frontend and Express + MongoDB backend.
- User signup / login (hashed passwords with bcrypt)
- Add/update cart stored on user document
- Simple order history + user profile
- React frontend with routing (Vite + Tailwind)
- Frontend: React, Vite, TailwindCSS
- Backend: Node.js, Express, Mongoose (MongoDB)
- Auth: bcrypt for password hashing
-
Clone the repo
-
Install dependencies
# install server deps
cd server
npm install
# install frontend deps
cd ../canteen
npm install- Configure environment for server
Create a .env file inside the server/ folder with at least:
MONGO_URI=<your_mongodb_connection_string>
PORT=2007
- Run the app
# start backend (from server/)
npm run start
# start frontend (from canteen/)
npm run devOpen the frontend URL shown by Vite (usually http://localhost:5173) and ensure the backend is running at the PORT you set.
-
Frontend (in
canteen/):npm run dev— start Vite dev servernpm run build— build production bundlenpm run preview— preview production build
-
Server (in
server/):npm run start— start server withnodemon(auto-restart)
The repository root also contains a package.json with dev dependencies used in the project.
-
POST /signup— create user- body:
{ studentCode, password, name, email, phoneNumber, ... }
- body:
-
POST /login— authenticate- body:
{ studentCode, password }
- body:
-
POST /add-to-cart— push an item into user's cart- body:
{ studentCode, item }whereitemcontainsname,price,image,quantity, etc.
- body:
-
POST /update-cart— replace the user's cart array- body:
{ studentCode, cart }wherecartis an array of cart item objects
- body:
-
GET /user?studentCode=...— fetch user document bystudentCode
Server implementation: server/index.js
-
server/ — Express API and Mongoose models
- server/index.js — server entry and routes
- server/Models/UserModel.js — user schema with
cartandorders - server/Models/Product.js — product schema
-
canteen/ — React frontend (Vite)
- canteen/src/App.jsx — routes and main layout
- canteen/src/main.jsx — entry point
- canteen/src/Components/ — UI components
- Secure your
.envand do not commit secrets. - Consider adding proper authentication (JWT/session) for production instead of only returning user objects on login.
- Validate and sanitize inputs on the backend before saving to the database.
If you want, I can also:
- add example
.env.example - add npm workspace configuration to manage both client and server from root
- improve the README with screenshots and API examples (cURL / Postman)