# riddhimanpuzari-88/maternal_risk_detector architecture

> Architecture diagram of the GitHub repository riddhimanpuzari-88/maternal_risk_detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/riddhimanpuzari-88/maternal_risk_detector
- Repository: https://github.com/riddhimanpuzari-88/maternal_risk_detector

## Overview

1. **What this repo is**
   - This is a small **Python machine-learning inference app** for **maternal risk detection**.
   - The public deployment is a **Streamlit** app, so the repository is likely focused on **serving predictions**, not on training a model in production.

2. **Primary runtime entry point**
   - `app.py` is the main application file.
   - Architecturally, this is the **presentation + inference layer**: it likely builds the UI, collects user inputs, prepares a feature vector, and calls the trained model to produce a risk prediction.

3. **Model artifact boundary**
   - `model.joblib` is the serialized trained model.
   - This file represents the **core prediction engine** and is separated from the app code, which means the repo cleanly divides **model serving** from **model training**.

4. **Feature schema artifact**
   - `feature_names.joblib` is a second serialized artifact used to keep the input schema consistent.
   - Its presence suggests the app must **match user-entered values to the exact feature order/names** expected by the model, which is important for reliable inference.

5. **Data source / training context**
   - `Dataset - Updated.csv` is most likely the dataset used for training, validation, or analysis.
   - It is probably **not required for runtime predictions** unless the app includes exploratory display or retraining logic, but it is part of the repository’s model-development lineage.

6. **Request-to-prediction flow**
   - A user opens the Streamlit app.
   - `app.py` renders input controls for maternal-health-related attributes.
   - The app maps those inputs into the model’s expected feature set using `feature_names.joblib`.
   - The prepared data is passed into `model.joblib`.
   - The model returns a risk class or score, which Streamlit displays in the UI.

7. **System boundaries**
   - There is no sign of a separate backend service, database, message queue, or API layer.
   - The architecture appears to be a **single-process app**: UI and inference live together in one Python runtime.

8. **Deployment model**
   - The README links to a **Streamlit Cloud** deployment, so the app is meant to be hosted as a lightweight interactive ML demo.
   - That deployment style reinforces that the repo is intended for **direct browser interaction** with a local model artifact, not remote model serving.

9. **Dependency stack**
   - `requirements.txt` likely pins Streamlit and ML/data libraries such as `pandas`, `numpy`, and `joblib`/`scikit-learn`.
   - These dependencies shape the architecture as a **Python notebook-to-app style ML project** rather than a full backend/frontend split.

10. **Practical diagram takeaway**
   - The main boxes to draw are:
     - **Browser / user**
     - **Streamlit app (`app.py`)**
     - **Serialized model (`model.joblib`)**
     - **Feature schema (`feature_names.joblib`)**
     - **Dataset artifact (`Dataset - Updated.csv`)** as the training source
   - The dominant flow is **user input → feature alignment → model inference → displayed risk result**.

11. **Repository character**
   - This is best described as a **model-serving repository with bundled artifacts**, not a platform.
   - The important architectural idea is that the **trained model and its feature contract are versioned alongside the app** to keep prediction behavior stable.

Main entry points: [`app.py`](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/app.py) (Streamlit app), [`Dataset - Updated.csv`](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/HEAD/Dataset%20-%20Updated.csv) (Dataset), [`feature_names.joblib`](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/feature_names.joblib) (Feature schema), [`model.joblib`](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/model.joblib) (Risk model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Runtime"]
  node_n1(("User<br/>browser"))
  node_n2["Streamlit app<br/>ui+inference<br/>[app.py]"]
  node_n6["Python deps<br/>runtime deps<br/>[requirements.txt]"]
end

subgraph group_g2["Artifacts"]
  node_n3["Feature schema<br/>schema artifact"]
  node_n4[("Risk model<br/>ML artifact<br/>[model.joblib]")]
end

subgraph group_g3["Data lineage"]
  node_n5["Dataset<br/>training data"]
end

node_n1 -->|"enters inputs"| node_n2
node_n2 -->|"aligns features"| node_n3
node_n2 -->|"loads model"| node_n4
node_n5 -.->|"trains/validates"| node_n4
node_n5 -.->|"defines schema"| node_n3
node_n6 -->|"supports runtime"| node_n2

click node_n2 "https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/app.py"
click node_n3 "https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/feature_names.joblib"
click node_n4 "https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/model.joblib"
click node_n5 "https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/Dataset - Updated.csv"
click node_n6 "https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/requirements.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2,node_n6 toneBlue
class node_n3,node_n4 toneAmber
class node_n5 toneMint
```

## Components

### Runtime

Interactive inference path for the deployed Streamlit app.

- **User**: browser · Person using the Streamlit demo to enter maternal health inputs.
- [Streamlit app](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/app.py): ui+inference · Main application entrypoint that renders inputs and coordinates prediction. · `app.py`
- [Python deps](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/requirements.txt): runtime deps · Dependency set for Streamlit and the ML/data stack used by the app. · `requirements.txt`

### Artifacts

Versioned model and schema artifacts used at prediction time.

- [Feature schema](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/feature_names.joblib): schema artifact · Serialized feature-name order used to align user input with the model contract. · `feature_names.joblib`
- [Risk model](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/main/model.joblib): ML artifact · Serialized trained classifier used to produce the maternal risk prediction. · `model.joblib`

### Data lineage

Training data source that informs the bundled artifacts.

- [Dataset](https://github.com/riddhimanpuzari-88/maternal_risk_detector/blob/HEAD/Dataset%20-%20Updated.csv): training data · CSV dataset likely used for training or validation of the bundled model. · `Dataset - Updated.csv`

## Connections

- User → Streamlit app: enters inputs · The user interacts with the Streamlit interface to provide maternal-health attributes.
- Streamlit app → Feature schema: aligns features · The app maps form values into the exact feature order expected by the model.
- Streamlit app → Risk model: loads model · The app invokes the serialized predictor to generate a risk result.
- Dataset → Risk model: trains/validates · The dataset is the likely source used to build the bundled model artifact.
- Dataset → Feature schema: defines schema · The dataset likely established the feature names and ordering preserved in the schema artifact.
- Python deps → Streamlit app: supports runtime · Dependencies provide the web UI and numerical/model-serving libraries used by the app.
