# horserider2146/meditrackpro architecture

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

- Interactive diagram: https://gitdiagram.com/horserider2146/meditrackpro
- Repository: https://github.com/horserider2146/meditrackpro

## Overview

1. **High-level shape**
   - This is a single-module Android app (`app/`) written in Kotlin.
   - The architecture is a mix of **MVVM for data-backed screens** and **Activity/Fragment-driven UI** for navigation and settings.
   - The app centers on personal health management: medications, health records, profile/health info, caregiver settings, and account/security controls.

2. **Entry points and screen navigation**
   - `LoginActivity` and `SignUpActivity` handle authentication before the user enters the main app.
   - `MainActivity` is the post-login shell and likely hosts the **bottom navigation** and `nav_graph.xml`.
   - The primary in-app destinations are the four main fragments:
     - `HomeFragment`
     - `MedicationsFragment`
     - `HealthFragment`
     - `ProfileFragment`

3. **Core UI split: fragments vs. standalone activities**
   - The app uses fragments for the main dashboard sections and separate activities for focused editor/settings flows.
   - Add/edit screens are isolated as activities:
     - `AddMedicineActivity`
     - `AddHealthRecordActivity`
     - `EditHealthInfoActivity`
   - Settings and preference screens are also separate activities:
     - `CaregiverSettingsActivity`
     - `NotificationSettingsActivity`
     - `PrivacySettingsActivity`
     - `AppAppearanceActivity`
     - `EmergencyContactsActivity`

4. **Medication subsystem**
   - The medication feature is a full local-data subsystem built around:
     - `Medicine` entity
     - `MedicineDao`
     - `MedicineDatabase`
     - `MedicineViewModel`
   - `MedicationsFragment` presents organized views such as today’s meds, all meds, and refill tracking.
   - `AddMedicineActivity` writes new medication data into the local database; the fragment reads it back through the ViewModel.
   - The UI also includes refill and dosage card layouts, showing that medication data is rendered in multiple card styles rather than a single list.

5. **Health records subsystem**
   - The health record side mirrors the medication architecture:
     - `HealthRecord` entity
     - `HealthRecordDao`
     - `HealthViewModel`
   - `HealthFragment` is the read/browse surface for records and category counts.
   - `AddHealthRecordActivity` and `EditHealthInfoActivity` provide data entry/editing flows.
   - The readme indicates record types like lab results, prescriptions, visits, and vaccinations, with deletion support from the list view.

6. **Home/dashboard flow**
   - `HomeFragment` is the summary layer of the app.
   - It aggregates user-facing health and medication status into a dashboard: live time, greeting, dose progress, and upcoming dose alerts.
   - This makes it the “presentation-only” hub that pulls together information from the medication and profile subsystems rather than owning its own persistent model.

7. **Profile, health info, and caregiver support**
   - `ProfileFragment` likely acts as the central user profile and settings gateway.
   - `EditHealthInfoActivity` manages personal health attributes such as blood type, height, weight, DOB, gender, and conditions; the readme notes BMI is computed from the entered values.
   - Caregiver configuration is separated into `CaregiverSettingsActivity`, indicating a distinct workflow for contact details and alert preferences.
   - `EmergencyContactsActivity` holds two dedicated contact slots, suggesting emergency contacts are a separate data domain from caregiver data.

8. **Authentication and account lifecycle**
   - Firebase Authentication is the external identity boundary for the app.
   - Email/password sign-in and sign-up are handled by `LoginActivity` and `SignUpActivity`.
   - The presence of `google-services.json` and Firebase in the readme indicates the app depends on Google services configuration at build/runtime.
   - Privacy flows include password reset, biometric unlock on launch, and account deletion with re-authentication.

9. **Local persistence boundary**
   - The app’s persistent health and medication data is stored locally with **Room** on SQLite.
   - ViewModels sit between the UI and the Room layer, which keeps screens decoupled from direct database access.
   - This is the main data flow pattern in the repo: **Activity/Fragment → ViewModel → DAO → Room database**.
   - The readme also mentions “clear all local data,” reinforcing that local persistence is a major concern and likely user-resettable.

10. **Appearance and app-wide behavior**
   - `BaseActivity` and `AppThemeHelper` indicate centralized behavior for app-wide theme/font application.
   - `AppAppearanceActivity` lets users change dark/light theme, accent color, and text size.
   - The resource set includes multiple color/dot/pill drawable variants, which supports the app’s theme customization system.
   - This is a cross-cutting layer that affects many screens rather than a feature silo.

