Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitchcamza/littlelemon
Back-End Developer Capstone
https://github.com/mitchcamza/littlelemon
authentication-backend django django-rest-framework json jwt-token model-view-template mysql python3 rest-api routing serialization test-automation testing
Last synced: about 1 month ago
JSON representation
Back-End Developer Capstone
- Host: GitHub
- URL: https://github.com/mitchcamza/littlelemon
- Owner: mitchcamza
- Created: 2023-06-04T11:17:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-16T02:06:24.000Z (3 months ago)
- Last Synced: 2024-10-12T22:55:00.924Z (2 months ago)
- Topics: authentication-backend, django, django-rest-framework, json, jwt-token, model-view-template, mysql, python3, rest-api, routing, serialization, test-automation, testing
- Language: Python
- Homepage:
- Size: 28.2 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LittleLemon Restaurant
(Meta Back-End Developer Capstone Project)## 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 MySQL database
- Implements APIs for menu and table booking
- Set up with user registration and authentication
- Contains unit tests
- The API can be tested with the Insomnia REST client![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()
![alt text]()## Getting the Code
1. Clone the Repository from GitHub
```bash
git clone https://github.com/Meta-Backend-Developer/08-LittleLemon.git
```## Installation and Usage
### Method 1 (Recommended for new users):
1. Make the `setup.sh` script in the root directory executable:
```bash
chmod +x setup.sh
```
2. Run the Script from the Root Directory:
```bash
./setup.sh
```### Method 2: Follow the setup instructions below:
1. Activate the Existing Virtual Environment:
```bash
python -m venv lemon
source lemon/bin/activate # (On Windows use `env\Scripts\activate`)
```2. Install Dependencies:
```bash
pip install -r requirements.txt
```3. 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.4. Apply Database Migrations:
```bash
python3 manage.py migrate
```5. Run the Development Server:
```bash
python3 manage.py runserver
```## Establishing a MySQL connection
Note: the 'django.db.backends.mysql' engine does not work on ARM based machines.
Please install mysql-connector-python using pip or pipenv.
Alternatively, if you are using the mysqlclient connector, you can uncomment the 'django.db.backends.mysql' line in **settings.py** and comment out the line below it, in order to establish a database connection.### Database Credentials
| Username | Password | User Type |
|----------|----------------|---------------|
| meta | password | superuser |
| mario | mariospassword | standard user |## Testing
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.### API endpoints to test
| 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/<> | | |
| Add a menu item | POST | /restaurant/menu/ | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | {"id": 4,"title": "Burger","price": "4.00","inventory": 10 } |
| Update a menu item | PUT | /restaurant/menu/<> | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | { "id": 3, "title": "Spaghetti Bolognese", "price": "7.00", "inventory": 20} |
| Delete a menu item | DELETE | /restaurant/menu/<> | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | |
| Obtain authtoken | POST | /restaurant/api-token-auth/ | | { "username": "mario", "password": "mariospassword"} |
| View table bookings | GET | /restaurant/booking/tables | 2bb2d58fa95e3457d22c028663fbe1ad1e5ca40e | |