A complete full-stack food ordering application built with React (frontend), Node.js/Express (backend), MongoDB, and Stripe for payments.
✅ User Features
- User authentication (Register/Login)
- Browse restaurants and menus
- Add items to shopping cart
- Place orders with delivery address
- Secure payment processing with Stripe
- View order history and status tracking
- User profile management
✅ Admin Features
- Create and manage restaurants
- Add/edit menu items
- Update order status
- User and order management
✅ Technical Features
- JWT authentication
- Responsive design
- Context API for state management
- Cart management system
- Real-time order updates
- Secure payment integration
food-ordering-system/
├── backend/
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API routes
│ ├── middleware/ # Auth & validation
│ ├── index.js # Express server
│ ├── seed.js # Database seeding
│ ├── package.json
│ └── .env.example
│
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API calls
│ │ ├── context/ # Context providers
│ │ ├── App.js # Main app
│ │ └── index.js
│ ├── public/
│ ├── package.json
│ └── .env.example
│
└── README.md
- Node.js (v14 or higher)
- npm or yarn
- MongoDB (local or Atlas)
- Stripe account (for payments)
git clone <repository-url>
cd food-ordering-systemNavigate to the backend directory:
cd backend
npm installCreate a .env file with your configuration:
MONGODB_URI=mongodb://localhost:27017/food-ordering
JWT_SECRET=your_jwt_secret_key_change_this
STRIPE_SECRET_KEY=sk_test_your_key
STRIPE_PUBLIC_KEY=pk_test_your_key
PORT=5000
NODE_ENV=developmentInstall MongoDB locally (if not using Atlas):
- Download from https://www.mongodb.com/try/download/community
- Follow installation instructions for your OS
Seed the database with sample data:
node seed.jsStart the backend server:
npm run devThe backend will run on http://localhost:5000
In a new terminal, navigate to the frontend directory:
cd frontend
npm installCreate a .env file:
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_STRIPE_PUBLIC_KEY=pk_test_your_keyStart the React development server:
npm startThe frontend will run on http://localhost:3000
After seeding the database:
Admin Account:
- Email:
admin@foodhub.com - Password:
admin123
Customer Account:
- Email:
customer@example.com - Password:
customer123
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user
GET /api/restaurants- Get all restaurantsGET /api/restaurants/:id- Get restaurant detailsPOST /api/restaurants- Create restaurant (admin)PUT /api/restaurants/:id- Update restaurant (admin)DELETE /api/restaurants/:id- Delete restaurant (admin)
GET /api/menus/restaurant/:restaurantId- Get restaurant menuPOST /api/menus- Add menu item (admin)PUT /api/menus/:id- Update menu item (admin)DELETE /api/menus/:id- Delete menu item (admin)
GET /api/orders- Get user ordersPOST /api/orders- Create orderPUT /api/orders/:id- Update order status (admin)PUT /api/orders/:id/cancel- Cancel order
POST /api/payments/create-payment-intent- Create Stripe payment intentPOST /api/payments/confirm-payment- Confirm payment
GET /api/users/profile- Get user profilePUT /api/users/profile- Update profilePOST /api/users/address- Add delivery address
Backend:
- Express.js
- MongoDB with Mongoose
- JWT for authentication
- bcryptjs for password hashing
- Stripe API
- CORS middleware
Frontend:
- React.js
- React Router v6
- Context API for state management
- Axios for HTTP requests
- Stripe.js for payments
- CSS for styling
- Browse - User browses restaurants on homepage
- Select - Click restaurant to see menu items
- Add to Cart - Add items to shopping cart
- Checkout - Proceed to checkout page
- Enter Address - Provide delivery address
- Pay - Complete payment via Stripe or choose cash
- Track - View order status in order history
Copy .env.example to .env and update with your actual values:
Backend .env:
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key
STRIPE_SECRET_KEY=your_stripe_secret
STRIPE_PUBLIC_KEY=your_stripe_public_key
PORT=5000
NODE_ENV=development
Frontend .env:
REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_STRIPE_PUBLIC_KEY=your_stripe_public_key
Terminal 1 (Backend):
cd backend
npm run devTerminal 2 (Frontend):
cd frontend
npm startVisit http://localhost:3000 in your browser.
- Backend logs API requests and database connections
- Frontend uses React DevTools for component inspection
- Stripe test cards:
- Visa:
4242 4242 4242 4242 - Expiry: Any future date
- CVC: Any 3 digits
- Visa:
- 🗺️ Real-time order tracking with maps
- ⭐ Rate and review system
- 🔔 Push notifications
- 💬 Chat support
- 📊 Admin analytics dashboard
- 🎯 Promotions and coupons
- 📱 Mobile app (React Native)
MongoDB Connection Error:
- Ensure MongoDB is running locally or check Atlas connection string
CORS Error:
- Verify
proxyin frontend package.json points to backend
Payment Not Working:
- Check Stripe keys are correct in
.envfiles - Use Stripe test mode keys
Port Already in Use:
- Backend: Change PORT in
.env - Frontend:
PORT=3001 npm start
MIT License - feel free to use for personal or commercial projects
For issues or questions, please create an issue in the repository.