A modern food ordering application built with React for the frontend and Express.js for the backend. Users can browse available meals, add items to their cart, and place orders seamlessly.
- Browse a variety of meals with images and descriptions
- Add meals to cart with quantity management
- View cart summary with total price
- Secure checkout process with customer details validation
- Order submission with confirmation
- Responsive design for mobile and desktop
- React 19
- Vite (build tool)
- Context API for state management
- Custom hooks for HTTP requests
- Node.js
- Express.js
- File-based data storage (JSON files)
- CORS enabled for frontend communication
- Node.js (version 16 or higher)
- npm or yarn
- Navigate to the root directory
- Install dependencies:
npm install
- Start the development server:
The frontend will be available at
npm run dev
http://localhost:5173
- Navigate to the backend directory:
cd backend - Install dependencies:
npm install
- Start the backend server:
The backend will run on
npm start
http://localhost:3000
- Start both frontend and backend servers as described above
- Open your browser and navigate to the frontend URL
- Browse available meals
- Add desired meals to your cart
- Proceed to checkout and fill in your details
- Submit your order
Retrieves all available meals.
Response:
[
{
"id": "1",
"name": "Margherita Pizza",
"price": "12.99",
"description": "A classic pizza with fresh mozzarella, tomatoes, and basil on a thin and crispy crust.",
"image": "margherita-pizza.jpg"
}
]Submits a new order.
Request Body:
{
"order": {
"items": [
{
"id": "1",
"name": "Margherita Pizza",
"price": "12.99",
"quantity": 2
}
],
"customer": {
"email": "john@example.com",
"name": "John Doe",
"street": "123 Main St",
"postal-code": "12345",
"city": "Anytown"
}
}
}Response:
{
"message": "Order created!"
}food-order/
├── backend/
│ ├── app.js # Express server setup
│ ├── package.json
│ ├── data/
│ │ ├── available-meals.json # Meal data
│ │ └── orders.json # Order storage
│ └── public/
│ └── images/ # Meal images
├── src/
│ ├── components/ # React components
│ │ ├── Cart.jsx
│ │ ├── Checkout.jsx
│ │ ├── Meals.jsx
│ │ └── ...
│ ├── store/ # Context providers
│ ├── hooks/ # Custom hooks
│ └── ...
├── package.json
├── vite.config.js
└── README.md
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.