File size: 2,006 Bytes
96f792c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from pydantic import BaseModel, EmailStr, Field
from typing import Optional, List
from enum import Enum

class UserRole(str, Enum):
    ADMIN = "admin"
    USER = "user"

class UserCreate(BaseModel):
    username: str
    email: EmailStr
    password: str

class UserLogin(BaseModel):
    username: str
    password: str

class UserResponse(BaseModel):
    id: int
    username: str
    email: str
    role: UserRole
    
    class Config:
        from_attributes = True

class Token(BaseModel):
    access_token: str
    token_type: str

class TokenData(BaseModel):
    username: Optional[str] = None
    role: Optional[str] = None

class ProductCreate(BaseModel):
    name: str
    brand: Optional[str] = None
    calories: float
    protein: float
    fat: float
    carbohydrates: float
    sodium: float
    sugar: float
    fiber: Optional[float] = None
    cholesterol: Optional[float] = None
    serving_size: Optional[str] = None

class ProductResponse(BaseModel):
    id: int
    name: str
    brand: Optional[str]
    calories: float
    protein: float
    fat: float
    carbohydrates: float
    sodium: float
    sugar: float
    fiber: Optional[float]
    cholesterol: Optional[float]
    serving_size: Optional[str]
    image_path: Optional[str] = None
    
    class Config:
        from_attributes = True

class HealthIssueCreate(BaseModel):
    issue_type: str = Field(..., description="Type of health issue (e.g., diabetes, hypertension, high cholesterol)")
    severity: Optional[str] = None
    notes: Optional[str] = None

class HealthIssueResponse(BaseModel):
    id: int
    user_id: int
    issue_type: str
    severity: Optional[str]
    notes: Optional[str]
    
    class Config:
        from_attributes = True

class NutritionAnalysisResponse(BaseModel):
    extracted_nutrition: dict
    health_rating: float = Field(..., description="Product rating from 1-10")
    health_recommendations: List[str]
    suggested_alternatives: List[ProductResponse]
    analysis_summary: str