How skiletcool/myunit_java works
1. What this repo is
- A single Android application called MyUnit, built in Java.
- It is a personal organizer that combines auth, notes, finance tracking, health logging, and an AI chat assistant in one app.
2. Top-level app shape
- The app is centered around MainActivity as the host.
- Most user-facing behavior is split into feature fragments under ui/*, with navigation resources in res/navigation.
- This is a classic fragment + ViewModel Android app rather than a multi-module backend/frontend system.
3. Presentation layer
- Each feature has its own UI package:
- ui/auth for login/register
- ui/notes for note list/detail
- ui/finance for income/expense tracking
- ui/health for health/activity logs
- ui/ai for the Gemini chat assistant
- ui/home and ui/settings for app shell and preferences
- The UI layer is driven by Fragments, Adapters for lists, and ViewModels for state and actions.
4. Navigation and screen composition
- nav_graph.xml and nav_graph_home.xml define the screen flow.
- activity_main.xml and the fragment layouts indicate that the app uses a single-activity, multi-fragment structure.
- Bottom navigation and feature menus suggest the app is organized around switching between major modules rather than deep nested screens.
5. Feature boundaries
- The repo is cleanly split into independent business areas:
- Auth: user login/registration and session handling
- Notes: CRUD-style note management plus note detail
- Finance: transactions, balances, analytics-style views
- Health: health log entry and viewing
- AI: chat interface plus AI context integration
- These features appear to share common persistence patterns but remain separate at the UI and repository levels.
6. Local data layer
- Persistent app data is stored locally with Room on top of SQLite.
- The database layer is anchored by AppDatabase, with DAOs for:
- UserDao
- NoteDao
- FinanceRecordDao
- HealthRecordDao
- ChatMessageDao
- Entities mirror those domains: User, Note, FinanceRecord, HealthRecord, and ChatMessage.
7. Repository layer
- Each domain has a repository under data/repository:
- UserRepository
- NoteRepository
- FinanceRepository
- HealthRepository
- ChatRepository
- Repositories are the main boundary between UI/ViewModels and data sources.
- They likely mediate between Room storage and, for AI, remote network calls plus context assembly.
8. Remote AI integration
- The only visible remote integration is the Gemini assistant stack in data/remote:
- GeminiApiService
- GeminiRequest
- GeminiResponse
- RetrofitClient
- This indicates the app calls Gemini via Retrofit rather than through a generic backend API.
- The AI feature therefore has a direct outbound network dependency from the app to Google’s generative service.
9. AI context flow
- AIContextManager is a key architectural piece because it bridges user-owned local data and AI prompts.
- The README says the assistant uses context from notes and goals to personalize responses.
- Architecturally, this means the AI flow is not just chat history; it likely aggregates local data from repositories into prompt context before sending the request.
10. State and concurrency
- The README calls out ExecutorService and ListenableFutures, which suggests asynchronous work is off the main thread for database and network operations.
- ViewModels likely expose UI state while repositories perform background I/O.
- This keeps the app responsive during Room access and Gemini calls.
11. Authentication and session handling
- Auth is localized in the app, with LoginFragment, RegisterFragment, AuthViewModel, and UserViewModel.
- SessionManager indicates the app maintains login/session state locally.
- The README mentions BCrypt password hashing, so credentials are not stored in plain text; the secure user record is part of the local persistence model.
12. Cross-cutting utilities and locale support
- LocaleHelper suggests app-wide language or locale switching.
- values-uk resources show Ukrainian localization support.
- These are supporting, cross-cutting concerns rather than standalone business modules.
13. Infrastructure and boundaries to show in a diagram
- The key boundary is between:
- UI/ViewModel layer in ui/*
- Repository layer in data/repository
- Local persistence in Room (AppDatabase, DAOs, entities)
- Remote AI service in data/remote
- There is no obvious separate backend service in the repo; the app is primarily client-side with local storage plus external Gemini API calls.
14. Overall architecture summary
- MyUnit is a single Android client app with a modular feature layout.
- It uses MVVM with Room-backed repositories for local data and a Gemini-powered AI subsystem that can incorporate local context.
- The architecture is optimized for an offline-first personal organizer, with cloud usage limited to AI generation rather than general app storage or authentication services.
Main entry points: repository Repositories · nav_graph.xml Nav graph · MainActivity.java MainActivity · AIViewModel.java AI VM
Components 21
UI layer
Single-activity, multi-fragment presentation layer.
- MainActivity · Single activity that hosts the app shell and fragment navigation.
app/src/main/java/com/example/myunit/MainActivity.java - Home · Main landing shell for the organizer app.
app/src/main/java/com/example/myunit/ui/home/HomeFragment.java - Auth · Login and registration screens plus auth state handling.
app/src/main/java/com/example/myunit/ui/auth - Notes · Note browsing, editing, and detail screens.
app/src/main/java/com/example/myunit/ui/notes - Finance · Income, expense, and transaction tracking screens.
app/src/main/java/com/example/myunit/ui/finance - Health · Health and activity logging screens.
app/src/main/java/com/example/myunit/ui/health - AI chat · Gemini chat assistant and message list UI.
app/src/main/java/com/example/myunit/ui/ai - Settings · App preferences and configuration screen.
app/src/main/java/com/example/myunit/ui/settings/SettingsFragment.java - Auth VM · Coordinates login and registration actions.
app/src/main/java/com/example/myunit/ui/auth/AuthViewModel.java - Notes VM · Drives note list and detail state.
app/src/main/java/com/example/myunit/ui/notes/NoteViewModel.java - Finance VM · Manages transaction and balance state.
app/src/main/java/com/example/myunit/ui/finance/FinanceViewModel.java - Health VM · Manages health log state and actions.
app/src/main/java/com/example/myunit/ui/health/HealthViewModel.java - AI VM · Builds chat requests and feeds assistant responses.
app/src/main/java/com/example/myunit/ui/ai/AIViewModel.java
Data layer
Repositories, Room storage, and remote AI integration.
- Repositories · Domain repositories mediating between UI and storage or network.
app/src/main/java/com/example/myunit/data/repository - AppDatabase · Room database entry point for local persistence.
app/src/main/java/com/example/myunit/data/local/AppDatabase.java - Gemini API · Retrofit-based Gemini request/response integration.
app/src/main/java/com/example/myunit/data/remote/GeminiApiService.java - AI context · Assembles local notes and goals into assistant context.
app/src/main/java/com/example/myunit/data/repository/AIContextManager.java
Cross-cutting
Session, locale, and other app-wide helpers.
- Session manager · Tracks local login/session state.
app/src/main/java/com/example/myunit/utils/SessionManager.java - Locale helper · Supports app language and locale switching.
app/src/main/java/com/example/myunit/utils/LocaleHelper.java
Navigation
Screen flow and fragment composition resources.
- Nav graph · Primary navigation graph for the app flow.
app/src/main/res/navigation/nav_graph.xml - Home graph · Home-area navigation graph for the main shell.
app/src/main/res/navigation/nav_graph_home.xml
Connections 24
- MainActivity → Nav graph: hosts · Main activity hosts the primary navigation flow.
- MainActivity → Home graph: embeds · Activity includes the home shell navigation.
- Nav graph → Auth: routes to · Primary graph routes into auth screens.
- Nav graph → Notes: routes to · Primary graph routes into notes.
- Nav graph → Finance: routes to · Primary graph routes into finance.
- Nav graph → Health: routes to · Primary graph routes into health.
- Nav graph → AI chat: routes to · Primary graph routes into AI chat.
- Nav graph → Settings: routes to · Primary graph routes into settings.
- Home graph → Home: contains · Home graph composes the landing shell.
- Auth → Auth VM: uses · Auth UI is driven by its ViewModel.
- Notes → Notes VM: uses · Notes UI is driven by its ViewModel.
- Finance → Finance VM: uses · Finance UI is driven by its ViewModel.
- Health → Health VM: uses · Health UI is driven by its ViewModel.
- AI chat → AI VM: uses · AI UI is driven by its ViewModel.
- Auth VM → Repositories: calls · Auth logic goes through the repository layer.
- Notes VM → Repositories: calls · Notes logic goes through the repository layer.
- Finance VM → Repositories: calls · Finance logic goes through the repository layer.
- Health VM → Repositories: calls · Health logic goes through the repository layer.
- AI VM → AI context: builds with · Assistant requests are enriched with local context.
- AI VM → Repositories: calls · AI feature persists and retrieves chat data through repositories.
- Repositories → AppDatabase: reads/writes · Domain repositories use Room for local persistence.
- Repositories → Gemini API: calls · AI-related repository work reaches the remote Gemini service.
- Repositories → Session manager: uses · User/session state is handled locally.
- MainActivity → Locale helper: applies · Activity-level locale changes are supported by helper utilities.