How tales06/memori works
Project Type and Purpose
• Memori is a single-module Android application built with Kotlin and Jetpack Compose. It follows a full-stack mobile pattern where the “frontend” (UI) lives in the app itself and “backend” components are a mix of local persistence (Room, DataStore) and cloud services (Firebase Auth & Firestore). Its core purpose is offline note taking and organization, with optional PIN-protected folders and bidirectional cloud sync.
File Structure Analysis
• Top-level “app” module containing:
• src/main/java/com/example/memori → code organized by feature (animation, auth, composable, data, database, preference, routes, setup, sync, theme, ui)
• build.gradle.kts + google-services.json → Gradle config and Firebase setup
• MVVM is enforced via separate ViewModel, Repository, DAO, and Composable directories.
• Configuration: AndroidManifest.xml, Proguard rules, DataStore pref files, Firestore and Auth credentials.
Architecture Overview from README
• UI (Jetpack Compose) observes StateFlow/Flow from ViewModels.
• ViewModels delegate data operations to Repositories or directly to Room DAOs/DataStore.
• Repositories encapsulate local Room Database (NoteDatabase + DAOs) and cloud Firestore interactions.
• Firebase Authentication (GoogleAuthClient) manages sign-in; DataStore holds hashed PIN and user preferences.
Main Components
a. Frontend/UI Layer
• Jetpack Compose Screens (HomeScreen, NoteCard, FavoritesScreen, PinSetupScreen, etc.)
• NavigationApp component managing Compose Navigation
b. ViewModel Layer
• NoteViewModel, FolderViewModel, SignInViewModel, ThemeViewModel, etc.
c. Data Layer
• Local: Room Database (NoteDatabase, NotesDao, FoldersDao), Jetpack DataStore for PIN & preferences
• Cloud: FirestoreNoteRepository, FirestoreFolderRepository, GoogleAuthClient
d. External Services
• Firebase Authentication service
• Cloud Firestore service
e. Assets & Config
• Local JSON (assets/data.json) for initial data or AI integration
• google-services.json, backup_rules.xml, data_extraction_rules.xml
Relationships and Data Flows
• UI → ViewModel: user actions (e.g., “create note”) trigger ViewModel functions
• ViewModel → Repository/DAO: ViewModel decides local vs. cloud path
• Repository → Room: synchronous CRUD via DAO
• Repository → Firestore: asynchronous sync when online
• Firestore ↔ Room: bidirectional sync at startup and on data change
• ViewModel → DataStore: read/write PIN and theme preferences
• SignInViewModel → GoogleAuthClient → Firebase Auth → enables Firestore access
Architectural Patterns & Principles
• MVVM divides concerns clearly: composable UI, stateful ViewModels, pure data Repositories
• Single-source-of-truth in Room database; cloud sync augments local data
• Dependency inversion via constructor injection (ViewModels get Repositories)
• Reactive state management with Flow/StateFlow for UI updates