# laptopasus1282007-dotcom/elderly-healthcare architecture

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

- Interactive diagram: https://gitdiagram.com/laptopasus1282007-dotcom/elderly-healthcare
- Repository: https://github.com/laptopasus1282007-dotcom/elderly-healthcare

## Overview

AyuCare is an elderly-care and medication-management platform with a Next.js application and a parallel Streamlit/FastAPI implementation. The main user journey is role-based access, medication scheduling and safety checks, dose logging, and caregiver visibility through adherence, alerts, and reports; appointments, vitals, family management, prescription scanning, and SOS are supporting capabilities. The graph includes the documented UI-to-feature relationships and sampled route-to-service dependencies. Some README-described behavior and the Python app’s internal calls are not fully sampled, so those links are omitted or marked unverified.

Main entry points: [`src/lib/db.ts`](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/db.ts) (JSON Data Store), [`src/components/ElderlyPortal.tsx`](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/ElderlyPortal.tsx) (Elderly Portal), [`src/components/CaregiverPortal.tsx`](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/CaregiverPortal.tsx) (Caregiver Portal), [`src/lib/gemini.ts`](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/gemini.ts) (Gemini Services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_elder["Elderly Portal<br/>[ElderlyPortal.tsx]"]
  node_caregiver["Caregiver Portal"]
  node_authui["Passcode Access<br/>[PasscodeModal.tsx]"]
  node_app["Application Entry<br/>[page.tsx]"]
end

subgraph group_care["Care Workflows"]
  node_meds["Medication Management<br/>[route.ts]"]
  node_dose["Dose Logging<br/>[route.ts]"]
  node_adherence["Adherence Metrics<br/>[route.ts]"]
  node_appointments["Appointments<br/>[route.ts]"]
  node_vitals["Vitals Tracking<br/>[route.ts]"]
  node_family["Family Management<br/>[route.ts]"]
  node_contacts["Emergency Contacts<br/>[route.ts]"]
  node_sos["Emergency SOS<br/>[route.ts]"]
  node_reports["Care Reports<br/>[route.ts]"]
  node_notifications["Notification Records<br/>[route.ts]"]
end

subgraph group_services["Application Services"]
  node_auth["PIN Verification<br/>[route.ts]"]
  node_scan["Prescription Scanner<br/>[route.ts]"]
  node_interaction["Drug Safety Check<br/>[route.ts]"]
  node_gemini["Gemini Services<br/>[gemini.ts]"]
  node_email["Email Dispatch<br/>[notifications.ts]"]
end

subgraph group_storage["Persistence"]
  node_dbts[("JSON Data Store<br/>[db.ts]")]
end

subgraph group_python["Python Application"]
  node_streamlit["Streamlit Interface<br/>[streamlit_app.py]"]
  node_fastapi["FastAPI Routes<br/>[main.py]"]
  node_pydb[("Python Data Store<br/>[database.py]")]
  node_pyai["Python AI Service<br/>[gemini_service.py]"]
end

node_user(("Care Team and Patient"))

node_user -->|"uses"| node_app
node_app -.->|"offers"| node_elder
node_app -.->|"offers"| node_caregiver
node_elder -->|"accesses"| node_authui
node_caregiver -->|"accesses"| node_authui
node_authui -->|"verifies access"| node_auth
node_elder -->|"logs doses"| node_dose
node_caregiver -->|"manages schedules"| node_meds
node_caregiver -->|"scans prescriptions"| node_scan
node_elder -->|"uses voice prompts"| node_gemini
node_meds -->|"reads and writes"| node_dbts
node_meds -->|"checks interactions"| node_gemini
node_dose -->|"records doses"| node_dbts
node_dose -->|"dispatches alerts"| node_email
node_adherence -->|"reads metrics"| node_dbts
node_appointments -->|"reads and writes"| node_dbts
node_vitals -->|"reads and writes"| node_dbts
node_family -->|"reads and writes"| node_dbts
node_contacts -->|"reads and writes"| node_dbts
node_sos -->|"records SOS"| node_dbts
node_sos -->|"dispatches alert"| node_email
node_reports -->|"reads summary"| node_dbts
node_notifications -->|"reads alerts"| node_dbts
node_scan -->|"extracts schedules"| node_gemini
node_interaction -->|"checks safety"| node_gemini
node_interaction -->|"reads regimen"| node_dbts
node_streamlit -.->|"uses API"| node_fastapi
node_streamlit -->|"uses data services"| node_pydb
node_streamlit -->|"uses AI services"| node_pyai
node_fastapi -->|"routes data operations"| node_pydb
node_fastapi -->|"routes AI checks"| node_pyai

click node_elder "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/ElderlyPortal.tsx"
click node_caregiver "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/CaregiverPortal.tsx"
click node_authui "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/PasscodeModal.tsx"
click node_app "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/page.tsx"
click node_meds "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/medications/route.ts"
click node_dose "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/medications/%5Bid%5D/log/route.ts"
click node_adherence "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/adherence/route.ts"
click node_appointments "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/appointments/route.ts"
click node_vitals "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/vitals/route.ts"
click node_family "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/family/route.ts"
click node_contacts "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/emergency/route.ts"
click node_sos "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/alerts/emergency-sos/route.ts"
click node_reports "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/reports/summary/route.ts"
click node_notifications "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/notifications/route.ts"
click node_auth "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/auth/verify-pin/route.ts"
click node_scan "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/ai/scan-prescription/route.ts"
click node_interaction "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/ai/drug-interaction/route.ts"
click node_gemini "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/gemini.ts"
click node_email "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/notifications.ts"
click node_dbts "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/db.ts"
click node_streamlit "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/streamlit_app.py"
click node_fastapi "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/main.py"
click node_pydb "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/database.py"
click node_pyai "https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/gemini_service.py"

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_elder,node_caregiver,node_authui,node_app toneBlue
class node_meds,node_dose,node_adherence,node_appointments,node_vitals,node_family,node_contacts,node_sos,node_reports,node_notifications toneAmber
class node_auth,node_scan,node_interaction,node_gemini,node_email toneMint
class node_dbts toneRose
class node_streamlit,node_fastapi,node_pydb,node_pyai,node_user toneIndigo
```

## Components

### User Experience

- [Elderly Portal](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/ElderlyPortal.tsx): `src/components/ElderlyPortal.tsx`
- [Caregiver Portal](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/CaregiverPortal.tsx): `src/components/CaregiverPortal.tsx`
- [Passcode Access](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/components/PasscodeModal.tsx): `src/components/PasscodeModal.tsx`
- [Application Entry](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/page.tsx): `src/app/page.tsx`

### Care Workflows

- [Medication Management](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/medications/route.ts): `src/app/api/medications/route.ts`
- [Dose Logging](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/medications/%5Bid%5D/log/route.ts): `src/app/api/medications/[id]/log/route.ts`
- [Adherence Metrics](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/adherence/route.ts): `src/app/api/adherence/route.ts`
- [Appointments](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/appointments/route.ts): `src/app/api/appointments/route.ts`
- [Vitals Tracking](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/vitals/route.ts): `src/app/api/vitals/route.ts`
- [Family Management](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/family/route.ts): `src/app/api/family/route.ts`
- [Emergency Contacts](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/emergency/route.ts): `src/app/api/emergency/route.ts`
- [Emergency SOS](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/alerts/emergency-sos/route.ts): `src/app/api/alerts/emergency-sos/route.ts`
- [Care Reports](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/reports/summary/route.ts): `src/app/api/reports/summary/route.ts`
- [Notification Records](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/notifications/route.ts): `src/app/api/notifications/route.ts`

### Application Services

- [PIN Verification](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/auth/verify-pin/route.ts): `src/app/api/auth/verify-pin/route.ts`
- [Prescription Scanner](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/ai/scan-prescription/route.ts): `src/app/api/ai/scan-prescription/route.ts`
- [Drug Safety Check](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/app/api/ai/drug-interaction/route.ts): `src/app/api/ai/drug-interaction/route.ts`
- [Gemini Services](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/gemini.ts): `src/lib/gemini.ts`
- [Email Dispatch](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/notifications.ts): `src/lib/notifications.ts`

### Persistence

- [JSON Data Store](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Python Application

- [Streamlit Interface](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/streamlit_app.py): `streamlit_app.py`
- [FastAPI Routes](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/main.py): `backend/main.py`
- [Python Data Store](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/database.py): `backend/database.py`
- [Python AI Service](https://github.com/laptopasus1282007-dotcom/elderly-healthcare/blob/main/backend/gemini_service.py): `backend/gemini_service.py`

### Other components

- **Care Team and Patient**

## Connections

- Care Team and Patient → Application Entry: uses (evidence: `README.md`)
- Application Entry → Elderly Portal: offers
- Application Entry → Caregiver Portal: offers
- Elderly Portal → Passcode Access: accesses (evidence: `README.md`)
- Caregiver Portal → Passcode Access: accesses (evidence: `README.md`)
- Passcode Access → PIN Verification: verifies access (evidence: `README.md`)
- Elderly Portal → Dose Logging: logs doses (evidence: `README.md`)
- Caregiver Portal → Medication Management: manages schedules (evidence: `README.md`)
- Caregiver Portal → Prescription Scanner: scans prescriptions (evidence: `README.md`)
- Elderly Portal → Gemini Services: uses voice prompts (evidence: `README.md`)
- Medication Management → JSON Data Store: reads and writes (evidence: `src/app/api/medications/route.ts`)
- Medication Management → Gemini Services: checks interactions (evidence: `src/app/api/medications/route.ts`)
- Dose Logging → JSON Data Store: records doses (evidence: `src/app/api/medications/[id]/log/route.ts`)
- Dose Logging → Email Dispatch: dispatches alerts (evidence: `src/app/api/medications/[id]/log/route.ts`)
- Adherence Metrics → JSON Data Store: reads metrics (evidence: `src/app/api/adherence/route.ts`)
- Appointments → JSON Data Store: reads and writes (evidence: `src/app/api/appointments/route.ts`)
- Vitals Tracking → JSON Data Store: reads and writes (evidence: `src/app/api/vitals/route.ts`)
- Family Management → JSON Data Store: reads and writes (evidence: `src/app/api/family/route.ts`)
- Emergency Contacts → JSON Data Store: reads and writes (evidence: `src/app/api/emergency/route.ts`)
- Emergency SOS → JSON Data Store: records SOS (evidence: `src/app/api/alerts/emergency-sos/route.ts`)
- Emergency SOS → Email Dispatch: dispatches alert (evidence: `src/app/api/alerts/emergency-sos/route.ts`)
- Care Reports → JSON Data Store: reads summary (evidence: `src/app/api/reports/summary/route.ts`)
- Notification Records → JSON Data Store: reads alerts (evidence: `src/app/api/notifications/route.ts`)
- Prescription Scanner → Gemini Services: extracts schedules (evidence: `src/app/api/ai/scan-prescription/route.ts`)
- Drug Safety Check → Gemini Services: checks safety (evidence: `src/app/api/ai/drug-interaction/route.ts`)
- Drug Safety Check → JSON Data Store: reads regimen (evidence: `src/app/api/ai/drug-interaction/route.ts`)
- Streamlit Interface → FastAPI Routes: uses API
- Streamlit Interface → Python Data Store: uses data services (evidence: `streamlit_app.py`)
- Streamlit Interface → Python AI Service: uses AI services (evidence: `streamlit_app.py`)
- FastAPI Routes → Python Data Store: routes data operations (evidence: `backend/main.py`)
- FastAPI Routes → Python AI Service: routes AI checks (evidence: `backend/main.py`)
