How gouravkar007/ai-based-maternal-health-preeclampsia-risk-prediction-system works
Purpose and Entry Points
This repository delivers an educational maternal-health screening product: a Streamlit application performs staged ML risk assessment for preeclampsia, provides guidance, reporting, analytics, and a Gemini-backed chatbot. The public landing page is index.html; the runnable application entry point is AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py.
Deployment Topology
GitHub Pages serves the static landing page, which links users to the separately hosted Streamlit service. Render is the app hosting target and its service definition is in AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/render.yaml. Python 3.11+ is the runtime; primary libraries include Streamlit and scikit-learn, declared through AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/pyproject.toml.
Streamlit Application Shell
The UI orchestration, navigation, patient input forms, emergency checks, dashboard visualizations, prediction presentation, and report-generation flow are centralized in AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py. Streamlit presentation settings are bounded in AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/.streamlit/config.toml. This is a server-rendered interactive Python app, not a separate frontend/API architecture.
Staged Clinical Risk Flow
The primary control flow is:
1. Collect maternal demographic and clinical intake values.
2. Run the general maternal-health classifier.
3. Return low-risk guidance directly, or escalate high-risk results.
4. Collect/use the targeted preeclampsia feature set and run its classifier.
5. Present risk-specific recommendations and optionally generate a downloadable PDF summary.
The two persisted model artifacts are AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/maternal_health_model.pkl and AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/preeclampsia_model.pkl.
Model Serving Boundary
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/loader.py is the model-loading boundary between UI logic and serialized scikit-learn artifacts. The repository contains inference assets only; dataset ingestion, feature engineering, training, evaluation, and model selection are described as upstream work rather than represented as executable source directories. Runtime correctness therefore depends on app-provided features matching each serialized model’s expected preprocessing/schema.
Guidance, Safety, and State
Clinical advice and threshold-style guidance are data-driven through AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/doctor_advice.json, consumed by the app’s result and safety flows. AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/cache.py provides the caching boundary for expensive or repeatable runtime operations, likely including model/resource reuse. Outputs are screening guidance only, with no indicated persistence layer, user account system, or clinical-record integration.
Conversational AI Integration
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/chatbot.py encapsulates chatbot behavior and the external Gemini API integration. This is the principal external runtime dependency beyond deployment hosting: Gemini credentials/network availability affect chat functionality, while core local ML predictions rely on packaged .pkl artifacts.
Main entry points: app.py App Shell & Navigation · loader.py Model Loader · render.yaml Render Service · index.html Landing Page
Components 16
Public Entry
- Landing Page · Public product entry page.
index.html - GitHub Pages
Deployment
- Render Service
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/render.yaml - Python Runtime · Python 3.11+ with Streamlit and scikit-learn.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/pyproject.toml - Streamlit Settings
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/.streamlit/config.toml
Streamlit Screening App
- App Shell & Navigation · Central orchestration for forms, dashboards, results, and reports.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py - Clinical Intake & Safety · Collects maternal values and performs emergency checks.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py - Staged Risk Flow · Routes general-risk results to guidance or targeted screening.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py - Results & PDF Report · Presents recommendations and downloadable summaries.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/app.py - Clinical Guidance · Threshold-style screening guidance and recommendations.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/doctor_advice.json - Runtime Cache · Reuses expensive runtime resources.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/cache.py - Health Chatbot · Encapsulates conversational behavior and API access.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/chatbot.py
Local ML Inference
- Model Loader · Separates UI logic from serialized scikit-learn models.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/loader.py - Maternal Health Model · General maternal-health risk classifier.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/maternal_health_model.pkl - Preeclampsia Model · Targeted preeclampsia risk classifier.
AI-Based-Maternal-Health-Preeclampsia-Risk-Prediction-System/app/models/preeclampsia_model.pkl
Other components
- Gemini API · Chat depends on credentials and network availability.
Connections 15
- GitHub Pages → Landing Page: serves
- Landing Page → Render Service: links to app
- Render Service → App Shell & Navigation: hosts
- Python Runtime → Render Service: defines runtime
- Streamlit Settings → App Shell & Navigation: configures
- App Shell & Navigation → Clinical Intake & Safety: collects inputs
- Clinical Intake & Safety → Staged Risk Flow: clinical features
- Staged Risk Flow → Model Loader: requests inference
- Model Loader → Maternal Health Model: loads general model
- Model Loader → Preeclampsia Model: loads targeted model
- Staged Risk Flow → Results & PDF Report: risk result
- Clinical Guidance → Results & PDF Report: supplies guidance
- Runtime Cache → Model Loader: reuses resources
- App Shell & Navigation → Health Chatbot: opens chat
- Health Chatbot → Gemini API: API requests