# tuuhin/recorderapp architecture

> Architecture diagram of the GitHub repository tuuhin/recorderapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tuuhin/recorderapp
- Repository: https://github.com/tuuhin/recorderapp

## Overview

##### Project type and purpose
- This is a modularized Android application (“RecorderApp”) built in Kotlin.
- It follows a clean-architecture style: UI layer (Jetpack Compose + Compose Navigation), domain/use-case layer, data layer (multiple feature/data modules), and platform/infrastructure (Room, DataStore, WorkManager, Android Services).
- Purpose: capture audio, store metadata, organize with categories/bookmarks, play media, expose widgets and shortcuts.

##### High-level file-structure analysis
- Top-level modules:
– app: the Android application entrypoint, manifest, DI graph (RecorderApp.kt), NavHost, build scripts, schema migrations.
– build-logic: custom Gradle plugins for Android, Hilt, Room, Protobuf.
– core/ui & core/utils: shared UI components, themes, animations, common helpers.
– data/\*: one module per domain (bookmarks, categories, database, datastore, interactions, location, player, recorder, recordings, use_case, worker).
– feature/\*: UI-feature modules (recorder UI, player UI, recordings list, categories picker, editor, settings, widget).
- Each data module has data-API (implementation) + domain API + DI module.
- feature modules depend on use_case modules; use_case depends on data modules.
- app module wires everything together with Hilt, provides navigation routes.

a. Main components:
– Presentation Layer:
- Single Activity (MainActivity) hosting Compose NavHost.
- Feature UIs (feature/recorder, feature/player, feature/recordings, feature/categories, feature/settings, feature/widget, feature/editor).
– Domain/Use-Case Layer:
- Use cases in data/use_case module (e.g. CombineRecordingSources, PhoneStateObserverUseCase).
– Data Layer:
- Recorder Service (foreground service for audio capture).
- Player Service (MediaPlayerService for playback).
- Room database (data/database module).
- Proto DataStore (data/datastore module).
- Interactions (shortcuts, sharing, Bluetooth, phone-state).
- Location provider (optional geotagging).
- Worker (WorkManager tasks: remove trash, update paths).
- File providers (for recordings and bookmarks export).
– Cross-cutting:
- Hilt DI graph (bindings from all modules).
- Protobuf codegen for settings & widgets.
- Shared core/ui and core/utils.
– External Android OS: AudioRecord, MediaCodec, MediaSession, NotificationManager, WorkManager, ContentResolver, DataStore API.

b. Interactions & data flows:
1. User taps “Record” in UI → ViewModel (feature) → UseCase (start recording) → Recorder Service (data/recorder) → AudioRecord API → Room or file.
2. Service emits amplitude → ViewModel observes via Flow → UI amplitude graph.
3. Stop recording → use case writes metadata into Room (data/database) + stores settings in DataStore.
4. User navigates to “Recordings” → ViewModel → UseCase fetch recordings → Data providers (data/recordings) → ContentResolver/File system → returns list.
5. Play media → ViewModel → UseCase → PlayerService → ExoPlayer/MediaSession → Notification controls.
6. Categories/bookmarks creation → UseCase → repository → Room or CSV exporter (data/bookmarks).
7. Widgets update via Proto buffers (feature/widget + broadcast receivers).
8. Scheduled cleanup via WorkManager (data/worker).

c. Architectural patterns & design principles
- Clean Architecture: separation of presentation/domain/data.
- MVVM: Compose UI + ViewModels for each screen.
- Modularity: each feature and each data concern is its own Gradle module.
- Dependency Injection: Hilt modules in each module, unified in app.
- Service-oriented: Android Services for background tasks (record, play).
- Reactive streams: Kotlin Flows for state.

d. Key technologies & frameworks
- Kotlin + Coroutines + Flow
- Jetpack Compose + Navigation Compose
- Hilt (Dagger) for DI
- Room for local database
- Proto DataStore for typed key-value storage
- WorkManager for background workers
- Android Services + Notifications for media controls
- Protobuf for settings & widgets

