# jiangtian616/jhentai architecture

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

- Interactive diagram: https://gitdiagram.com/jiangtian616/jhentai
- Repository: https://github.com/jiangtian616/jhentai

## Overview

##### Main System Components

The system should be divided into these major components:

a. Presentation Layer:
- Pages Module (lib/src/pages/)
- Widgets Module (lib/src/widget/)
- Layout Variants (Mobile, Tablet, Desktop)

b. Business Logic Layer:
- Services Module (lib/src/service/)
- State Management (using GetX)
- Settings Management (lib/src/setting/)

c. Data Layer:
- Database Module (lib/src/database/)
- Network Module (lib/src/network/)
- Local Storage

d. Core Components:
- Models (lib/src/model/)
- Utils (lib/src/utils/)
- Configuration (lib/src/config/)

##### Component Relationships

a. Data Flow:
**UI Layer → Business Logic → Data Layer**
- ↑                 ↓
- Data Flow ───┘

b. Service Dependencies:
**Services ←→ Network Module**
- ↓
**Database Module**
- ↓
**Local Storage**

##### Specific Implementation Details

Key architectural elements:

a. Cross-Platform Support:
- Platform-specific implementations (Android, iOS, Windows, MacOS, Linux)
- Shared core logic

b. Feature Modules:
**Gallery Management**
- ↓
**Download System**
- ↓
**Reading System**
- ↓
**Search & Filter**

##### Technical Stack Highlights

Technologies:
- Flutter (UI Framework)
- GetX (State Management)
- Dio (Network Operations)
- Drift (Local Database)
- ExtendedImage (Image Handling)

##### Design Patterns

Following patterns:
- MVC/MVVM Architecture
- Service Locator Pattern (via GetX)
- Repository Pattern (for data handling)
- Factory Pattern (for platform-specific implementations)

Use these visual elements:
- Blue: UI Components
- Green: Business Logic
- Yellow: Data Layer
- Red: External Services
- Gray: Utilities & Helpers

##### Key Interactions

Flows:
**User Input → Page Logic → Service Layer → Repository**
- ↓            ↓              ↓
- State Mgmt → Network/DB → Local Storage

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Core Layers
    subgraph Presentation
        UI[Presentation Layer]
        Pages[Pages Module]:::ui
        Widgets[Widgets Module]:::ui
        Layout[Layout System]:::ui
    end

    subgraph Business
        Logic[Business Logic Layer]
        Services[Services Module]:::logic
        StateManagement[State Management]:::logic
        Settings[Settings Management]:::logic
    end

    subgraph Data
        DataLayer[Data Layer]
        Database[Database Module]:::data
        Network[Network Module]:::data
        Storage[Local Storage]:::data
        DAO[Database Access Objects]:::data
        DBTables[Database Tables]:::data
    end

    subgraph Core
        Models[Models]:::util
        Utils[Utils]:::util
        Config[Configuration]:::util
        Routes[Routes Management]:::util
        L18n[Localization]:::util
        Constants[Constants]:::util
        Exceptions[Exception Handling]:::util
        Extensions[Extensions]:::util
    end

    %% Relationships
    UI --> Logic
    Logic --> DataLayer
    DataLayer --> Logic
    
    Pages --> Services
    Services --> Network
    Services --> Database
    Database --> Storage
    Database --> DAO
    DAO --> DBTables
    
    StateManagement --> Services
    Settings --> Storage
    
    %% Feature Flow
    GalleryMgmt[Gallery Management]:::logic
    DownloadSys[Download System]:::logic
    ReadingSys[Reading System]:::logic
    SearchFilter[Search & Filter]:::logic
    
    GalleryMgmt --> DownloadSys
    DownloadSys --> ReadingSys
    ReadingSys --> SearchFilter

    %% Click Events
    click Pages "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/pages/"
    click Widgets "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/widget/"
    click Layout "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/pages/layout/"
    click Services "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/service/"
    click Settings "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/setting/"
    click Database "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/database/"
    click Network "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/network/"
    click Models "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/model/"
    click Utils "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/utils/"
    click Config "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/config/"
    click StateManagement "https://github.com/jiangtian616/JHenTai/blob/master/lib/src/pages/base/base_page_logic.dart"
    click Routes "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/routes/"
    click L18n "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/l18n/"
    click Constants "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/consts/"
    click DAO "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/database/dao/"
    click DBTables "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/database/table/"
    click Exceptions "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/exception/"
    click Extensions "https://github.com/jiangtian616/JHenTai/tree/master/lib/src/extension/"

    %% Legend
    subgraph Legend
        UI_Legend[UI Components]:::ui
        Logic_Legend[Business Logic]:::logic
        Data_Legend[Data Layer]:::data
        Util_Legend[Utilities]:::util
    end
```
