# null2264/yokai architecture

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

- Interactive diagram: https://gitdiagram.com/null2264/yokai
- Repository: https://github.com/null2264/yokai

## Overview

##### Project type and purpose
- This is an Android client application (a fork of Tachiyomi called “Yōkai”), built with Kotlin Multiplatform modules.
- Purpose: a free, open‑source manga reader that integrates local file reading, online catalogue sources, trackers (MyAnimeList, AniList, etc.), backups, and extensions.

##### File structure
Top‑level modules:
- app – Android application module (UI entry point, Gradle config, manifests)
- core – shared utilities (network, storage, preferences), Kermit logging, Kotlin MPP bridges
- data – repository implementations, SQLDelight database layer, migrations
- domain – business‑logic layer (use‑cases/interactors, repository interfaces)
- presentation – shared Compose UI components and widgets
- source – source‑API definitions for online manga sources
- i18n – multilanguage resources via moko‑resources
- buildSrc, gradle, settings – build logic, version catalogs

##### Key insights from README
- Highlights Clean Architecture (separation of UI, domain, data)
- Supports multiple trackers and online sources via plugin‑like extension APIs
- Uses Kotlin Coroutines, SQLDelight, OkHttp, Coil, Glance (app widgets)

##### Main components
a. Android App (app module)
b. Presentation layer (UI/ViewModels in app + presentation modules)
c. Domain layer (interactors/use‑cases in domain module)
d. Data layer (repositories, SQLDelight adapters, network clients in data module)
e. Core utilities (network helper, storage provider, preferences in core module)
f. Source API (source module)
g. i18n engine (moko‑resources in i18n module)
h. External services:
– Online catalogue sources (MangaDex, Cubari, MangaPlus, etc.)
– Trackers (MyAnimeList, AniList, Kitsu, Bangumi, Shikimori, MangaUpdates)
– GitHub Releases (app updates)
i. Local persistence: SQLite via SQLDelight, file system for backups, local extensions

##### Relationships and interactions
- UI/Activity/Compose screens → Presentation ViewModels → Domain interactors → Data repositories → Core helpers → External/DB
- Source module defines interfaces; data layer binds concrete online‑source implementations as plugins
- Domain layer defines repository interfaces; data layer implements them using SQLDelight or network
- Backup/restore flows: Data → Core storage → file system → local backup files
- App update flow: Presentation triggers an update check → data.updater component calls GitHubRelease API → Core installer