##### Essential details to capture
- Single-Activity + multiple feature Composables.
- Two background services (recorder & player).
- Room + DataStore + WorkManager + ContentResolver flows.
- UseCase boundary between UI and data.
- Hilt modules wiring.
- Widgets via broadcast receivers and Proto models.
- Shortcuts & interactions as separate data module.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Presentation Layer"
    direction TB
    App["RecorderApp\n(Application Entry & Hilt Graph)"]:::presentation
    MainAct["MainActivity\n(Single-Activity Host)"]:::presentation
    NavHost["AppNavHost\n(Compose NavHost)"]:::presentation
    subgraph "Feature UIs"
      direction TB
      RecUI["Recorder UI"]:::presentation
      PlayUI["Player UI"]:::presentation
      RecsUI["Recordings List UI"]:::presentation
      CatUI["Categories Picker UI"]:::presentation
      EditUI["Audio Editor UI"]:::presentation
      SetUI["Settings UI"]:::presentation
      WidgetUI["App Widget UI"]:::presentation
    end
  end

  subgraph "Core Modules"
    direction TB
    CoreUI["Core UI Components & Themes"]:::presentation
    CoreUtils["Core Utilities"]:::domain
  end

  subgraph "Domain / Use-Case Layer"
    direction TB
    CombineUC["CombineRecordingSources"]:::domain
    PhoneUC["PhoneStateObserverUseCase"]:::domain
  end

  subgraph "Data / Infrastructure Layer"
    direction TB
    RecService["VoiceRecorderService"]:::infrastructure
    PlayService["MediaPlayerService"]:::infrastructure
    RoomDB["RecorderDataBase & DAOs"]:::infrastructure
    DataStoreRepo["RecorderAudioSettingsRepoImpl"]:::infrastructure
    Bookmarks["RecordingBookMarkProviderImpl"]:::infrastructure
    Categories["RecordingsCategoryProviderImpl"]:::infrastructure
    Interactions["Interactions Module"]:::infrastructure
    Location["CoarseLocationProviderImpl"]:::infrastructure
    RemoveWorker["RemoveTrashRecordingWorker"]:::infrastructure
    UpdateWorker["UpdateRecordingPathWorker"]:::infrastructure
  end

  subgraph "External Android OS"
    direction TB
    AudioRec["AudioRecord API"]:::external
    MediaCodec["MediaCodec"]:::external
    MediaSession["MediaSession"]:::external
    Notification["NotificationManager"]:::external
    WorkMgrAPI["WorkManager"]:::external
    ContentRes["ContentResolver / FileSystem"]:::external
    DataStoreAPI["DataStore API"]:::external
  end

  App --> MainAct
  MainAct --> NavHost
  NavHost --> RecUI
  NavHost --> PlayUI
  NavHost --> RecsUI
  NavHost --> CatUI
  NavHost --> EditUI
  NavHost --> SetUI
  NavHost --> WidgetUI

  RecUI -->|"startRecording()"| CombineUC
  CombineUC --> RecService
  RecService --> AudioRec
  AudioRec --> RecService
  RecService -->|"flow amplitude"| RecUI
  RecUI -->|"stopRecording()"| CombineUC
  CombineUC --> RoomDB
  CombineUC --> DataStoreRepo

  RecsUI -->|"fetchRecordings()"| PhoneUC
  PhoneUC --> RoomDB
  PhoneUC --> ContentRes

  PlayUI -->|"play() UseCase"| CombineUC
  CombineUC --> PlayService
  PlayService --> MediaSession
  PlayService --> Notification

  CatUI -->|"manageCategories()"| CombineUC
  CombineUC --> Categories
  CatUI -->|"manageBookmarks()"| CombineUC
  CombineUC --> Bookmarks

  WidgetUI -->|"updateWidgets()"| DataStoreRepo
  WidgetUI -->|"broadcast"| Interactions

  RemoveWorker --> WorkMgrAPI
  UpdateWorker --> WorkMgrAPI
  RemoveWorker --> RoomDB
  UpdateWorker --> RoomDB

  Interactions --> ContentRes
  Interactions -->|"phoneState"| PhoneUC
  Location --> CombineUC
  CoreUI --> RecUI
  CoreUtils --> CombineUC

  classDef presentation fill:#D0E8FF,stroke:#0B6FA4,stroke-width:1px
  classDef domain fill:#D0FFD6,stroke:#28A745,stroke-width:1px
  classDef infrastructure fill:#FFE5B4,stroke:#DA7C0C,stroke-width:1px
  classDef external fill:#E5E5E5,stroke:#888,stroke-width:1px

  click App "https://github.com/tuuhin/recorderapp/blob/main/app/src/main/java/com/eva/recorderapp/RecorderApp.kt"
  click MainAct "https://github.com/tuuhin/recorderapp/blob/main/app/src/main/java/com/eva/recorderapp/MainActivity.kt"
  click NavHost "https://github.com/tuuhin/recorderapp/blob/main/app/src/main/java/com/eva/recorderapp/navigation/AppNavHost.kt"
  click CoreUI "https://github.com/tuuhin/recorderapp/tree/main/core/ui/src/main/java/com/eva/ui"
  click CoreUtils "https://github.com/tuuhin/recorderapp/tree/main/core/utils/src/main/java/com/eva/utils"
  click CombineUC "https://github.com/tuuhin/recorderapp/blob/main/data/use_case/src/main/java/com/eva/use_case/usecases/CombineRecordingSources.kt"
  click PhoneUC "https://github.com/tuuhin/recorderapp/blob/main/data/use_case/src/main/java/com/eva/use_case/usecases/PhoneStateObserverUseCase.kt"
  click RoomDB "https://github.com/tuuhin/recorderapp/blob/main/data/database/src/main/java/com/eva/database/RecorderDataBase.kt"
  click DataStoreRepo "https://github.com/tuuhin/recorderapp/blob/main/data/datastore/src/main/java/com/eva/datastore/data/repository/RecorderAudioSettingsRepoImpl.kt"
  click RecService "https://github.com/tuuhin/recorderapp/blob/main/data/recorder/src/main/java/com/eva/recorder/data/service/VoiceRecorderService.kt"
  click PlayService "https://github.com/tuuhin/recorderapp/blob/main/data/player/src/main/java/com/eva/player/data/service/MediaPlayerService.kt"
  click Bookmarks "https://github.com/tuuhin/recorderapp/blob/main/data/bookmarks/src/main/java/com/eva/bookmarks/RecordingBookMarkProviderImpl.kt"
  click Categories "https://github.com/tuuhin/recorderapp/blob/main/data/categories/src/main/java/com/eva/categories/data/RecordingsCategoryProviderImpl.kt"
  click Interactions "https://github.com/tuuhin/recorderapp/tree/main/data/interactions/src/main/java/com/eva/interactions/data"
  click Location "https://github.com/tuuhin/recorderapp/blob/main/data/location/src/main/java/com/eva/location/provider/CoarseLocationProviderImpl.kt"
  click RemoveWorker "https://github.com/tuuhin/recorderapp/blob/main/data/worker/src/main/java/com/eva/worker/RemoveTrashRecordingWorker.kt"
  click UpdateWorker "https://github.com/tuuhin/recorderapp/blob/main/data/worker/src/main/java/com/eva/worker/UpdateRecordingPathWorker.kt"
  click RecUI "https://github.com/tuuhin/recorderapp/tree/main/feature/recorder/src/main/java/com/eva/feature_recorder"
  click PlayUI "https://github.com/tuuhin/recorderapp/tree/main/feature/player/src/main/java/com/eva/feature_player"
  click RecsUI "https://github.com/tuuhin/recorderapp/tree/main/feature/recordings/src/main/java/com/eva/feature_recordings"
  click CatUI "https://github.com/tuuhin/recorderapp/tree/main/feature/categories/src/main/java/com/eva/feature_categories"
  click EditUI "https://github.com/tuuhin/recorderapp/tree/main/feature/editor/src/main/java/com/eva/feature_editor"
  click SetUI "https://github.com/tuuhin/recorderapp/tree/main/feature/settings/src/main/java/com/eva/feature_settings"
  click WidgetUI "https://github.com/tuuhin/recorderapp/tree/main/feature/widget/src/main/java/com/eva/feature_widget"
```
