MyFridge is a simple rest API implemented with Django REST Framework and MongoDB thought for those people who never know what to cook, like me :)
- Sign up
- Sign in
- Access and update their user detail
- Complete their profile
- Upload their fridge ingredients
- Create, read, update and delete ingredients
- Create, read, update and delete recipes
- And, the main thing, is that they can consult the recipes that they can make with their fridge's ingredients.
-
Must have Python 3 & MongoDB (Community Server) installed and running. If you don´t here is the MongoDB Install Guide, to install mongo locally.
-
Clone this repository and access it through the command line.
-
Create a virtual environment:
python -m venv venv
-
Go into your virtual environment:
source venv/bin/activate
(orvenv/Scripts/activate
in Windows) -
Install dependencies:
pip install -r requirements.txt
-
Setup Database (in the mongo shell)
- Create the database:
use my-fridge;
- Create DB user with privilages on all dbs: db.createUser( { user: "my-fridge-admin", pwd: "password", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
- Create the database:
-
Run migrations:
python manage.py migrate
-
Create an admin user for logging into the Django admin interface:
python manage.py createsuperuser
-
Run the app:
python manage.py runserver
-
You can access the admin interface at
localhost:8000/admin
-
User
- username
- is_active
- is_admin
- password
-
Profile
- user (OneToOne)
- picture
- first_name
- last_name
- biography
-
Fridge
- owner (User OneToOne)
- ingredients (ManyToMany)
-
Ingredient
- name
- slug_name
- created_by (User FoeringKey)
- picture
- description
- is_veggie
- is_vegan
-
Recipe
- name
- slug_name
- created_by (User FoeringKey)
- picture
- description
- instructions
- ingredients (ManyToMany)
- is_veggie
- is_vegan
/users/signup/
- post
/users/login/
- post
/users/:username/
- get (User Detail is also the way to check user's profile and fridge content)
- put
- patch
/users/:username/profile/
- put
- patch
/users/:username/fridge/
- patch
example get User Detail response:
{
"id": 47,
"email": "[email protected]",
"username": "nsterroni",
"is_admin": false,
"is_verified": false,
"is_active": true,
"profile": {
"picture": null,
"first_name": "Nicolas",
"last_name": "Terroni",
"biography": "Thanks for visiting!"
},
"fridge": {
"ingredients": [
41,
40
]
}
}
/ingredients/
- post
- get
/ingredients/:slug_name/
- get
- put
- patch
- delete
/recipes/
- post
- get
/recipes/:slug_name/
- get
- put
- patch
- delete
recipes/possible_recipes/
- get (List recipes that contain user's fridge ingredients.)
recipes/my_recipes/
- get (List recipes created by the requesting user.)