- 🐍Python Django & Django rest framework based
- 🛳 Dockerfile for easy deployment + included packages for Raspberry Pi.
- 👨🍳 Admin panel revamped with jazzmin
- 🤖 Android application source code for the supporters ( find more info in the readme bellow 👇)
- 🔐 Header authentication for easy access management to the API
- 🪶 SQLite database support.
- 🔎 Search endpoint support pagination ( 70 results per page. )
GET /category
- return list ofcategory
object that haspk, name
fields.GET /category/pk/recipes
return list ofrecipe
object.GET /trending
return list of trendingsrecipes
objects.GET /favorites
return list of favorites recipies.PATCH /favorites/<int:recipe_pk>/favorite
- endpoint to favorite and un-favorite recipe.
GET /tags
return list oftag
objects that haspk, name
fieldsGET /tag/pk/recipies
return list of recipe objects with the current tag.POST /api/auth/signup
endpoint to register admin user.Request body must haveusername
,password
strings andis_superuser
boolean that should be set toTrue
📝 Note each recipie object consist of ['pk', 'name', 'category'*, 'serves', 'prep_time', 'tag', 'image', 'video'*, 'ingreadiants', 'instructions']
(* means optional)
📝Note the API path is: {baseUrl}/api/foodie
📝 Note {baseUrl}/api/foodie?search={name}
is the search path as name
is the full name of the recipe or part from it.
📝Note to login in the panel you must register admin user from the /signup
endpoint afterwards the users can be added from the panel.
Username: admin
Password: IamDjango123!
Note📝: CRUD operations are disabled; you cannot add, delete, or update entries from the panel.
- Clone the repo and cd the root folder 📂:
$ git clone https://github.com/mikebgrep/foodie && cd foodie/foodie_be
📝 Skip step 2 if you're not deploying for local use, instead set the env variable in the service secrets vault or add them in the Dockerfile if not available!
- Rename
.env.examle
file to.env
open it and enter values for each variable.- For the
X_AUTH_HEADER
you can add random GUUID. (this will be the authentication secret that will be used for authorization to the API). - For
DJANGO_SECRET
run the following function in terminal and use the output:
- For the
$ python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
You can install the server locally as following this guide:
- Install packages
# We assume current directory is ../foodie/foodie_be
$ python -m venv ../.venv && source ../.venv/bin/activate
$ pip install -r requirements.txt
2.Make the migrations and run the server
$ python manage.py makemigrations && python manage.py migrate && python manage.py runserver
📝 You can access the admin panel from 127.0.0.1:8000/admin
in browser and 127.0.0.1:8000/api/foodie
from Postman or any other client.
Don't forget to add the X-Auth-Header
for each request.
📝 Note for Raspberry pi remove the commented packages 📦 in the Dockerfile.
- Copy ssl pem files in
foodie/nginx/ssl
folder 📂. The file need to be in the folder arefullchain.pem
andprivkey.pem
. - Replace
localhost
value infoodie/foodie_be/foodie.nginx.conf
file with the actual domain name of your host. - Run docker compose up command in the folder where is it
docker-compose.yml
file.
$ docker compose up
or
$ docker-compose up
At this point the container will be build and running.You can access it from domain name from each browser.
4.Register admin user preferably with curl.
Endpoint: POST https://host/api/auth/signup
Payload:
{
"username": "your-username",
"password": "your-password",
"is_superuser": true
}
💡 X-Auth-Header
header should be added to request
Finally you can access the admin panel from https://your-domain-name/admin
in browser and https://your-domain-name/api/foodie
from Postman or any other client.
💡 Don't forget to add the X-Auth-Header
for each request.
You can support the repo as click on the gif bellow 👇 I will share a repo with Android application to the supporters that leave a tip more or equal to 17$) you can take a look of the Android demo in Playstore
The repository use MIT license