# suwayomi/tachidesk-sorayomi architecture

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

- Interactive diagram: https://gitdiagram.com/suwayomi/tachidesk-sorayomi
- Repository: https://github.com/suwayomi/tachidesk-sorayomi

## Overview

##### Main Components

a. Client-Side Architecture (Flutter App):
- Presentation Layer
- Features modules (Library, Browse, Reader, Settings, etc.)
- Widgets and UI components
- Domain Layer
- Models and business logic
- Data Layer
- Repositories
- API clients
- Global State Management (Riverpod)

b. Server Integration:
- Tachidesk Server connection
- REST API communication
- Authentication handling

##### Key Architectural Elements

**[Client Layer]**
- UI Components (Flutter Widgets)
- Shell (Navigation)
- Manga Reader
- Library Manager
- Settings Interface

- Feature Modules
- Library
- Browse Center
- Manga Book
- Settings
- Quick Open

- State Management (Riverpod)
- Global Providers
- Feature-specific Controllers

- Data Layer
- Repositories
- API Client (Dio)

**[External Integration]**
- Tachidesk Server
- REST API Endpoints
- Authentication
- Manga Source Management

##### Important Relationships to Highlight

- Feature modules interact with state management through controllers
- Repositories communicate with external Tachidesk server
- UI components observe state changes through Riverpod
- Cross-platform compatibility layers

##### Technical Details

- Flutter/Dart as the primary framework
- Riverpod for state management
- Dio for HTTP client
- JSON serialization with freezed
- Local storage handling
- Platform-specific implementations (Android, iOS, Web, Desktop)

##### Implementation Notes

- How the feature-first folder structure maps to the architecture
- How global providers interact with feature-specific controllers
- Demonstrate the separation of concerns between layers

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        subgraph "UI Layer"
            Shell["Shell/Navigation"]:::ui
            MangaReader["Manga Reader"]:::ui
            LibraryUI["Library UI"]:::ui
            SettingsUI["Settings UI"]:::ui
            MangaCover["Manga Cover Widget"]:::ui
        end

        subgraph "Feature Modules"
            Library["Library Module"]:::feature
            BrowseCenter["Browse Center"]:::feature
            MangaBook["Manga Book"]:::feature
            Settings["Settings"]:::feature
            QuickOpen["Quick Open"]:::feature
        end

        subgraph "State Management"
            GlobalProviders["Global Providers"]:::state
            ReaderController["Reader Controller"]:::state
            LibraryController["Library Controller"]:::state
        end

        subgraph "Data Layer"
            subgraph "Repositories"
                LibraryRepo["Library Repository"]:::data
                MangaRepo["Manga Book Repository"]:::data
                BrowseRepo["Browse Repository"]:::data
            end

            subgraph "API Client"
                DioClient["Dio Client"]:::data
                NetworkModule["Network Module"]:::data
            end
        end

        subgraph "Domain Layer"
            MangaModel["Manga Model"]:::domain
            ChapterModel["Chapter Model"]:::domain
            CategoryModel["Category Model"]:::domain
        end

        subgraph "Configuration"
            AppConstants["App Constants"]:::config
            Endpoints["Endpoints"]:::config
            RouterConfig["Router Config"]:::config
        end
    end

    subgraph "External"
        TachideskServer["Tachidesk Server"]:::external
    end

    %% Relationships
    Shell --> Library
    Shell --> BrowseCenter
    Shell --> MangaBook
    Shell --> Settings
    Shell --> QuickOpen

    Library --> LibraryController
    MangaBook --> ReaderController
    
    LibraryController --> LibraryRepo
    ReaderController --> MangaRepo
    BrowseCenter --> BrowseRepo

    LibraryRepo --> DioClient
    MangaRepo --> DioClient
    BrowseRepo --> DioClient

    DioClient --> NetworkModule
    NetworkModule --> TachideskServer

    LibraryRepo --> MangaModel
    MangaRepo --> MangaModel
    MangaRepo --> ChapterModel
    LibraryRepo --> CategoryModel

    %% Click Events
    click Library "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/features/library"
    click BrowseCenter "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/features/browse_center"
    click MangaReader "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/features/manga_book/presentation/reader"
    click Settings "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/features/settings"
    click QuickOpen "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/features/quick_open"
    click LibraryRepo "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/library/data/category/category_repository.dart"
    click MangaRepo "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/manga_book/data/manga_book_repository.dart"
    click BrowseRepo "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/browse_center/data/source_repository/source_repository.dart"
    click MangaModel "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/manga_book/domain/manga/manga_model.dart"
    click ChapterModel "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/manga_book/domain/chapter/chapter_model.dart"
    click CategoryModel "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/library/domain/category/category_model.dart"
    click GlobalProviders "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/global_providers/global_providers.dart"
    click ReaderController "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/manga_book/presentation/reader/controller/reader_controller.dart"
    click LibraryController "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/features/library/presentation/library/controller/library_controller.dart"
    click DioClient "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/utils/storage/dio/dio_client.dart"
    click NetworkModule "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/utils/storage/dio/network_module.dart"
    click Shell "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/widgets/shell/shell_screen.dart"
    click MangaCover "https://github.com/Suwayomi/Tachidesk-Sorayomi/tree/main/lib/src/widgets/manga_cover"
    click AppConstants "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/constants/app_constants.dart"
    click Endpoints "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/constants/endpoints.dart"
    click RouterConfig "https://github.com/Suwayomi/Tachidesk-Sorayomi/blob/main/lib/src/routes/router_config.dart"

    %% Styles
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef feature fill:#4CAF50,stroke:#2E7D32,color:white
    classDef state fill:#FFC107,stroke:#FFA000,color:black
    classDef data fill:#FF9800,stroke:#F57C00,color:white
    classDef domain fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef config fill:#607D8B,stroke:#455A64,color:white
    classDef external fill:#795548,stroke:#5D4037,color:white
```
