# purshathali-hub/liver-disease-prediction architecture

> Architecture diagram of the GitHub repository purshathali-hub/liver-disease-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/purshathali-hub/liver-disease-prediction
- Repository: https://github.com/purshathali-hub/liver-disease-prediction

## Overview

This React application collects patient demographics and liver laboratory values, submits them to a Gemini-backed service for an educational risk estimate, and displays the result, risk factors, and recommendations. App.tsx owns submission, loading, and error state; the form and result components handle the corresponding user-interface stages. The README describes a Jupyter/scikit-learn model, but the sampled runtime calls Gemini instead, so no connection from the notebook to prediction is asserted.

Main entry points: [`App.tsx`](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/App.tsx) (App state and submission), [`components/PredictionForm.tsx`](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/PredictionForm.tsx) (Patient data form), [`services/geminiService.ts`](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/services/geminiService.ts) (Gemini prediction service), [`components/ResultDisplay.tsx`](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/ResultDisplay.tsx) (Risk result display)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_entry["React entry<br/>[index.tsx]"]
  node_form["Patient data form<br/>[PredictionForm.tsx]"]
  node_result["Risk result display<br/>[ResultDisplay.tsx]"]
  node_loader["Loading indicator<br/>[Loader.tsx]"]
  node_header["Application header<br/>[Header.tsx]"]
  node_footer["Medical disclaimer<br/>[Footer.tsx]"]
end

subgraph group_flow["Prediction flow"]
  node_app["App state and submission<br/>[App.tsx]"]
  node_gemini["Gemini prediction service<br/>[geminiService.ts]"]
end

subgraph group_contracts["Data contracts"]
  node_defaults["Form fields and defaults<br/>[constants.ts]"]
  node_contracts["Patient and result types<br/>[types.ts]"]
end

node_patient(("Patient"))
node_google["Google Gemini API"]

node_entry -->|"mounts"| node_app
node_app -->|"renders"| node_header
node_app -->|"renders"| node_form
node_app -->|"renders"| node_loader
node_app -->|"renders"| node_result
node_app -->|"renders"| node_footer
node_patient -->|"enters data"| node_form
node_form -->|"reads field definitions"| node_defaults
node_form -->|"submits and reports changes"| node_app
node_app -->|"initializes patient data"| node_defaults
node_app -->|"requests prediction"| node_gemini
node_gemini -->|"requests generated analysis"| node_google
node_gemini -->|"returns prediction"| node_app
node_app -->|"passes prediction"| node_result
node_form -->|"uses patient types"| node_contracts
node_gemini -->|"uses prediction types"| node_contracts
node_result -->|"uses result type"| node_contracts

click node_entry "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/index.tsx"
click node_app "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/App.tsx"
click node_form "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/PredictionForm.tsx"
click node_defaults "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/constants.ts"
click node_gemini "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/services/geminiService.ts"
click node_result "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/ResultDisplay.tsx"
click node_loader "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Loader.tsx"
click node_header "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Header.tsx"
click node_footer "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Footer.tsx"
click node_contracts "https://github.com/purshathali-hub/liver-disease-prediction/blob/main/types.ts"

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_entry,node_form,node_result,node_loader,node_header,node_footer toneBlue
class node_app,node_gemini toneAmber
class node_defaults,node_contracts,node_google toneMint
class node_patient toneIndigo
```

## Components

### User interface

- [React entry](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/index.tsx): `index.tsx`
- [Patient data form](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/PredictionForm.tsx): `components/PredictionForm.tsx`
- [Risk result display](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/ResultDisplay.tsx): `components/ResultDisplay.tsx`
- [Loading indicator](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Loader.tsx): `components/Loader.tsx`
- [Application header](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Header.tsx): `components/Header.tsx`
- [Medical disclaimer](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/components/Footer.tsx): `components/Footer.tsx`

### Prediction flow

- [App state and submission](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/App.tsx): `App.tsx`
- [Gemini prediction service](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/services/geminiService.ts): `services/geminiService.ts`

### Data contracts

- [Form fields and defaults](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/constants.ts): `constants.ts`
- [Patient and result types](https://github.com/purshathali-hub/liver-disease-prediction/blob/main/types.ts): `types.ts`

### Other components

- **Patient**
- **Google Gemini API**

## Connections

- React entry → App state and submission: mounts (evidence: `index.tsx`)
- App state and submission → Application header: renders (evidence: `App.tsx`)
- App state and submission → Patient data form: renders (evidence: `App.tsx`)
- App state and submission → Loading indicator: renders (evidence: `App.tsx`)
- App state and submission → Risk result display: renders (evidence: `App.tsx`)
- App state and submission → Medical disclaimer: renders (evidence: `App.tsx`)
- Patient → Patient data form: enters data (evidence: `components/PredictionForm.tsx`)
- Patient data form → Form fields and defaults: reads field definitions (evidence: `components/PredictionForm.tsx`)
- Patient data form → App state and submission: submits and reports changes (evidence: `components/PredictionForm.tsx`)
- App state and submission → Form fields and defaults: initializes patient data (evidence: `App.tsx`)
- App state and submission → Gemini prediction service: requests prediction (evidence: `App.tsx`)
- Gemini prediction service → Google Gemini API: requests generated analysis (evidence: `services/geminiService.ts`)
- Gemini prediction service → App state and submission: returns prediction (evidence: `App.tsx`)
- App state and submission → Risk result display: passes prediction (evidence: `App.tsx`)
- Patient data form → Patient and result types: uses patient types (evidence: `components/PredictionForm.tsx`)
- Gemini prediction service → Patient and result types: uses prediction types (evidence: `services/geminiService.ts`)
- Risk result display → Patient and result types: uses result type (evidence: `components/ResultDisplay.tsx`)
