# mkcodes4/ds-mini-project architecture

> Architecture diagram of the GitHub repository mkcodes4/ds-mini-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mkcodes4/ds-mini-project
- Repository: https://github.com/mkcodes4/ds-mini-project

## Overview

This is a CKD assessment web app: users enter 51 patient features, the Next.js interface submits them through an API route to a Flask service, and the service returns a model prediction and confidence for display. The Python service loads a serialized bagging model; the web API also proxies a health check. A separate analytics page presents performance, model-comparison, dataset, and confusion-matrix views. The README describes data preparation and model training, but no corresponding training code or dataset appears in the supplied tree, so those are not represented as runtime components.

Main entry points: [`src/app/api/predict/route.ts`](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/api/predict/route.ts) (Prediction API route), [`python-server/app.py`](https://github.com/mkcodes4/ds-mini-project/blob/main/python-server/app.py) (Flask prediction service), [`src/app/page.tsx`](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/page.tsx) (Feature assessment form), [`public/ckd_bagging_model.pkl`](https://github.com/mkcodes4/ds-mini-project/blob/main/public/ckd_bagging_model.pkl) (Bagging model artifact)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_assessment["Feature assessment form<br/>[page.tsx]"]
  node_results["Prediction results<br/>[page.tsx]"]
  node_analytics["Model analytics<br/>[page.tsx]"]
end

subgraph group_gateway["Web API"]
  node_predict_api["Prediction API route<br/>[route.ts]"]
end

subgraph group_inference["Prediction service"]
  node_flask["Flask prediction service<br/>[app.py]"]
  node_model["Bagging model artifact"]
end

node_patient(("Patient or user"))

node_patient -->|"enters features"| node_assessment
node_assessment -->|"submits features"| node_predict_api
node_predict_api -->|"forwards prediction"| node_flask
node_flask -->|"loads model"| node_model
node_flask -->|"runs prediction"| node_model
node_predict_api -->|"checks health"| node_flask
node_predict_api -->|"returns prediction"| node_results

click node_assessment "https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/page.tsx"
click node_results "https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/page.tsx"
click node_analytics "https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/analytics/page.tsx"
click node_predict_api "https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/api/predict/route.ts"
click node_flask "https://github.com/mkcodes4/ds-mini-project/blob/main/python-server/app.py"
click node_model "https://github.com/mkcodes4/ds-mini-project/blob/main/public/ckd_bagging_model.pkl"

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_assessment,node_results,node_analytics,node_patient toneBlue
class node_predict_api toneAmber
class node_flask,node_model toneMint
```

## Components

### User interface

- [Feature assessment form](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Prediction results](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Model analytics](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/analytics/page.tsx): `src/app/analytics/page.tsx`

### Web API

- [Prediction API route](https://github.com/mkcodes4/ds-mini-project/blob/main/src/app/api/predict/route.ts): `src/app/api/predict/route.ts`

### Prediction service

- [Flask prediction service](https://github.com/mkcodes4/ds-mini-project/blob/main/python-server/app.py): `python-server/app.py`
- [Bagging model artifact](https://github.com/mkcodes4/ds-mini-project/blob/main/public/ckd_bagging_model.pkl): `public/ckd_bagging_model.pkl`

### Other components

- **Patient or user**

## Connections

- Patient or user → Feature assessment form: enters features (evidence: `src/app/page.tsx`)
- Feature assessment form → Prediction API route: submits features (evidence: `src/app/page.tsx`)
- Prediction API route → Flask prediction service: forwards prediction (evidence: `src/app/api/predict/route.ts`)
- Flask prediction service → Bagging model artifact: loads model (evidence: `python-server/app.py`)
- Flask prediction service → Bagging model artifact: runs prediction (evidence: `python-server/app.py`)
- Prediction API route → Flask prediction service: checks health (evidence: `src/app/api/predict/route.ts`)
- Prediction API route → Prediction results: returns prediction (evidence: `src/app/api/predict/route.ts`)
