How aritra-tech/medai works
Project Type and Purpose
• MedAI is an Android mobile application (API 21+) built with Kotlin & Jetpack Compose.
• It leverages MVVM + repository pattern, Hilt DI, Google Gemini AI, and Firebase (Auth + Firestore + Analytics + Crashlytics + Messaging).
• Purpose: allow users to upload prescription images, validate & summarize via AI, authenticate with Google/Firebase, and persist data locally and in the cloud.
High-Level Architecture Overview
• Layered architecture with clear separation:
• UI Layer (Compose + ViewModels)
• Domain Layer (Models + Repository Interfaces + Use-Cases)
• Data Layer (Repository Implementations + Data Sources)
• External Services (Firebase endpoints & Google Gemini AI)
• DI Layer (Hilt modules to wire everything)
Main Components
a. UI Layer
• Compose Screens (Login, Onboarding, PrescriptionList, Details, Summarize, Profile, Settings, Splash)
• ViewModels (AuthViewModel, PrescriptionViewModel, PrescriptionDetailsViewModel, PrescriptionSummarizeViewModel, ProfileViewModel, SettingsViewModel, SplashViewModel)
b. Domain Layer
• Models (User, PrescriptionSummary, GeminiPrescriptionResponse, SignInResult)
• Interfaces (AuthRepository, PrescriptionRepository, BiometricAuthListener)
c. Data Layer
• DataStoreUtils (local prefs: dark mode, biometrics, auto-lock)
• AuthRepositoryImpl (uses FirebaseAuth + Google Sign-In)
• PrescriptionRepositoryImpl (uses Firestore + Google Gemini API)
d. External Services
• Firebase Authentication
• Firebase Firestore (prescriptions collection)
• Google Gemini Generative AI API
• Biometric API (AndroidX)
e. DI Layer
• AppModule (provides singletons: FirebaseAuth, Firestore, DataStore, Gemini service, Hilt bindings)
Relationships and Data Flows
• User taps a Compose Screen → ViewModel
• ViewModel calls Domain interfaces → Use-cases (implemented by Repo Impl)
• Repos delegate to Data Sources:
• AuthRepositoryImpl → FirebaseAuth / Google Sign-In
• PrescriptionRepositoryImpl → Google Gemini API for image analysis → Firestore to save/retrieve
• DataStoreUtils for local settings read/write
• Responses bubble back through ViewModel → UI state updates
• DI Layer injects dependencies at each level
Architectural Patterns & Principles
• MVVM (UI ← ViewModel ← Domain ← Data)
• Repository Pattern (abstract data sources behind interfaces)
• Single Responsibility (each package: ui, domain, data, di, utils)
• Dependency Injection with Hilt (loose coupling, testability)
• Coroutine-based async operations (off main thread)