# xdwil/komikku architecture

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

- Interactive diagram: https://gitdiagram.com/xdwil/komikku
- Repository: https://github.com/xdwil/komikku

## Overview

##### Project type and purpose
- Komikku is a feature‑rich Android manga reader app based on TachiyomiSY & Mihon.
- It uses a multi‑module, Clean‑Architecture style setup: UI (app), Presentation libraries, Domain, Data, Core utilities, plus feature‑specific modules (sources, i18n, flags, widgets).

##### Main components
- Presentation/UI Layer (app module + presentation‑core + presentation‑widget)
– Jetpack Compose screens, ViewModels, navigation
- Domain Layer (domain module)
– Use‑case Interactors, Domain models, Repository interfaces
- Data Layer (data module + source‑api + source‑local)
– Repository implementations, mappers, data sources (SQLDelight, SharedPreferences/DataStore, HTTP via OkHttp/Retrofit)
- Core Libraries (core/common, core/archive, core‑metadata)
– Utilities: networking interceptors, archive readers, metadata parsers
- Feature modules
– flagkit (SVG country flags), i18n‑* (multi‑language resources), macrobenchmark, CI scripts
- External services and systems
– Content sources (E‑Hentai, MangaDex, etc.), Trackers (AniList, MAL, Kitsu, …), Cloud backup (Google Drive, YomiSync)
- Persistence & caching

##### Relationships and interactions
1. UI → ViewModel → Domain Use Case (Interactor)
2. Use Case → Repository interface (defined in Domain)
3. Repository impl (in Data Layer) dispatches to:
a. Local data source (SQLDelight DB or DataStore)
b. Remote data source (HTTP APIs via OkHttp/Retrofit)
4. Results → Domain models → mapped to UI models (via Presentation‑Core) → UI
5. Background jobs (WorkManager) trigger Interactors for sync, updates, backup
6. External API calls (sources, trackers, backup) happen via dedicated Service classes

##### Architectural patterns and design principles
- Clean Architecture / Hexagonal: inner Domain surrounded by Data adapters and outer UI.
- Module layering: each Gradle module represents a layer or feature.
- Dependency inversion: Domain defines interfaces, Data & Presentation depend on Domain, not vice versa.
- Single Responsibility & Separation of Concerns at module level.
- DI: DI modules under tachiyomi/di (e.g. AppModule, PreferenceModule).

##### Details
- Multi‑module structure (app, data, domain, core, source‑api, source‑local, presentation‑core, presentation‑widget, flagkit, i18n, macrobenchmark).
- Don’t just list components—show how calls flow between UI, Domain, Data, and External.
- Clean Architecture boundaries and ports/adapters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation / UI Layer
    subgraph "Presentation / UI Layer"
        App["app"]:::ui
        PresCore["presentation-core"]:::ui
        PresWidget["presentation-widget"]:::ui
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Domain["domain"]:::domain
        WorkManager["WorkManager"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        DataModule["data"]:::data
        SourceAPI["source-api"]:::data
        SourceLocal["source-local"]:::data
        SQLDelight["Local DB (SQLDelight)"]:::data
        DataStore["DataStore/Prefs"]:::data
        HTTP["HTTP API Clients"]:::data
        ImageCache["Image Cache (Coil)"]:::data
    end

    %% Core Libraries
    subgraph "Core Libraries"
        Common["core/common"]:::core
        Archive["core/archive"]:::core
        Metadata["core-metadata"]:::core
    end

    %% Feature Modules & Tools
    subgraph "Feature Modules & Tools"
        Flagkit["flagkit"]:::feature
        i18nKMK["i18n-kmk"]:::feature
        i18nSY["i18n-sy"]:::feature
        i18nShared["i18n"]:::feature
        Macro["macrobenchmark"]:::feature
        CI["CI Scripts"]:::feature
    end

    %% External Services
    Sources["Content Sources"]:::external
    Trackers["Trackers"]:::external
    Backup["Cloud Backup"]:::external

    %% Data Flows & Relationships
    App -->|"uses"| Domain
    PresWidget -->|"widget UI calls"| Domain
    Domain -->|"invokes"| DataModule
    WorkManager -->|"triggers jobs in"| Domain

    DataModule -->|"reads/writes"| SQLDelight
    DataModule -->|"reads/writes"| DataStore
    DataModule -->|"caches images in"| ImageCache
    DataModule -->|"implements interfaces using"| SourceAPI
    DataModule -->|"implements interfaces using"| SourceLocal

    SourceAPI -->|"HTTP calls via"| HTTP
    SourceAPI -->|"fetches from"| Sources
    SourceAPI -->|"syncs with trackers"| Trackers
    SourceLocal -->|"local adapters for"| SQLDelight

    DataModule -->|"uses utilities in"| Common
    DataModule -->|"uses archive readers in"| Archive
    DataModule -->|"parses metadata via"| Metadata

    Domain -->|"backups via"| Backup

    %% CI & i18n integration
    CI -->|"builds modules"| App
    CI -->|"builds modules"| DataModule
    CI -->|"builds modules"| Domain
    i18nKMK --> App
    i18nSY --> App
    i18nShared --> App

    %% Click Events
    click App "https://github.com/xdwil/komikku/tree/master/app/"
    click PresCore "https://github.com/xdwil/komikku/tree/master/presentation-core/"
    click PresWidget "https://github.com/xdwil/komikku/tree/master/presentation-widget/"
    click Domain "https://github.com/xdwil/komikku/tree/master/domain/"
    click DataModule "https://github.com/xdwil/komikku/tree/master/data/"
    click SourceAPI "https://github.com/xdwil/komikku/tree/master/source-api/"
    click SourceLocal "https://github.com/xdwil/komikku/tree/master/source-local/"
    click Common "https://github.com/xdwil/komikku/tree/master/core/common/"
    click Archive "https://github.com/xdwil/komikku/tree/master/core/archive/"
    click Metadata "https://github.com/xdwil/komikku/tree/master/core-metadata/"
    click Flagkit "https://github.com/xdwil/komikku/tree/master/flagkit/"
    click i18nKMK "https://github.com/xdwil/komikku/tree/master/i18n-kmk/"
    click i18nSY "https://github.com/xdwil/komikku/tree/master/i18n-sy/"
    click i18nShared "https://github.com/xdwil/komikku/tree/master/i18n/"
    click Macro "https://github.com/xdwil/komikku/tree/master/macrobenchmark/"
    click CI "https://github.com/xdwil/komikku/tree/master/.github/workflows/"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef domain fill:#d4edda,stroke:#155724,color:#155724;
    classDef data fill:#fff3cd,stroke:#856404,color:#856404;
    classDef core fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef feature fill:#ffe5cc,stroke:#e65c00,color:#e65c00;
    classDef external fill:#e8f5e9,stroke:#388e3c,color:#388e3c;
```
