Started as my Meta BackEnd Developer Capstone Project - now expanded with containerization.
This is a Django web application for a restaurant named LittleLemon. The application fulfills the following criteria:
- Serves static HTML content using the Django framework
- Connects the backend to a database
- Implements APIs for menu and table booking
- Provides user registration and authentication
- Contains unit tests
- Clone the Repository
git clone https://github.com/mitchcamza/LittleLemon.git
- Make the
setup.shscript in the root directory executable:chmod +x setup.sh
- Run the Script from the Root Directory:
./setup.sh
-
Activate the Existing Virtual Environment:
python -m venv lemon source lemon/bin/activate # (On Windows use `env\Scripts\activate`)
-
Install Dependencies:
pip install -r requirements.txt
-
Database Setup The MySQL database is already configured in the settings.py file. If you need to modify the connection details, you can find the relevant settings in the DATABASES section of settings.py.
-
Apply Database Migrations:
python3 manage.py migrate
-
Run the Development Server:
python3 manage.py runserver
-
Ensure you have Docker and Docker Compose installed.
-
Create the Docker network:
docker network create littlelemon_net
-
Build and start the containers:
docker compose up -d
-
The Django application will be available at http://localhost:8000.
-
To run migrations inside the container:
docker compose exec web python manage.py migrate -
To create a superuser:
docker compose exec web python manage.py createsuperuser -
To stop the containers:
docker compose down
The application contains unit tests that can be run using the Django test runner. To run the tests, use the following command: python manage.py test
The API can also be tested using the Insomnia REST client or other tools.
| Description | Method | Path | Token | Form/JSON payload |
|---|---|---|---|---|
| Load static home page | GET | /restaurant/ | ||
| View menu items | GET | /restaurant/menu/ | ||
| View single menu item | GET | /restaurant/menu/<int:pk> | ||
| Add a menu item | POST | /restaurant/menu/ | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | {"id": 4,"title": "Burger","price": "4.00","inventory": 10 } |
| Update a menu item | PUT | /restaurant/menu/<int:pk> | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | { "id": 3, "title": "Spaghetti Bolognese", "price": "7.00", "inventory": 20} |
| Delete a menu item | DELETE | /restaurant/menu/<int:pk> | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | |
| Obtain authtoken | POST | /restaurant/api-token-auth/ | { "username": "mario", "password": "mariospassword"} | |
| View table bookings | GET | /restaurant/booking/tables | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e |

