How charan545/medicalsupplydistributionproject works
Project Type and Purpose
• This is a monolithic, full-stack web application built with Django (Python) that optimizes the distribution of medical supplies.
• The “optimizer” Django app contains the core models, optimization logic, views, serializers, static assets and templates.
• The top-level “medical_supply_distribution” directory holds global settings, URL routing, WSGI/ASGI entry points and project configuration.
File Structure Analysis
• Top-level files:
• manage.py – Django CLI entry point
• db.sqlite3 – development database
• requirements.txt – Python dependencies (Django, Pandas, NumPy, Matplotlib/Seaborn, etc.)
• package.json – JS tooling (if any)
• Top-level directory “medical_supply_distribution”:
• settings.py, urls.py, wsgi.py, asgi.py – global configuration and URL routing.
• App directory “optimizer”:
• models.py – ORM definitions (Supply, Hospital, Distribution, etc.)
• migrations/ – database schema migrations
• views.py & urls.py – HTTP handlers and URL endpoints
• serializers.py – REST serialization (if exposing JSON endpoints)
• optimizer_logic.py – core mathematical optimization routines (Pandas/NumPy)
• utils.py – helper functions
• static/ – CSS, JS, images for frontend UX
• templates/ – HTML templates for MVT pattern
• No separate “frontend” service; templates and static files served by the Django backend.
Key Insights from README
• Tech stack: Python, Pandas, NumPy, Matplotlib/Seaborn, Django.
• Features: Supply tracking, route optimization, data visualization.
Main Components
a. Client Browser (User Interface)
• Renders HTML templates, CSS, JS
• Initiates HTTP(S) requests (form submits, AJAX calls for optimize)
b. Django Web Server (Application Backend)
• HTTP Server (Django’s runserver or WSGI/ASGI host)
• URL Dispatcher → Views
• Views → Serializer (for JSON) or Context (for templates)
• ORM (Models) → SQLite Database
• Core module: optimizer_logic.py
c. Database
• SQLite for development; houses supply, hospital, distribution data
d. External Libraries
• Pandas/NumPy for data processing
• Matplotlib/Seaborn for generating charts/plots
e. Static Asset Server
• Serves CSS, JS, images from optimizer/static
f. (Optional) External Services
Relationships & Data Flow
1. User browses to a URL → HTTP GET to Django server.
2. URL router maps to optimizer.views.home (or optimize endpoint).
3. View loads data via models (ORM) from SQLite.
4. If optimization endpoint:
– View calls optimizer_logic.run(...)
– optimizer_logic uses Pandas, NumPy, SciPy (if used)
– Returns optimized routes, allocation results
5. View serializes results (via serializers.py or context) and passes to template.
6. Django template engine renders HTML with embedded data.
7. Static JS fetches data (AJAX) or handles UI interactions for charts.
Architectural Patterns & Design Principles
• Django’s MVT (Model-View-Template) pattern
• Separation of concerns:
• Data layer (models, migrations)
• Business logic (optimizer_logic.py, utils.py)
• Presentation layer (templates, static assets)
• API layer (serializers, views returning JSON)
• Modular app structure: one “optimizer” app within the project