# variablepotato/microland_hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/variablepotato/microland_hackathon
- Repository: https://github.com/variablepotato/microland_hackathon

## Overview

MediCare is a hybrid medication companion for patients and caregivers. The user signs in, then the routed app presents the dashboard and medicine, schedule, history, refill, caregiver, and AI workflows. Medication and dose services combine Supabase with an offline cache; scheduling also sets local reminders, while adherence summarizes dose logs. The AI assistant proposes safety-aware schedule actions for explicit approval. The README documents biometric access, caregiver push alerts, and native Android support; their implementation paths are included, but unsampled wiring is not asserted.

Main entry points: [`src/App.tsx`](https://github.com/variablepotato/microland_hackathon/blob/main/src/App.tsx) (Routed application), [`src/features/ai-assistant/aiService.ts`](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/ai-assistant/aiService.ts) (AI agent service), [`src/features/scheduling/scheduleService.ts`](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/scheduling/scheduleService.ts) (Scheduling service), [`src/features/medication/medicationService.ts`](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/medication/medicationService.ts) (Medication service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and access"]
  node_app["Routed application<br/>[App.tsx]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
end

subgraph group_care["Medication care"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_medicines["Medicine cabinet<br/>[Medicines.tsx]"]
  node_medication["Medication service"]
  node_schedule["Dose schedule<br/>[Schedule.tsx]"]
  node_scheduling["Scheduling service<br/>[scheduleService.ts]"]
  node_adherence["Adherence analytics"]
  node_history["History view<br/>[History.tsx]"]
  node_refills["Refill alerts<br/>[Refills.tsx]"]
  node_caregiver["Caregiver links"]
end

subgraph group_ai["AI assistance"]
  node_aiui["AI assistant UI<br/>[AIAssistant.tsx]"]
  node_ai["AI agent service<br/>[aiService.ts]"]
  node_aiworker["AI edge function<br/>[index.ts]"]
end

subgraph group_platform["Platform services"]
  node_biometric["Biometric lock<br/>[biometric.ts]"]
  node_offline[("Offline cache<br/>[offline.ts]")]
  node_sync["Sync queue<br/>[sync.ts]"]
  node_notifications["Local reminders<br/>[notifications.ts]"]
  node_fcm["Caregiver push<br/>[fcm.ts]"]
  node_android["Android shell<br/>[MainActivity.java]"]
end

subgraph group_backend["Backend integrations"]
  node_pushworker["Push edge function<br/>[index.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

node_patient(("Patient or caregiver"))
node_gemini{{"Gemini API"}}
node_firebase{{"Firebase messaging"}}

node_patient -->|"opens"| node_app
node_app -->|"checks session"| node_auth
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_medicines
node_app -->|"routes"| node_schedule
node_app -->|"routes"| node_history
node_app -->|"routes"| node_refills
node_app -->|"routes"| node_aiui
node_app -->|"routes"| node_caregiver
node_auth -->|"authenticates"| node_supabase
node_auth -->|"uses lock"| node_biometric
node_dashboard -->|"loads doses"| node_scheduling
node_dashboard -->|"loads medicines"| node_medication
node_dashboard -->|"loads metrics"| node_adherence
node_medicines -->|"manages"| node_medication
node_schedule -->|"marks doses"| node_scheduling
node_scheduling -->|"updates stock"| node_medication
node_scheduling -->|"schedules reminders"| node_notifications
node_medication -->|"caches records"| node_offline
node_scheduling -->|"caches doses"| node_offline
node_adherence -->|"reads dose logs"| node_offline
node_history -->|"shows trends"| node_adherence
node_refills -->|"checks stock"| node_medication
node_caregiver -->|"stores links"| node_supabase
node_aiui -->|"sends chat"| node_ai
node_ai -->|"reads medicines"| node_medication
node_ai -->|"reads or saves schedules"| node_scheduling
node_ai -->|"reads adherence"| node_adherence
node_ai -->|"uses fallback data"| node_offline
node_ai -->|"sets approved reminders"| node_notifications
node_ai -->|"requests generation"| node_gemini
node_aiworker -.->|"calls model"| node_gemini
node_app -->|"initializes"| node_offline
node_sync -->|"reads queue"| node_offline
node_sync -->|"syncs records"| node_supabase
node_app -->|"registers device"| node_fcm
node_pushworker -.->|"sends alerts"| node_firebase
node_android -.->|"hosts WebView"| node_app
node_fcm -.->|"uses messaging"| node_firebase

click node_app "https://github.com/variablepotato/microland_hackathon/blob/main/src/App.tsx"
click node_auth "https://github.com/variablepotato/microland_hackathon/blob/main/src/contexts/AuthContext.tsx"
click node_biometric "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/biometric.ts"
click node_dashboard "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Dashboard.tsx"
click node_medicines "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Medicines.tsx"
click node_medication "https://github.com/variablepotato/microland_hackathon/blob/main/src/features/medication/medicationService.ts"
click node_schedule "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Schedule.tsx"
click node_scheduling "https://github.com/variablepotato/microland_hackathon/blob/main/src/features/scheduling/scheduleService.ts"
click node_adherence "https://github.com/variablepotato/microland_hackathon/blob/main/src/features/adherence/adherenceService.ts"
click node_history "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/History.tsx"
click node_refills "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Refills.tsx"
click node_caregiver "https://github.com/variablepotato/microland_hackathon/blob/main/src/features/caregiver/caregiverService.ts"
click node_aiui "https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/AIAssistant.tsx"
click node_ai "https://github.com/variablepotato/microland_hackathon/blob/main/src/features/ai-assistant/aiService.ts"
click node_aiworker "https://github.com/variablepotato/microland_hackathon/blob/main/supabase/functions/ai-assistant/index.ts"
click node_offline "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/offline.ts"
click node_sync "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/sync.ts"
click node_notifications "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/notifications.ts"
click node_fcm "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/fcm.ts"
click node_pushworker "https://github.com/variablepotato/microland_hackathon/blob/main/supabase/functions/notification-service/index.ts"
click node_supabase "https://github.com/variablepotato/microland_hackathon/blob/main/src/services/supabase.ts"
click node_android "https://github.com/variablepotato/microland_hackathon/blob/main/android/app/src/main/java/com/medicare/app/MainActivity.java"

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 toneBlue
class node_dashboard,node_medicines,node_medication,node_schedule,node_scheduling,node_adherence,node_history,node_refills,node_caregiver toneAmber
class node_aiui,node_ai,node_aiworker,node_gemini toneMint
class node_biometric,node_offline,node_sync,node_notifications,node_fcm,node_android toneRose
class node_pushworker,node_supabase,node_patient,node_firebase toneIndigo
```

## Components

### App and access

- [Routed application](https://github.com/variablepotato/microland_hackathon/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication](https://github.com/variablepotato/microland_hackathon/blob/main/src/contexts/AuthContext.tsx): `src/contexts/AuthContext.tsx`

### Medication care

- [Dashboard](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Medicine cabinet](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Medicines.tsx): `src/pages/Medicines.tsx`
- [Medication service](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/medication/medicationService.ts): `src/features/medication/medicationService.ts`
- [Dose schedule](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Schedule.tsx): `src/pages/Schedule.tsx`
- [Scheduling service](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/scheduling/scheduleService.ts): `src/features/scheduling/scheduleService.ts`
- [Adherence analytics](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/adherence/adherenceService.ts): `src/features/adherence/adherenceService.ts`
- [History view](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/History.tsx): `src/pages/History.tsx`
- [Refill alerts](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/Refills.tsx): `src/pages/Refills.tsx`
- [Caregiver links](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/caregiver/caregiverService.ts): `src/features/caregiver/caregiverService.ts`

### AI assistance

- [AI assistant UI](https://github.com/variablepotato/microland_hackathon/blob/main/src/pages/AIAssistant.tsx): `src/pages/AIAssistant.tsx`
- [AI agent service](https://github.com/variablepotato/microland_hackathon/blob/main/src/features/ai-assistant/aiService.ts): `src/features/ai-assistant/aiService.ts`
- [AI edge function](https://github.com/variablepotato/microland_hackathon/blob/main/supabase/functions/ai-assistant/index.ts): `supabase/functions/ai-assistant/index.ts`

### Platform services

- [Biometric lock](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/biometric.ts): `src/services/biometric.ts`
- [Offline cache](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/offline.ts): `src/services/offline.ts`
- [Sync queue](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/sync.ts): `src/services/sync.ts`
- [Local reminders](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/notifications.ts): `src/services/notifications.ts`
- [Caregiver push](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/fcm.ts): `src/services/fcm.ts`
- [Android shell](https://github.com/variablepotato/microland_hackathon/blob/main/android/app/src/main/java/com/medicare/app/MainActivity.java): `android/app/src/main/java/com/medicare/app/MainActivity.java`

### Backend integrations

- [Push edge function](https://github.com/variablepotato/microland_hackathon/blob/main/supabase/functions/notification-service/index.ts): `supabase/functions/notification-service/index.ts`
- [Supabase client](https://github.com/variablepotato/microland_hackathon/blob/main/src/services/supabase.ts): `src/services/supabase.ts`

### Other components

- **Patient or caregiver**
- **Gemini API**
- **Firebase messaging**

## Connections

- Patient or caregiver → Routed application: opens (evidence: `src/App.tsx`)
- Routed application → Authentication: checks session (evidence: `src/App.tsx`)
- Routed application → Dashboard: routes (evidence: `src/App.tsx`)
- Routed application → Medicine cabinet: routes (evidence: `src/App.tsx`)
- Routed application → Dose schedule: routes (evidence: `src/App.tsx`)
- Routed application → History view: routes (evidence: `src/App.tsx`)
- Routed application → Refill alerts: routes (evidence: `src/App.tsx`)
- Routed application → AI assistant UI: routes (evidence: `src/App.tsx`)
- Routed application → Caregiver links: routes (evidence: `src/App.tsx`)
- Authentication → Supabase client: authenticates (evidence: `src/contexts/AuthContext.tsx`)
- Authentication → Biometric lock: uses lock (evidence: `src/components/ProtectedRoute.tsx`)
- Dashboard → Scheduling service: loads doses (evidence: `src/pages/Dashboard.tsx`)
- Dashboard → Medication service: loads medicines (evidence: `src/pages/Dashboard.tsx`)
- Dashboard → Adherence analytics: loads metrics (evidence: `src/pages/Dashboard.tsx`)
- Medicine cabinet → Medication service: manages (evidence: `src/pages/Medicines.tsx`)
- Dose schedule → Scheduling service: marks doses (evidence: `src/pages/Schedule.tsx`)
- Scheduling service → Medication service: updates stock (evidence: `src/features/scheduling/scheduleService.ts`)
- Scheduling service → Local reminders: schedules reminders (evidence: `src/features/scheduling/scheduleService.ts`)
- Medication service → Offline cache: caches records (evidence: `src/features/medication/medicationService.ts`)
- Scheduling service → Offline cache: caches doses (evidence: `src/features/scheduling/scheduleService.ts`)
- Adherence analytics → Offline cache: reads dose logs (evidence: `src/features/adherence/adherenceService.ts`)
- History view → Adherence analytics: shows trends (evidence: `src/pages/History.tsx`)
- Refill alerts → Medication service: checks stock (evidence: `src/pages/Refills.tsx`)
- Caregiver links → Supabase client: stores links (evidence: `src/features/caregiver/caregiverService.ts`)
- AI assistant UI → AI agent service: sends chat (evidence: `src/pages/AIAssistant.tsx`)
- AI agent service → Medication service: reads medicines (evidence: `src/features/ai-assistant/aiService.ts`)
- AI agent service → Scheduling service: reads or saves schedules (evidence: `src/features/ai-assistant/aiService.ts`)
- AI agent service → Adherence analytics: reads adherence (evidence: `src/features/ai-assistant/aiService.ts`)
- AI agent service → Offline cache: uses fallback data (evidence: `src/features/ai-assistant/aiService.ts`)
- AI agent service → Local reminders: sets approved reminders (evidence: `src/features/ai-assistant/aiService.ts`)
- AI agent service → Gemini API: requests generation (evidence: `src/features/ai-assistant/aiService.ts`)
- AI edge function → Gemini API: calls model
- Routed application → Offline cache: initializes (evidence: `src/App.tsx`)
- Sync queue → Offline cache: reads queue (evidence: `src/services/sync.ts`)
- Sync queue → Supabase client: syncs records (evidence: `src/services/sync.ts`)
- Routed application → Caregiver push: registers device (evidence: `src/App.tsx`)
- Push edge function → Firebase messaging: sends alerts
- Android shell → Routed application: hosts WebView
- Caregiver push → Firebase messaging: uses messaging
