How niranjan-0/meditrack works
1. Overall shape
MediTrack is a single-process Android app written in Java, with a mostly local-first architecture. The core app runs on-device, persists data in Room (SQLite), and uses a small set of external APIs only for AI chat and nearby clinic lookup.
2. Entry and navigation flow
SplashActivity is the entry point and performs the initial session check through SessionManager. From there, users are routed to either LoginActivity/RegisterActivity/ForgotPasswordActivity or into MainActivity, which acts as the host for the main bottom-navigation experience.
3. Primary user-facing modules
The main experience is split into five feature areas hosted as fragments inside MainActivity: HomeFragment, MedicinesFragment, HealthFragment, ContactsFragment, and NearbyFragment. Separate activities handle focused workflows such as adding a medicine, adding a health log, and chatting with the AI assistant.
4. Persistence boundary
The app’s state is stored locally via AppDatabase and DAOs for User, Medicine, MedLog, HealthLog, and EmergencyContact. This is the main data backbone of the app: UI screens read from Room, and create/update flows write back into Room.
5. UI rendering layer
Lists and cards are rendered through RecyclerView adapters such as MedicineAdapter, HealthLogAdapter, MedLogAdapter, ContactsAdapter, ClinicAdapter, and ChatAdapter. Data Binding is used heavily, which reduces direct view lookups and keeps activity/fragment code focused on behavior rather than manual widget wiring.
6. Medicine reminder workflow
AddMedicineActivity captures a medicine schedule and stores it locally. AlarmHelper schedules reminders, AlarmReceiver fires at the right time, and NotificationHelper displays the reminder notification. MedActionReceiver handles reminder actions, so the reminder loop is: user input → Room → alarm scheduling → broadcast receiver → notification/action handling.
7. Boot-resilience and reminder persistence
BootReceiver restores alarm state after device reboot, which is important because reminders would otherwise be lost. This makes the reminder subsystem durable across restarts and distinguishes the app from a simple in-memory scheduler.
8. Health tracking workflow
AddHealthLogActivity creates log records for measurements like blood pressure, sugar, and weight. HealthFragment consumes those records for history views and charts, and the app uses MPAndroidChart for graphing. This is a classic write-local, read-local analytics loop with no server dependency.
9. Authentication and account safety
Login, registration, and password reset are handled on-device with User data stored in Room. HashUtils suggests credentials or security answers are hashed locally rather than stored in plain text. The ForgotPasswordActivity implements a multi-step recovery flow rather than a simple reset link model, which fits an offline/mobile-only account system.
10. Emergency contacts subsystem
ContactsFragment manages emergency contacts, and ContactsAdapter exposes actions like call, SMS, edit, and delete. This subsystem bridges local contact data with device capabilities such as calling and texting, so it sits at the boundary between app data and phone-native actions.
11. AI assistant integration
ChatActivity provides the AI health assistant experience through the Google Generative AI SDK (Gemini, per README). The ChatAdapter renders the conversation, and the app includes a fallback/demo mode when no API key is configured. This is an external service boundary: prompts go out to Gemini, but the chat UI remains usable without live access.
12. Nearby clinics and maps integration
NearbyFragment combines Google Maps and Places-style clinic discovery with a ClinicAdapter for list presentation. The flow is location in → nearby facility search → map/list output → one-tap navigation. The README indicates a fallback demo dataset when GPS or API access is unavailable, so the feature is intentionally failure-tolerant.
13. Cross-cutting app services
NotificationHelper, AlarmHelper, SessionManager, and HashUtils are the main utility services supporting the app. They centralize notification setup, scheduling, session state, and hashing so the feature screens stay thin and do not duplicate infrastructure logic.
14. Important architectural boundaries to diagram
The most important separation is between:
- Presentation: activities, fragments, adapters, data binding
- Local domain/storage: models, Room entities/DAOs/database
- Device/system integration: alarms, notifications, boot receiver, phone actions
- Cloud integration: Gemini chat and Google Maps/Places lookup
The app is therefore best drawn as a client app centered on local persistence, with two external integration branches for AI and maps.
Main entry points: MainActivity.java Main hub · AppDatabase.java Room DB · MedicineAdapter.java Adapters · SplashActivity.java Splash
Components 21
Presentation
Activities, fragments, adapters, and session/navigation UI.
- Splash · App entry that checks session state and routes users onward.
app/src/main/java/com/meditrack/activities/SplashActivity.java - Auth flow · Login, registration, and password recovery screens.
app/src/main/java/com/meditrack/activities/LoginActivity.java - Main hub · Hosts bottom navigation and the core in-app experience.
app/src/main/java/com/meditrack/activities/MainActivity.java - Home · Landing fragment summarizing the app state.
app/src/main/java/com/meditrack/fragments/HomeFragment.java - Medicines · Medicine list and reminder-oriented management view.
app/src/main/java/com/meditrack/fragments/MedicinesFragment.java - Health · Health log history and charting view.
app/src/main/java/com/meditrack/fragments/HealthFragment.java - Contacts · Emergency contacts management and device actions.
app/src/main/java/com/meditrack/fragments/ContactsFragment.java - Nearby · Nearby clinic discovery and map/list view.
app/src/main/java/com/meditrack/fragments/NearbyFragment.java - Add medicine · Captures medicine schedules and saves them locally.
app/src/main/java/com/meditrack/activities/AddMedicineActivity.java - Add health · Creates local health measurement log records.
app/src/main/java/com/meditrack/activities/AddHealthLogActivity.java - Session · Tracks login state and session persistence.
app/src/main/java/com/meditrack/utils/SessionManager.java - Adapters · RecyclerView adapters for medicines, logs, contacts, clinics, and chat.
app/src/main/java/com/meditrack/adapters/MedicineAdapter.java
Local data
Room-backed models, database, and hashing.
- Room DB · AppDatabase and generated DAO implementations back local persistence.
app/src/main/java/com/meditrack/database/AppDatabase.java - Domain models · User, medicine, logs, contacts, chat, and clinic data models.
app/src/main/java/com/meditrack/models/User.java - Hashing · Hashes credentials or recovery data locally.
app/src/main/java/com/meditrack/utils/HashUtils.java
Device integration
Alarms, notifications, boot persistence, and phone-native actions.
- Reminders · Schedules medicine alerts and restores them after reboot.
app/src/main/java/com/meditrack/utils/AlarmHelper.java - Notifications · Builds and displays reminder notifications.
app/src/main/java/com/meditrack/utils/NotificationHelper.java - Receivers · Alarm, boot, and reminder action receivers.
app/src/main/java/com/meditrack/receivers/AlarmReceiver.java
Cloud services
AI assistant and nearby clinic lookup integrations.
- Chat AI · AI health assistant chat experience.
app/src/main/java/com/meditrack/activities/ChatActivity.java - Gemini · Generative AI backend used by the chat assistant.
- Maps lookup · Nearby clinic discovery and map/list lookup backend.
Connections 26
- Splash → Session: checks session · Splash routes based on stored login state.
- Splash → Auth flow: guest flow · Unauthenticated users are sent to account screens.
- Splash → Main hub: signed in · Authenticated users enter the main experience.
- Main hub → Home: hosts · MainActivity swaps in the home fragment.
- Main hub → Medicines: hosts · MainActivity swaps in the medicines fragment.
- Main hub → Health: hosts · MainActivity swaps in the health fragment.
- Main hub → Contacts: hosts · MainActivity swaps in the contacts fragment.
- Main hub → Nearby: hosts · MainActivity swaps in the nearby clinics fragment.
- Medicines → Room DB: reads/writes · Medicine screens persist schedules and load local data.
- Health → Room DB: reads/writes · Health screens persist and query health logs.
- Contacts → Room DB: reads/writes · Contacts management is backed by Room.
- Auth flow → Room DB: accounts · Login and registration operate on local user data.
- Auth flow → Hashing: hashes · Sensitive account data is hashed locally.
- Add medicine → Room DB: stores · Medicine creation writes a schedule into Room.
- Add medicine → Reminders: schedules · Saved medicine schedules are turned into alarms.
- Reminders → Receivers: fires · Alarm broadcasts are handled by receivers.
- Receivers → Notifications: notifies · Receivers trigger reminder notifications.
- Receivers → Room DB: restores state · Boot handling reloads persisted reminder data.
- Notifications → Medicines: alerts · Notifications surface medicine reminder actions.
- Add health → Room DB: stores · Health measurements are written locally.
- Health → Adapters: renders · RecyclerView adapters render log history and charts support.
- Contacts → Adapters: renders · Adapters provide call, SMS, edit, and delete actions.
- Nearby → Adapters: renders · Clinic results are listed through an adapter.
- Chat AI → Adapters: renders · Chat messages are shown in a conversation list.
- Chat AI → Gemini: AI prompts · Chat exchanges prompts with the AI service.
- Nearby → Maps lookup: location search · Nearby clinic lookup depends on external location/search services.