A simple and clean Node.js backend application for restaurant management, designed for learning AWS deployment. This project provides RESTful APIs for managing menu items and reservations.
- Menu Management: Create and retrieve menu items
- Reservation System: Manage customer reservations
- MySQL Database: Persistent data storage
- RESTful APIs: Clean and simple API design
- Error Handling: Comprehensive error responses
- CORS Enabled: Ready for frontend integration
Before you begin, ensure you have the following installed:
cd backend_newnpm installCreate a .env file in the root directory:
cp .env.example .envEdit the .env file with your MySQL credentials:
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=restaurant_db
DB_PORT=3306
NODE_ENV=developmentLog in to MySQL:
mysql -u root -pRun the schema file:
source schema.sqlOr alternatively, run it directly:
mysql -u root -p < schema.sqlThis will:
- Create the
restaurant_dbdatabase - Create
menuandreservationstables - Insert sample data for testing
npm run devnpm startThe server will start on http://localhost:3000
GET /healthResponse:
{
"success": true,
"message": "Restaurant Backend API is running",
"timestamp": "2025-12-31T11:08:50.000Z",
"uptime": 123.45
}GET /api/menuResponse:
{
"success": true,
"count": 5,
"data": [
{
"id": 1,
"name": "Margherita Pizza",
"description": "Classic pizza with tomato sauce...",
"price": 12.99,
"category": "Main Course",
"image_url": null,
"is_available": true,
"created_at": "2025-12-31T10:00:00.000Z",
"updated_at": "2025-12-31T10:00:00.000Z"
}
]
}GET /api/menu/:idExample: GET /api/menu/1
Response:
{
"success": true,
"data": {
"id": 1,
"name": "Margherita Pizza",
"description": "Classic pizza with tomato sauce...",
"price": 12.99,
"category": "Main Course",
"image_url": null,
"is_available": true
}
}POST /api/menu
Content-Type: application/jsonRequest Body:
{
"name": "Pasta Carbonara",
"description": "Creamy pasta with bacon and parmesan",
"price": 14.99,
"category": "Main Course",
"is_available": true
}Response:
{
"success": true,
"message": "Menu item created successfully",
"data": {
"id": 6,
"name": "Pasta Carbonara",
"description": "Creamy pasta with bacon and parmesan",
"price": 14.99,
"category": "Main Course",
"is_available": true
}
}GET /api/reservationsResponse:
{
"success": true,
"count": 1,
"data": [
{
"id": 1,
"customer_name": "John Doe",
"customer_email": "john.doe@example.com",
"customer_phone": "+1234567890",
"party_size": 4,
"reservation_date": "2025-01-15",
"reservation_time": "19:00:00",
"special_requests": "Window seat preferred",
"status": "confirmed",
"created_at": "2025-12-31T10:00:00.000Z"
}
]
}POST /api/reservations
Content-Type: application/jsonRequest Body:
{
"customer_name": "Jane Smith",
"customer_email": "jane.smith@example.com",
"customer_phone": "+1987654321",
"party_size": 2,
"reservation_date": "2025-01-20",
"reservation_time": "18:30:00",
"special_requests": "Anniversary dinner"
}Response:
{
"success": true,
"message": "Reservation created successfully",
"data": {
"id": 2,
"customer_name": "Jane Smith",
"customer_email": "jane.smith@example.com",
"customer_phone": "+1987654321",
"party_size": 2,
"reservation_date": "2025-01-20",
"reservation_time": "18:30:00",
"special_requests": "Anniversary dinner",
"status": "pending"
}
}# Health check
curl http://localhost:3000/health
# Get all menu items
curl http://localhost:3000/api/menu
# Get specific menu item
curl http://localhost:3000/api/menu/1
# Create menu item
curl -X POST http://localhost:3000/api/menu \
-H "Content-Type: application/json" \
-d '{
"name": "Tiramisu",
"description": "Italian coffee-flavored dessert",
"price": 6.99,
"category": "Dessert"
}'
# Get all reservations
curl http://localhost:3000/api/reservations
# Create reservation
curl -X POST http://localhost:3000/api/reservations \
-H "Content-Type: application/json" \
-d '{
"customer_name": "Alice Johnson",
"customer_email": "alice@example.com",
"customer_phone": "+1122334455",
"party_size": 3,
"reservation_date": "2025-01-25",
"reservation_time": "20:00:00"
}'- Import the API endpoints listed above
- Set the base URL to
http://localhost:3000 - Test each endpoint with sample data
This application is designed to be deployed on AWS. Here are some deployment options:
- Launch an EC2 instance (Ubuntu recommended)
- Install Node.js and MySQL
- Clone the repository
- Configure environment variables
- Run the application with PM2
- Create an Elastic Beanstalk environment for Node.js
- Set up RDS for MySQL database
- Configure environment variables in EB console
- Deploy using EB CLI or ZIP upload
- Create a Dockerfile for the application
- Push to Amazon ECR
- Configure ECS service with RDS
backend_new/
βββ config/
β βββ database.js # MySQL connection configuration
βββ routes/
β βββ menu.js # Menu API routes
β βββ reservations.js # Reservation API routes
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ package.json # Project dependencies
βββ schema.sql # Database schema
βββ server.js # Main application file
βββ README.md # This file
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3000 |
DB_HOST |
MySQL host | localhost |
DB_USER |
MySQL username | root |
DB_PASSWORD |
MySQL password | - |
DB_NAME |
Database name | restaurant_db |
DB_PORT |
MySQL port | 3306 |
NODE_ENV |
Environment | development |
This is a learning project. Feel free to fork and modify as needed!
MIT License - feel free to use this project for learning and development.
This project is created for learning AWS deployment strategies. It provides a simple, clean codebase that's easy to deploy and test on AWS infrastructure.
Happy Coding! π