models #1

Open
sin_serhao wants to merge 2 commits from models into master
7 changed files with 93 additions and 38 deletions
Showing only changes of commit 57714071da - Show all commits

View File

@@ -17,3 +17,8 @@ UML
=== ===
# Entity Relations # Entity Relations
<!-- include: uml/ERD.md --> <!-- include: uml/ERD.md -->
UML
===
# Architecture
<!-- include: uml/architecture.md -->

View File

@@ -4,17 +4,22 @@ config:
layout: elk layout: elk
--- ---
erDiagram erDiagram
User ||--o{ Objectif: objectif UserProfile ||--o{ Objective: objective
User |o--o{ Plan: abonnement UserProfile |o--o{ Subscription: subscription
User |o--o{ RegimeAlimentaire: regime UserProfile |o--o{ Diet: diet
User }o--o{ Allergie: allergies UserProfile }o--o{ Ingredient: allergies
User }o--o{ Exercice: exercices UserProfile ||--|| User: user
Aliment }o--|| Allergie: alergène
Aliment }o--|{ Recette: ingredients Ingredient |o--o{ Diet: diet
Recette }|--|{ RegimeAlimentaire: regime Recipe }|--o{ Ingredient: ingredients
Exercice }|--|{ Equipement: équipement ExercisePlan }|--o{ Exercise: exercises
Exercice }|--|{ BodyPart: partieCorps ExercisePlan ||--o{ User: user
Exercice }|--|{ Muscle: muscle MealPlan }|--o{ Recipe: meals
MealPlan ||--o{ User: user
Exercise |o--o{ Equipement: equipements
Exercise |o--o{ BodyPart: bodyparts
Exercise |o--o{ Muscle: muscles
User{ User{
int id int id
bool is_superuser bool is_superuser
@@ -37,7 +42,7 @@ erDiagram
integer height integer height
string picture string picture
} }
Objectif { Objective{
int id int id
string name string name
string description string description
@@ -62,36 +67,44 @@ erDiagram
int sugars int sugars
int salt int salt
} }
Recette { Recipe{
int Id int id
string Nom string name
int MinutesPreparation int minute_preparation
int MinutesCuisson int minute_preparation
string Resume string summary
string Recette string steps
string ImageUrl string picture
} }
Regime { MealPlan {
int Id int id
string Nom datetime created_date
string Description
} }
Exercice { Diet {
int Id int id
string Nom string name
string GifUrl string description
string Instructions }
Exercise {
int id
string name
string image
string instructions
} }
Equipement { Equipement {
int Id int id
string Nom string name
} }
BodyPart { BodyPart {
int Id int id
string Nom string name
} }
Muscle { Muscle {
int Id int id
string Nom string name
}
ExercisePlan {
int id
datetime created_date
} }
``` ```

View File

@@ -0,0 +1,27 @@
```mermaid +render
architecture-beta
group back(Server)[HealhAI Back]
group api(cloud)[API] in back
group etl(cloud)[ETL] in back
group datavis(cloud)[Data visualisation] in back
service db(database)[Database] in api
service gunicorn(server)[gunicorn] in api
service grafana(cloud)[Grafana] in datavis
service django-admin(cloud)[Django Admin] in datavis
service redis(database)[Redis] in etl
service parser(server)[Parser] in etl
junction parserJunction in etl
junction redisJunction in etl
gunicorn:L -- R:db
parser:B -- T:redis
parser:R --> L:parserJunction
redis:R <-- L:redisJunction
parserJunction:B -- T:redisJunction
grafana:T <-- B:db
django-admin:T -- B:gunicorn
gunicorn:T -- B:redisJunction
```

View File

@@ -78,6 +78,7 @@
presenterm presenterm
yaml-language-server yaml-language-server
mermaid-cli mermaid-cli
pythonSet.python.pkgs.weasyprint
]; ];
}; };
default = pkgs.mkShellNoCC { default = pkgs.mkShellNoCC {

View File

@@ -11,6 +11,7 @@ class UserProfile(models.Model):
weight = models.IntegerField() # in g weight = models.IntegerField() # in g
height = models.IntegerField() # in cm height = models.IntegerField() # in cm
picture = models.ImageField(upload_to="profiles") picture = models.ImageField(upload_to="profiles")
allergies = models.ManyToManyField("Ingredient", related_name="users") allergies = models.ManyToManyField("Ingredient", related_name="users")
diet = models.ForeignKey( diet = models.ForeignKey(
"Diet", on_delete=models.SET_NULL, null=True, blank=True, related_name="users" "Diet", on_delete=models.SET_NULL, null=True, blank=True, related_name="users"
@@ -27,7 +28,7 @@ class UserProfile(models.Model):
# with the date of plan generation. # with the date of plan generation.
class Objectif(models.Model): class Objective(models.Model):
name = models.CharField(max_length=200) name = models.CharField(max_length=200)
description = models.TextField() description = models.TextField()
image_url = models.ImageField("objectives") image_url = models.ImageField("objectives")
@@ -68,19 +69,27 @@ class Ingredient(models.Model):
class Recipe(models.Model): class Recipe(models.Model):
nom = models.CharField(max_length=300) name = models.CharField(max_length=300)
minutes_preparation = models.IntegerField() minutes_preparation = models.IntegerField()
minutes_cuisson = models.IntegerField() minutes_cuisson = models.IntegerField()
summary = models.TextField() summary = models.TextField()
steps = models.TextField() steps = models.TextField()
picture = models.ImageField("recipes") picture = models.ImageField("recipes")
ingredients = models.ManyToManyField(Ingredient, related_name="ingredients")
class ExercisePlan(models.Model): class ExercisePlan(models.Model):
created_date = models.DateTimeField(default=datetime.now, editable=False) created_date = models.DateTimeField(default=datetime.now, editable=False)
exercises = models.ManyToManyField("Exercise", related_name="plans") exercises = models.ManyToManyField("Exercise", related_name="plans")
user = models.ForeignKey( user = models.ForeignKey(
UserProfile, related_name="plans", on_delete=models.CASCADE UserProfile, related_name="exercise_plans", on_delete=models.CASCADE
)
class MealPlan(models.Model):
created_date = models.DateTimeField(default=datetime.now, editable=False)
meals = models.ManyToManyField("Recipe", related_name="plans")
user = models.ForeignKey(
UserProfile, related_name="meal_plans", on_delete=models.CASCADE
) )