How myousafmalik/fettler-be works
Project Type and Purpose
• Project Type: Backend API service built with Django and Django REST Framework.
• Purpose: Serve account management, diet/exercise request processing, and personalized recommendations (including an ML inference component using a YOLOv8 model).
High-Level Architecture Components
a. API Gateway / Reverse Proxy
• Nginx or similar handling SSL, static files, request routing.
b. WSGI Server
• Gunicorn/Uvicorn hosting Django’s ASGI/WSGI application.
c. Django Application
• Core config module (config/)
• Three Django apps:
– account (authentication, user profiles, serializers & views under account/)
– requests (end-user diet/exercise requests workflow)
– recommend (recommendation engine, includes ML model inference)
• Utilities:
– utils/misc.py, utils/views/Misc.py
– Excel asset (utils/diets.xlsx)
d. ML Inference Subsystem
• recommend/utils/predict_type.py loading assets/yolov8n.pt
• Could be represented as a separate microservice or internal library.
e. Database
• SQLite (db.sqlite3) in development; can be replaced by PostgreSQL/MySQL in production.
f. External Interfaces
• Frontend client or mobile app (consuming REST endpoints)
• Postman collection (Fettler++.postman_collection.json)
• Potential third-party services (email/SMS, cloud storage)
Relationships & Data Flow
• The client sends HTTP requests → Nginx → Gunicorn/Uvicorn → Django entry point (config/asgi.py or wsgi.py).
• URL routing (config/urls.py) dispatches to app-specific urls.py.
• View logic (in account/views, requests/views, recommend/views) invokes:
• Serializers (validate/transform input)
• Models (ORM reads/writes to database)
• ML inference (recommend/utils) when generating recommendations.
• Responses flow back up the chain to the client.
Architectural Patterns & Principles
• MTV (Model-Template-View) pattern, adapted as API (templates unused).
• Separation of concerns per app:
• account → auth & user data
• requests → business workflow
• recommend → ML & domain logic
• Single database backing all apps.
• Potential to extract ML inference into a microservice for scalability.
Final Checklist
– Green for user-facing components.
– Orange for core Django apps.
– Purple for ML inference.
– Blue for data stores.
• Version note: “DB = SQLite (dev) → PostgreSQL (prod)”.
• Filename of Postman collection as “API contract”.