The Problem

MyBrain is an all‑in‑one productivity app that bundles tasks, notes, calendar, diary and bookmarks with a local AI assistant. The codebase is large (696 files, 358 Kotlin modules) and suffers from deep nesting and duplicated data‑module logic, making everyday changes harder than they need to be.

What This Does

The repository is a multi‑module Android app built with Jetpack Compose, Clean Architecture, MVI, and Koin for dependency injection.

  • Core layers live under core/, ai/, bookmarks/, calendar/, diary/, and tasks/. Each domain module (ai/domain, bookmarks/domain, …) defines use‑cases and models, while presentation modules (ai/presentation, bookmarks/presentation, …) compose UI with Compose.
  • Data handling is performed by Room‑backed repositories (ai/data/AiRepositoryImpl.kt, bookmarks/data/BookmarkRepositoryImpl.kt, etc.) and DI modules (ai/data/di/AiDataModule.kt, bookmarks/data/di/BookmarksDataModule.kt, …).
  • AI interaction flows through ai/domain/use_case/SendAiMessageUseCase.ktai/data/repository/AiRepositoryImpl.kt → a local LLM util (ai/data/src/main/java/com/mhss/app/data/LLMUtil.kt).
  • Entry point is app/src/main/java/com/mhss/app/mybrain/MainActivity.kt which sets up the MainScreen and bottom navigation; the MainViewModel (app/src/main/java/com/mhss/app/mybrain/presentation/main/MainViewModel.kt) orchestrates dashboard‑level state (tasks, calendar, notes).

How It Is Wired

Execution starts at MainActivity.ktMainScreenMainBottomBarMainViewModel. The view model consumes use‑cases (SendAiMessageUseCase, AddBookmarkUseCase, …) that in turn delegate to repository implementations.

  • Call graph depth: MainViewModelAddTaskUseCaseTaskRepositoryImplTaskDao → Room. Typical paths are 3‑4 hops.
  • Hub modules: AiDataModule.kt, BookmarksDataModule.kt, CalendarDataModule.kt, DiaryDataModule.kt each contain ~498 repeated 6‑line blocks (measured) that configure nearly identical Room providers, DAOs and DataStore preferences.
  • External touches: The AI module calls ktor client (ai/data/tools/UtilToolSet.kt) for outbound prompts; the alarm module (core/alarm/) interacts with AlarmManager and a PendingIntent for reminders. No network‑level secrets are embedded; all data stays local.

How To Use It

  • Build: The project uses Gradle. No build commands are documented in the README; the standard Android build is
./gradlew assembleDebug
  • Run: After a successful assemble, install via
./gradlew installDebug
  • Configuration: No environment variables or API keys are required; the app is designed to run entirely offline. The only configurable element is the Crowdin localisation project (managed externally).
  • Testing: The repo contains 32 test files, but the GitHub Actions workflow does not invoke the test suite (see Code Health & Issues).

Real-World Use

A user opens the app and taps the AI‑assistant floating button. AssistantScreen.kt presents a chat interface; user input is fed to SendAiPromptUseCase.kt, which calls AiRepositoryImpl.ktLLMUtil.kt to generate a response. The assistant can also create a task: the AI returns a JSON‑like payload that AddTaskUseCase.kt persists via TaskRepositoryImpl.ktTaskDao. The whole flow touches four files and completes in under a second on a typical device.

Code Health & Issues

  • [HIGH] Pin third‑party GitHub Actions to a commit SHA – .github/workflows/build-android.yml references gradle/actions/setup-gradle@v5. A tag can move, so the action running with your token may change without notice. Fix: replace @vN with the 40‑character SHA and let Dependabot bump SHAs.
  • [HIGH] Make CI invoke the test suite it has – only 16 test files exist but no test step appears in any workflow. Add a test execution step to the existing workflow.
  • [LOW] Set timeout-minutes on workflow jobs – the build job has no timeout, risking overlap on the two‑hourly schedule. Add a realistic bound (e.g., timeout-minutes: 180).
  • [HIGH / cognitive_load] Deep nesting in ai/presentation/src/main/java/com/mhss/app/presentation/AssistantScreen.kt, AssistantViewModel.kt, AiAttachmentCards.kt – max indentation depth 11; flatten with guard clauses or extracted helpers.
  • [HIGH / clarity] Duplicated 6‑line blocks across 148 files (e.g., AiDataModule.kt, BookmarksDataModule.kt, CalendarDataModule.kt, DiaryDataModule.kt) – extract shared helpers to DRY the module setup.

The Bottom Line

MyBrain is a fully local, privacy‑first productivity suite with a capable AI assistant and a clean‑architecture codebase. The main strengths are its modular structure, extensive use of Kotlin coroutines/flows, and offline‑only operation. The primary drawbacks are the high cognitive‑load nesting in presentation files and massive duplicated data‑module boilerplate, plus CI that never runs the test suite and an unpinned GitHub Action. It’s suitable for teams that need a self‑contained Android app with AI assistance and are willing to invest in refactoring the nesting and duplication to keep the codebase maintainable.