This is a simple API to help a restaurant track it's customer's orderss and allow customers make orders easily as well as allow caterers add their meals to menus. The customers are supposed to create accounts which they can use later to view menus or place orders for meals. The Restaurant staff/caterers use priviledged user accounts which allow them to modify, delete some resources. The restaurant should at least have one super user created who will promote users to admin status.
Ensure you have a running python 3.6 virtual environment. See this for instructions on how to set up a virtual envronment. Follow these instructions to setup Book A Meal API
-
Clone this repositor to your computer
$ git clone https://github.com/jmutuku95/book-a-meal.git -
cd to the newly created 'book-a-meal' folder
$ cd book-a-meal -
Install all the requiremnets
$ pip install -r requirements.txt -
Set the following environment variable
export APP_SETTINGS=<Config setting> export FLASK_APP='book_a_meal.py' export DB_URI='postgresql://127.0.0.1:5432/<Database Name>' export SECRET=<Secret Key> export ORDER_EDITS_UPTO=30 export MAIL_USERNAME=<MAil USername> export MAIL_PASSWORD=<Mail Password> export TOKEN_VALIDITY=600 source venv/bin/activate -
Make database migrations: While at project root folder, run the following commands.
$ python manage.py db init$ python manage.py db migrate$ python manage.py db upgrade -
Create super user, while at project root folder
python manage.py db create_super_user -
Run tests to ensure everything os ok:
$ pytest -
Enter the following command in your terminal
$ flask run
This application is build using the following technologies
- Python 3.6
- Flask Microframework
- Dependencies specified in requirements.txt file
- The API has been hosted at Book A Meal API
Ensure you install the above and create a virtual environment with all dependencies. (Refer Getting Started on how to do this.)
You will need a browser too, to be able to view the webpages, I recommend Firefox v. 60
The app UI contains:
- User signup and signin pages.
- A page where the caterer can manage (i.e: add, modify and delete) meal options in the application.
- A page where the caterer can set menu for a specific day by selecting from the meal options available on the system.
- A page where the users can see the menu for a specific day and select an option from the menu.
- A page where the caterer can see the summary of the orders for a specific day and the details for all the orders .
Check out the UI at gh-pages at Book A Meal UI: Book A Meal
Here is a preview of home page
The tests were run on postman and the unittests were run using pytest
Below is a screenshot of postman test
Tests were run on postman, here is an example of the output
STEPS
- Navigate to project root folder book-a-meal
- Run on your terminal, to see all tests pass and see the coverage
$ pytest
NB: All endpoints should be prefixed with /api/v1 For more detailed explanations, see the at BOOK A MEAL DOCS
| EndPoint | Function | METHOD |
|---|---|---|
| /auth/signup | Sign up new users | POST |
| /auth/signin | Sign In users with accounts | POST |
| /users | Get list of all users | GET |
| /users/promote/ | Make user admin | PUT |
| /users/ | Get/delete specific user | GET, DELETE |
| /meals | Add a new meal | POST |
| /meals | Get all meals | GET |
| /meals/<meal_id> | Edit/Delete a meal | PUT, DELETE |
| /menu | Add/Get menu | GET, POST |
| /orders | Add order, view order | GET, POST |
| /orders/<order_id> | Edit/View specific menu | GET/ POST |
The tests also check if user has rights to access the specific endpoint and with what method to ensure integrity is mantained
- Joseph Mutuku Kyalo
Thanks to the following for reviewing the code:
- James Kinyua
- Clement Wekesa
- Sagini Abenga
- Everyone I consulted, Peers at Andela Kenya, Online bloggers and the entire Python and Flask community
Feel free to give suggestions on how to improve the API more.