##### Architectural patterns and technologies
- Clean Architecture layered approach (UI → Domain → Data → Core)
- MVVM / Model–View–Presenter in UI controllers
- Kotlin Multiplatform (commonMain, androidMain, iosMain in core module)
- SQLDelight for type‑safe DB, coroutine dispatchers for async
- OkHttp + Retrofit‑style interceptors for network, Coil for image loading
- Glance (app widget) and Moko‑resources (i18n)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Layers
    subgraph "UI Layer"
        direction TB
        AndroidApp["Android App\n(App.kt)"]:::ui
        LegacyUI["Legacy UI Controllers\n(Views)"]:::ui
    end

    subgraph "Presentation Layer"
        direction TB
        SharedUI["Shared UI Components\n(Compose)"]:::presentation
        Widgets["App Widgets\n(Glance)"]:::presentation
    end

    subgraph "Domain Layer"
        direction TB
        DomainUC["Use‑Cases / Interactors"]:::domain
    end

    subgraph "Data Layer"
        direction TB
        DataImpls["Repositories\n(SQLDelight, Network)"]:::data
        SQLDelight["SQLDelight Schema & Migrations"]:::data
        AndroidDBHandler["AndroidDatabaseHandler.kt"]:::data
        LegacyData["Legacy Data Package"]:::data
        Trackers["Trackers Implementations"]:::data
        BackupRestore["Backup & Restore Flow"]:::data
        Updater["Updater (GitHub Releases)"]:::data
        Extensions["Extension Manager"]:::data
    end

    subgraph "Core Layer"
        direction TB
        CoreMPP["Core Utilities\n(Network, Storage, Prefs)"]:::core
        AndroidCoreNet["Android Network Helpers"]:::core
        AndroidCorePref["Android Preferences"]:::core
        Archiving["Archiving Module\n(ePub/zip)"]:::core
    end

    subgraph "Source & I18n"
        direction TB
        SourceAPI["Source API Interfaces"]:::data
        i18nEngine["i18n Engine\n(moko‑resources)"]:::core
    end

    subgraph "External Services"
        direction TB
        ExternalSources["Online Catalogue Sources"]:::external
        ExternalTrackers["Trackers Services"]:::external
        GitHubReleases["GitHub Releases API"]:::external
        LocalFS["Local File System"]:::external
    end

    %% Flows
    AndroidApp -->|drives| SharedUI
    LegacyUI -->|drives| SharedUI
    SharedUI -->|calls| DomainUC
    Widgets -->|calls| DomainUC
    DomainUC -->|uses| DataImpls

    DataImpls -->|reads/writes| SQLDelight
    SQLDelight -->|delegates| AndroidDBHandler
    DataImpls -->|implements| LegacyData
    DataImpls -->|loads| Trackers
    DataImpls -->|performs| BackupRestore
    DataImpls -->|performs| Updater
    DataImpls -->|manages| Extensions
    DataImpls -->|binds| SourceAPI

    DataImpls -->|calls| CoreMPP
    DataImpls -->|calls| AndroidCoreNet
    DataImpls -->|calls| AndroidCorePref
    BackupRestore -->|stores| LocalFS
    Extensions -->|stores/fetches| LocalFS
    Updater -->|fetches| GitHubReleases
    SourceAPI -->|connects| ExternalSources
    Trackers -->|connects| ExternalTrackers
    SharedUI -->|localizes| i18nEngine

    %% Click Events
    click AndroidApp "https://github.com/null2264/yokai/blob/master/app/src/main/java/eu/kanade/tachiyomi/App.kt"
    click LegacyUI "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/ui"
    click SharedUI "https://github.com/null2264/yokai/tree/master/presentation/core/src/main/java/yokai/presentation"
    click Widgets "https://github.com/null2264/yokai/tree/master/presentation/widget/src/main/java/yokai/presentation/widget"
    click DomainUC "https://github.com/null2264/yokai/tree/master/domain/src/commonMain/kotlin/yokai/domain"
    click DataImpls "https://github.com/null2264/yokai/tree/master/data/src/commonMain/kotlin/yokai/data"
    click SQLDelight "https://github.com/null2264/yokai/tree/master/data/src/commonMain/sqldelight"
    click AndroidDBHandler "https://github.com/null2264/yokai/blob/master/data/src/androidMain/kotlin/yokai/data/AndroidDatabaseHandler.kt"
    click LegacyData "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/data"
    click Trackers "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/data/track/{anilist,bangumi,kitsu,bangumi,…}"
    click BackupRestore "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/data/backup"
    click Updater "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/data/updater"
    click Extensions "https://github.com/null2264/yokai/tree/master/app/src/main/java/eu/kanade/tachiyomi/extension"
    click CoreMPP "https://github.com/null2264/yokai/tree/master/core/main/src/commonMain/kotlin/eu/kanade/tachiyomi/core"
    click AndroidCoreNet "https://github.com/null2264/yokai/tree/master/core/main/src/androidMain/kotlin/eu/kanade/tachiyomi/network"
    click AndroidCorePref "https://github.com/null2264/yokai/tree/master/core/main/src/androidMain/kotlin/eu/kanade/tachiyomi/preference"
    click Archiving "https://github.com/null2264/yokai/tree/master/core/archive/src/main/java/yokai/core/archive"
    click SourceAPI "https://github.com/null2264/yokai/tree/master/source/api/src/commonMain/kotlin/eu/kanade/tachiyomi/source"
    click i18nEngine "https://github.com/null2264/yokai/tree/master/i18n/src/commonMain/moko-resources"

    %% Styles
    classDef ui fill:#add8e6,stroke:#000,stroke-width:1px
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:1px
    classDef domain fill:#ffff99,stroke:#000,stroke-width:1px
    classDef data fill:#ffcc99,stroke:#000,stroke-width:1px
    classDef core fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef external fill:#90ee90,stroke:#000,stroke-width:1px
```
