# nithyashreenithu24-arch/materncare architecture

> Architecture diagram of the GitHub repository nithyashreenithu24-arch/materncare, 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/nithyashreenithu24-arch/materncare
- Repository: https://github.com/nithyashreenithu24-arch/materncare

## Overview

Matern AI is a role-based maternal-health platform. Patients submit health records and receive risk predictions and nutrition plans; patients and clinicians use dashboards for longitudinal review, communication, appointments, and reports, while administrators manage users and model operations. The server routes API requests to prediction, nutrition, chat, and persistence services. The README documents several capabilities not visible in the sampled implementation; their UI components are included, but uncertain internal relationships are omitted. The graph reflects the supplied excerpts and README, not an inspection of unsampled source.

Main entry points: [`src/App.tsx`](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/App.tsx) (Application Shell), [`src/api.ts`](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/api.ts) (API Client), [`server.ts`](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server.ts) (REST API Server), [`src/components/DoctorDashboard.tsx`](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/DoctorDashboard.tsx) (Doctor Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["Role-Based Portals"]
  node_app["Application Shell<br/>[App.tsx]"]
  node_auth["Authentication<br/>[AuthModal.tsx]"]
  node_patient["Patient Dashboard"]
  node_doctor["Doctor Dashboard"]
  node_admin["Admin Dashboard<br/>[AdminDashboard.tsx]"]
end

subgraph group_clinical["Clinical Guidance"]
  node_health["Health Record Entry"]
  node_charts["Risk and Trend Charts<br/>[Charts.tsx]"]
  node_nutritionui["Nutrition Plan View<br/>[NutritionModal.tsx]"]
  node_report["Clinical Reports<br/>[ReportModal.tsx]"]
  node_chatui["Patient Education Chat<br/>[ChatbotDrawer.tsx]"]
  node_communication["Clinical Messaging"]
  node_appointments["Appointments"]
end

subgraph group_services["Application Services"]
  node_api["API Client<br/>[api.ts]"]
  node_server["REST API Server<br/>[server.ts]"]
  node_ml["Risk Prediction and Retraining<br/>[ml_engine.ts]"]
  node_nutrition["Nutrition Plan Engine"]
  node_chat["Chat Service<br/>[chat_service.ts]"]
end

subgraph group_state["Data and Models"]
  node_db[("Clinical Data Store<br/>[db.ts]")]
  node_datasets["Model Datasets"]
end

node_user(("Patient / Clinician / Admin"))
node_gemini{{"Google Gemini"}}

node_user -->|"uses"| node_app
node_app -->|"opens"| node_auth
node_app -->|"renders"| node_patient
node_app -->|"renders"| node_doctor
node_app -->|"renders"| node_admin
node_app -->|"opens"| node_health
node_app -->|"opens"| node_nutritionui
node_app -->|"opens"| node_report
node_app -->|"opens"| node_chatui
node_app -->|"opens"| node_communication
node_app -->|"opens"| node_appointments
node_patient -->|"renders"| node_charts
node_doctor -->|"renders"| node_charts
node_doctor -->|"renders"| node_communication
node_patient -.->|"requests data"| node_api
node_doctor -.->|"requests data"| node_api
node_admin -->|"requests data"| node_api
node_communication -->|"sends messages"| node_api
node_appointments -->|"requests appointment"| node_api
node_chatui -->|"sends query"| node_api
node_api -->|"calls REST API"| node_server
node_server -->|"reads and writes"| node_db
node_server -->|"calculates risk"| node_ml
node_server -->|"generates plan"| node_nutrition
node_server -->|"requests response"| node_chat
node_chat -->|"generates response"| node_gemini
node_datasets -.->|"trains from"| node_ml

click node_app "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/App.tsx"
click node_auth "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AuthModal.tsx"
click node_patient "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/PatientDashboard.tsx"
click node_doctor "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/DoctorDashboard.tsx"
click node_admin "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AdminDashboard.tsx"
click node_health "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/HealthDataModal.tsx"
click node_charts "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/Charts.tsx"
click node_nutritionui "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/NutritionModal.tsx"
click node_report "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/ReportModal.tsx"
click node_chatui "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/ChatbotDrawer.tsx"
click node_communication "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/CommunicationPanel.tsx"
click node_appointments "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AppointmentPanel.tsx"
click node_api "https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/api.ts"
click node_server "https://github.com/nithyashreenithu24-arch/materncare/blob/main/server.ts"
click node_ml "https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/ml_engine.ts"
click node_nutrition "https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/nutrition_engine.ts"
click node_chat "https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/chat_service.ts"
click node_db "https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/db.ts"
click node_datasets "https://github.com/nithyashreenithu24-arch/materncare/tree/main/data"

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_app,node_auth,node_patient,node_doctor,node_admin toneBlue
class node_health,node_charts,node_nutritionui,node_report,node_chatui,node_communication,node_appointments toneAmber
class node_api,node_server,node_ml,node_nutrition,node_chat toneMint
class node_db,node_datasets toneRose
class node_user,node_gemini toneIndigo
```

## Components

### Role-Based Portals

- [Application Shell](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AuthModal.tsx): `src/components/AuthModal.tsx`
- [Patient Dashboard](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/PatientDashboard.tsx): `src/components/PatientDashboard.tsx`
- [Doctor Dashboard](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/DoctorDashboard.tsx): `src/components/DoctorDashboard.tsx`
- [Admin Dashboard](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AdminDashboard.tsx): `src/components/AdminDashboard.tsx`

### Clinical Guidance

- [Health Record Entry](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/HealthDataModal.tsx): `src/components/HealthDataModal.tsx`
- [Risk and Trend Charts](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/Charts.tsx): `src/components/Charts.tsx`
- [Nutrition Plan View](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/NutritionModal.tsx): `src/components/NutritionModal.tsx`
- [Clinical Reports](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/ReportModal.tsx): `src/components/ReportModal.tsx`
- [Patient Education Chat](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/ChatbotDrawer.tsx): `src/components/ChatbotDrawer.tsx`
- [Clinical Messaging](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/CommunicationPanel.tsx): `src/components/CommunicationPanel.tsx`
- [Appointments](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/components/AppointmentPanel.tsx): `src/components/AppointmentPanel.tsx`

### Application Services

- [API Client](https://github.com/nithyashreenithu24-arch/materncare/blob/main/src/api.ts): `src/api.ts`
- [REST API Server](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server.ts): `server.ts`
- [Risk Prediction and Retraining](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/ml_engine.ts): `server/ml_engine.ts`
- [Nutrition Plan Engine](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/nutrition_engine.ts): `server/nutrition_engine.ts`
- [Chat Service](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/chat_service.ts): `server/chat_service.ts`

### Data and Models

- [Clinical Data Store](https://github.com/nithyashreenithu24-arch/materncare/blob/main/server/db.ts): `server/db.ts`
- [Model Datasets](https://github.com/nithyashreenithu24-arch/materncare/tree/main/data): `data`

### Other components

- **Patient / Clinician / Admin**
- **Google Gemini**

## Connections

- Patient / Clinician / Admin → Application Shell: uses (evidence: `README.md`)
- Application Shell → Authentication: opens (evidence: `src/App.tsx`)
- Application Shell → Patient Dashboard: renders (evidence: `src/App.tsx`)
- Application Shell → Doctor Dashboard: renders (evidence: `src/App.tsx`)
- Application Shell → Admin Dashboard: renders (evidence: `src/App.tsx`)
- Application Shell → Health Record Entry: opens (evidence: `src/App.tsx`)
- Application Shell → Nutrition Plan View: opens (evidence: `src/App.tsx`)
- Application Shell → Clinical Reports: opens (evidence: `src/App.tsx`)
- Application Shell → Patient Education Chat: opens (evidence: `src/App.tsx`)
- Application Shell → Clinical Messaging: opens (evidence: `src/App.tsx`)
- Application Shell → Appointments: opens (evidence: `src/App.tsx`)
- Patient Dashboard → Risk and Trend Charts: renders (evidence: `src/components/PatientDashboard.tsx`)
- Doctor Dashboard → Risk and Trend Charts: renders (evidence: `src/components/DoctorDashboard.tsx`)
- Doctor Dashboard → Clinical Messaging: renders (evidence: `src/components/DoctorDashboard.tsx`)
- Patient Dashboard → API Client: requests data
- Doctor Dashboard → API Client: requests data
- Admin Dashboard → API Client: requests data (evidence: `src/components/AdminDashboard.tsx`)
- Clinical Messaging → API Client: sends messages (evidence: `src/components/CommunicationPanel.tsx`)
- Appointments → API Client: requests appointment (evidence: `src/components/AppointmentPanel.tsx`)
- Patient Education Chat → API Client: sends query (evidence: `src/components/ChatbotDrawer.tsx`)
- API Client → REST API Server: calls REST API (evidence: `src/api.ts`)
- REST API Server → Clinical Data Store: reads and writes (evidence: `server.ts`)
- REST API Server → Risk Prediction and Retraining: calculates risk (evidence: `server.ts`)
- REST API Server → Nutrition Plan Engine: generates plan (evidence: `server.ts`)
- REST API Server → Chat Service: requests response (evidence: `server.ts`)
- Chat Service → Google Gemini: generates response (evidence: `server/chat_service.ts`)
- Model Datasets → Risk Prediction and Retraining: trains from (evidence: `README.md`)
