A vibrant Django-based web application designed to manage the Little Lemon Restaurant's menus and table bookings.
Ensure you have the following installed on your local machine:
- Python (3.7+ recommended)
- Django (4.2.5 recommended)
- Django REST framework
- MySQL
- Node.js and npm
- React (17.0.0+ recommended)
- Clone the Repository
git clone https://github.com/Waariss/Little_Lemon.git
- Navigate to the Backend Project Directory
cd Little_Lemon/backend
- Install Required Packages
pip install -r requirements.txt
- Configure Database
- Update
settings.py
with your MySQL database credentials.
- Update
- Run Migrations
python manage.py migrate
- Start the Server
python manage.py runserver
- Navigate to the Frontend Project Directory
cd Little_Lemon/frontend
- Install Required Packages
npm install
- Start the React App
npm start
- Access the Application
- Open a browser and navigate to http://localhost:3000.
- List & Create Menu Items
- Endpoint:
/api/menu/
- Methods:
GET
: Retrieve all menus.POST
: Create a new menu item.
- Endpoint:
- List & Create Bookings
- Endpoint:
/api/bookings/
- Methods:
GET
: Retrieve all bookings.POST
: Create a new booking.
- Endpoint:
- Manage Table Bookings
- Endpoint:
/api/bookings/<booking_id>/
- Methods:
GET
: Retrieve a specific booking.PUT
: Update an existing booking.DELETE
: Delete a booking.
- Endpoint:
-
API Calls: Use a library like Axios to make HTTP requests from your React app to your Django API.
Install Axios:
npm install axios
Example API call from React:
import axios from 'axios'; axios.get('http://127.0.0.1:8000/api/menu/') .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching data: ', error); });
-
CORS Headers: Ensure that your Django API can handle requests from your React app by configuring CORS headers using django-cors-headers.
-
Build & Deploy: When you're ready to deploy your application, build your React app and configure Django to serve the static files.
Build React app:
npm run build
Utilize the Insomnia REST Client or a similar tool to test the API endpoints.
This project is licensed under the MIT License