11. **Navigation and UI composition**
   - The app uses the **Jetpack Navigation Component** with a bottom navigation menu (`bottom_nav_menu.xml`) and a navigation graph (`nav_graph.xml`).
   - Screen layouts are mostly Material-style XML views, with reusable item layouts for medicine, health records, dose cards, and refill cards.
   - That suggests a classic Android view-based UI, not Compose.

12. **Infrastructure and platform dependencies**
   - Material Components, CardView, ConstraintLayout, AndroidX Biometric, and likely LiveData/ViewModel are the main Android framework dependencies shaping the app.
   - The readme mentions WorkManager and notification features, so background reminder infrastructure is part of the intended architecture, even though worker classes are not visible in this file tree.
   - Overall, the architecture is split cleanly between:
     - **Remote identity**: Firebase Auth
     - **Local health data**: Room
     - **UI/navigation**: Activities, Fragments, Navigation Component
     - **Cross-cutting preferences**: theme, font scale, biometric/privacy settings

Main entry points: [`app/src/main/java/com/example/meditrackpro/ProfileFragment.kt`](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/ProfileFragment.kt) (Profile), [`app/src/main/java/com/example/meditrackpro/MainActivity.kt`](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MainActivity.kt) (Main Shell), [`app/src/main/java/com/example/meditrackpro/MedicineViewModel.kt`](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineViewModel.kt) (Medicine VM), [`app/src/main/java/com/example/meditrackpro/HealthViewModel.kt`](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthViewModel.kt) (Health VM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_auth["Auth"]
  node_login_activity["Login<br/>activity<br/>[LoginActivity.kt]"]
  node_signup_activity["Sign Up<br/>activity<br/>[SignUpActivity.kt]"]
end

subgraph group_group_shell["App Shell"]
  node_main_activity["Main Shell<br/>activity<br/>[MainActivity.kt]"]
  node_home_fragment["Home<br/>fragment<br/>[HomeFragment.kt]"]
end

subgraph group_group_meds["Medications"]
  node_medications_fragment["Medications<br/>fragment"]
  node_add_medicine_activity["Add Medicine<br/>activity"]
  node_medicine_vm["Medicine VM<br/>viewmodel"]
  node_medicine_db[("Medicine DB<br/>room database")]
  node_medicine_dao["Medicine DAO<br/>room dao<br/>[MedicineDao.kt]"]
  node_medicine_entity["Medicine<br/>room entity<br/>[Medicine.kt]"]
end

subgraph group_group_health["Health Records"]
  node_health_fragment["Health<br/>fragment<br/>[HealthFragment.kt]"]
  node_add_health_activity["Add Record<br/>activity"]
  node_health_vm["Health VM<br/>viewmodel<br/>[HealthViewModel.kt]"]
  node_health_dao["Health DAO<br/>room dao<br/>[HealthRecordDao.kt]"]
  node_health_entity["Health Record<br/>room entity<br/>[HealthRecord.kt]"]
end

subgraph group_group_profile["Profile & Settings"]
  node_profile_fragment["Profile<br/>fragment<br/>[ProfileFragment.kt]"]
  node_edit_health_activity["Edit Health<br/>activity"]
  node_caregiver_activity["Caregiver<br/>activity"]
  node_emergency_activity["Emergency Contacts<br/>activity"]
end

subgraph group_group_infra["Shared Infra"]
  node_appearance_activity["Appearance<br/>activity"]
  node_privacy_activity["Privacy<br/>activity"]
  node_notification_activity["Notifications<br/>activity"]
  node_base_activity["Base Activity<br/>shared activity base<br/>[BaseActivity.kt]"]
  node_theme_helper["Theme Helper<br/>ui helper<br/>[AppThemeHelper.kt]"]
end

node_login_activity -->|"auth success"| node_main_activity
node_signup_activity -->|"register success"| node_main_activity
node_main_activity -->|"hosts"| node_home_fragment
node_main_activity -->|"hosts"| node_medications_fragment
node_main_activity -->|"hosts"| node_health_fragment
node_main_activity -->|"hosts"| node_profile_fragment
node_home_fragment -->|"summarizes"| node_medicine_vm
node_medications_fragment -->|"reads writes"| node_medicine_vm
node_add_medicine_activity -->|"creates"| node_medicine_vm
node_medicine_vm -->|"uses"| node_medicine_dao
node_medicine_dao -->|"queries"| node_medicine_db
node_medicine_db -->|"stores"| node_medicine_entity
node_health_fragment -->|"reads"| node_health_vm
node_add_health_activity -->|"creates"| node_health_vm
node_health_vm -->|"uses"| node_health_dao
node_health_dao -->|"stores"| node_health_entity
node_profile_fragment -->|"opens"| node_edit_health_activity
node_profile_fragment -->|"opens"| node_caregiver_activity
node_profile_fragment -->|"opens"| node_emergency_activity
node_profile_fragment -->|"opens"| node_privacy_activity
node_profile_fragment -->|"opens"| node_notification_activity
node_profile_fragment -->|"opens"| node_appearance_activity
node_base_activity -->|"applies"| node_theme_helper
node_appearance_activity -->|"configures"| node_theme_helper

click node_login_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/LoginActivity.kt"
click node_signup_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/SignUpActivity.kt"
click node_main_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MainActivity.kt"
click node_home_fragment "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HomeFragment.kt"
click node_medications_fragment "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicationsFragment.kt"
click node_add_medicine_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AddMedicineActivity.kt"
click node_medicine_vm "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineViewModel.kt"
click node_medicine_db "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineDatabase.kt"
click node_medicine_dao "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineDao.kt"
click node_medicine_entity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/Medicine.kt"
click node_health_fragment "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthFragment.kt"
click node_add_health_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AddHealthRecordActivity.kt"
click node_health_vm "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthViewModel.kt"
click node_health_dao "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthRecordDao.kt"
click node_health_entity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthRecord.kt"
click node_profile_fragment "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/ProfileFragment.kt"
click node_edit_health_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/EditHealthInfoActivity.kt"
click node_caregiver_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/CaregiverSettingsActivity.kt"
click node_emergency_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/EmergencyContactsActivity.kt"
click node_appearance_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AppAppearanceActivity.kt"
click node_privacy_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/PrivacySettingsActivity.kt"
click node_notification_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/NotificationSettingsActivity.kt"
click node_base_activity "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/BaseActivity.kt"
click node_theme_helper "https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AppThemeHelper.kt"

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_login_activity,node_signup_activity toneBlue
class node_main_activity,node_home_fragment toneAmber
class node_medications_fragment,node_add_medicine_activity,node_medicine_vm,node_medicine_db,node_medicine_dao,node_medicine_entity toneMint
class node_health_fragment,node_add_health_activity,node_health_vm,node_health_dao,node_health_entity toneRose
class node_profile_fragment,node_edit_health_activity,node_caregiver_activity,node_emergency_activity toneIndigo
class node_appearance_activity,node_privacy_activity,node_notification_activity,node_base_activity,node_theme_helper toneTeal
```

## Components

### Auth

Login, signup, and account lifecycle flows.

- [Login](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/LoginActivity.kt): activity · Email/password sign-in entry point. · `app/src/main/java/com/example/meditrackpro/LoginActivity.kt`
- [Sign Up](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/SignUpActivity.kt): activity · Account creation flow. · `app/src/main/java/com/example/meditrackpro/SignUpActivity.kt`

### App Shell

Post-login navigation and shared UI infrastructure.

- [Main Shell](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MainActivity.kt): activity · Post-login container for in-app navigation. · `app/src/main/java/com/example/meditrackpro/MainActivity.kt`
- [Home](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HomeFragment.kt): fragment · Dashboard summary for meds and health status. · `app/src/main/java/com/example/meditrackpro/HomeFragment.kt`

### Medications

Medication capture, tracking, and local persistence.

- [Medications](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicationsFragment.kt): fragment · Medication overview, doses, and refill tracking. · `app/src/main/java/com/example/meditrackpro/MedicationsFragment.kt`
- [Add Medicine](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AddMedicineActivity.kt): activity · Create medication entries. · `app/src/main/java/com/example/meditrackpro/AddMedicineActivity.kt`
- [Medicine VM](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineViewModel.kt): viewmodel · Bridges medication UI and local data. · `app/src/main/java/com/example/meditrackpro/MedicineViewModel.kt`
- [Medicine DB](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineDatabase.kt): room database · Local medication persistence boundary. · `app/src/main/java/com/example/meditrackpro/MedicineDatabase.kt`
- [Medicine DAO](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/MedicineDao.kt): room dao · Medication queries and writes. · `app/src/main/java/com/example/meditrackpro/MedicineDao.kt`
- [Medicine](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/Medicine.kt): room entity · Medication record model. · `app/src/main/java/com/example/meditrackpro/Medicine.kt`

### Health Records

Health record browsing and editing flows.

- [Health](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthFragment.kt): fragment · Health record browsing and counts. · `app/src/main/java/com/example/meditrackpro/HealthFragment.kt`
- [Add Record](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AddHealthRecordActivity.kt): activity · Create new health records. · `app/src/main/java/com/example/meditrackpro/AddHealthRecordActivity.kt`
- [Health VM](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthViewModel.kt): viewmodel · Bridges health record UI and local data. · `app/src/main/java/com/example/meditrackpro/HealthViewModel.kt`
- [Health DAO](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthRecordDao.kt): room dao · Health record queries and writes. · `app/src/main/java/com/example/meditrackpro/HealthRecordDao.kt`
- [Health Record](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/HealthRecord.kt): room entity · Health record model. · `app/src/main/java/com/example/meditrackpro/HealthRecord.kt`

### Profile & Settings

Profile, health info, privacy, and preferences.

- [Profile](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/ProfileFragment.kt): fragment · Profile gateway into personal and settings flows. · `app/src/main/java/com/example/meditrackpro/ProfileFragment.kt`
- [Edit Health](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/EditHealthInfoActivity.kt): activity · Personal health info editor. · `app/src/main/java/com/example/meditrackpro/EditHealthInfoActivity.kt`
- [Caregiver](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/CaregiverSettingsActivity.kt): activity · Caregiver contact and alert settings. · `app/src/main/java/com/example/meditrackpro/CaregiverSettingsActivity.kt`
- [Emergency Contacts](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/EmergencyContactsActivity.kt): activity · Dedicated emergency contact slots. · `app/src/main/java/com/example/meditrackpro/EmergencyContactsActivity.kt`

### Shared Infra

Cross-cutting app behavior and platform integration.

- [Appearance](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AppAppearanceActivity.kt): activity · Theme, accent, and text-size settings. · `app/src/main/java/com/example/meditrackpro/AppAppearanceActivity.kt`
- [Privacy](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/PrivacySettingsActivity.kt): activity · Security and account lifecycle controls. · `app/src/main/java/com/example/meditrackpro/PrivacySettingsActivity.kt`
- [Notifications](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/NotificationSettingsActivity.kt): activity · Reminder and alert settings. · `app/src/main/java/com/example/meditrackpro/NotificationSettingsActivity.kt`
- [Base Activity](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/BaseActivity.kt): shared activity base · Common activity behavior for the app. · `app/src/main/java/com/example/meditrackpro/BaseActivity.kt`
- [Theme Helper](https://github.com/horserider2146/meditrackpro/blob/main/app/src/main/java/com/example/meditrackpro/AppThemeHelper.kt): ui helper · Centralized theme and font application. · `app/src/main/java/com/example/meditrackpro/AppThemeHelper.kt`

## Connections

- Login → Main Shell: auth success · Successful sign-in enters the main shell.
- Sign Up → Main Shell: register success · New account creation proceeds into the app.
- Main Shell → Home: hosts · Main shell hosts the dashboard fragment.
- Main Shell → Medications: hosts · Main shell hosts medication navigation.
- Main Shell → Health: hosts · Main shell hosts health record navigation.
- Main Shell → Profile: hosts · Main shell hosts profile navigation.
- Home → Medicine VM: summarizes · Dashboard reflects medication status.
- Medications → Medicine VM: reads writes · Medication UI uses the ViewModel boundary.
- Add Medicine → Medicine VM: creates · Add flow persists through the ViewModel.
- Medicine VM → Medicine DAO: uses · ViewModel delegates local data access.
- Medicine DAO → Medicine DB: queries · DAO operates on the Room database.
- Medicine DB → Medicine: stores · Room database persists medication entities.
- Health → Health VM: reads · Health UI uses the ViewModel boundary.
- Add Record → Health VM: creates · Add record flow persists through the ViewModel.
- Health VM → Health DAO: uses · ViewModel delegates local data access.
- Health DAO → Health Record: stores · DAO reads and writes record entities.
- Profile → Edit Health: opens · Profile surface routes into personal health editing.
- Profile → Caregiver: opens · Profile surface routes into caregiver settings.
- Profile → Emergency Contacts: opens · Profile surface routes into emergency contacts.
- Profile → Privacy: opens · Profile surface routes into privacy controls.
- Profile → Notifications: opens · Profile surface routes into notification settings.
- Profile → Appearance: opens · Profile surface routes into appearance settings.
- Base Activity → Theme Helper: applies · Shared activity behavior centralizes theming.
- Appearance → Theme Helper: configures · Appearance settings update shared theme state.
