How oriolgalvez/previacare works
Project Type and Purpose
• Monolithic full-stack web application built on Django.
• Provides user authentication and profile management.
• Hosts two prediction services (diabetes risk & heart-disease risk) plus a simple chatbot.
• Renders server-side HTML templates, serves static assets, and exposes form endpoints.
Main Components
a. Client (Web Browser)
– Renders HTML/CSS/JS.
– Interacts via HTTP(S) with Django.
b. Django Web Server (Application Tier)
– URL Router & Views (in previacare/previacare/urls.py + each app’s urls.py & views.py).
– Apps:
• users (authentication, profiles, Google OAuth callback)
• diabetes (form → model inference → results)
• heart_disease (same pattern)
• chatbot (REST endpoints or web sockets for chat interaction)
– Templates (templates/…) and Static File Handler (static/css, js, assets).
– Middleware, Settings (previacare/previacare/settings.py).
c. Database (Data Tier)
– Django ORM models (in each app’s models.py, e.g. CustomUser, PredictionResult).
– Migrations folder per app.
– Backed by SQLite/PostgreSQL (configurable in settings).
d. ML Model Components
– Serialized/Pickled models loaded by the diabetes and heart_disease apps.
– Training artifacts maintained in Jupyter notebooks under each app’s model/ or modelo/ folder.
e. External Services & Dependencies
– Google OAuth2 (used in users/templates/users/google_callback.html).
– Python packages (listed in requirements.txt) such as Django, scikit-learn, pandas, etc.
Relationships & Data Flow
1. Browser → HTTP Request → Django URL Router
2. Router dispatches to appropriate View in one of the apps
3. View may:
• Render a template (GET dashboard, forms)
• Process form data → call ML inference function → save PredictionResult to DB → render results
• Interact with OAuth service (users app) → update user session
• Forward data to/from chatbot logic
4. View ↔ ORM ↔ Database for CRUD
5. ML inference modules (in-memory loaded models) invoked by views
6. Django static files served (directly or via CDN/web server)
Architectural Patterns & Design Principles
• MVC (Django’s MTV) separation: Models (models.py) ↔ Templates (templates/) ↔ Views (views.py)
• Single codebase monolith—no microservices.
• Clear app boundaries: users vs diabetes vs heart_disease vs chatbot
• Reusable components: shared static, shared base.html, common CSS/JS.
• Notebooks are outside runtime path—used for model training only.
Essential Elements
• Labels on every component (“Browser,” “Django Router,” “diabetes.views.predict_diabetes,” etc.)
• If space allows, include sample URLs (e.g., “/diabetes/form”, “/users/google/callback”)