# imashnake0/animite architecture

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

- Interactive diagram: https://gitdiagram.com/imashnake0/animite
- Repository: https://github.com/imashnake0/animite

## Overview

##### Main Components
- App Container: Represent the main Android app module. This is where AnimiteApplication and the primary views (Activity/Fragment using Jetpack Compose) reside.
- Feature Modules: Include separate modules for Home, Media, Navigation, Profile, and Social. Each encapsulates its own UI screens (using Compose) and dedicated ViewModels following MVVM.
- API Integration Modules:
– Anilist API module: Contains GraphQL queries, repositories (e.g., AnilistMediaRepository, AnilistSearchRepository, and User repository) and custom data sanitation logic.
– MAL API module: Contains repositories and models that handle MyAnimeList API interactions.
– Preferences module: Manages user settings and app preferences via DataStore.
- Core Module: Contains common extensions, UI components (like progress indicators, layouts, shaders), constants, and helper functions.
- Dependency Injection: The modules are wired together using Hilt for DI, as seen from the Hilt-based components (e.g., AnilistApiModule and the NetworkModule in the MAL module).

##### Relationships and Data Flow
- The UI Layer (in the app and feature modules) interacts with ViewModels that apply MVVM.
- ViewModels interact with repository classes housed in the API modules (AniList, MAL, Preferences) to fetch or mutate data.
- The API modules directly handle network requests using Apollo Kotlin (for GraphQL) and standard HTTP libraries, with data sanitized and mapped to domain models.
- The Core module provides shared utilities and UI components accessible across both the feature and API modules.
- Dependency injection via Hilt connects these layers – UI components get ViewModel instances, which in turn depend on the respective repositories.

##### Architectural Patterns & Technologies
- MVVM is central. Clearly demarcate the View (Compose UI), ViewModel, and Model (repositories, data models from API modules) components.
- Modern Android development practices such as Jetpack Compose for dynamic UI rendering, Kotlin Coroutines for asynchronous operations, and Hilt for dependency injection should be highlighted.
- Use of Apollo Kotlin for GraphQL queries in the AniList API module, indicating that network communication and data retrieval follow a GraphQL-based strategy.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        A["Animite Application (App Container)"]:::ui
        H["Home Feature"]:::ui
        M["Media Feature"]:::ui
        N["Navigation Feature"]:::ui
        P["Profile Feature"]:::ui
        S["Social Feature"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        HV["Home ViewModel"]:::business
        MV["Media ViewModel"]:::business
        PV["Profile ViewModel"]:::business
        SV["Social ViewModel"]:::business
        DI["Hilt DI"]:::di
    end

    %% Data/API Layer
    subgraph "Data/API Layer"
        AL["AniList API Module (GraphQL, Apollo Kotlin)"]:::data
        MAL["MAL API Module"]:::data
        PREF["Preferences API Module"]:::data
    end

    %% Core/Common Layer
    subgraph "Core/Common Layer"
        CORE["Core/Common Module"]:::core
    end

    %% Connections in UI Layer
    A --> H
    A --> M
    A --> N
    A --> P
    A --> S

    %% UI to Business Connections (MVVM)
    H --> HV
    M --> MV
    P --> PV
    S --> SV

    %% Dependency Injection connections (Hilt DI provides ViewModels)
    DI --> HV
    DI --> MV
    DI --> PV
    DI --> SV

    %% Business to Data/API connections via repositories
    HV -->|"fetchesData"| AL
    MV -->|"fetchesData"| MAL
    PV -->|"fetchesData"| PREF
    SV -->|"fetchesData"| AL

    %% Hilt DI Injects API Modules
    DI --> AL
    DI --> MAL
    DI --> PREF

    %% Shared Core/Common usage by UI and Data layers
    H --> CORE
    M --> CORE
    N --> CORE
    P --> CORE
    S --> CORE
    AL --> CORE
    MAL --> CORE
    PREF --> CORE

    %% Click Events
    click A "https://github.com/imashnake0/animite/blob/main/app/src/main/kotlin/com/imashnake/animite/AnimiteApplication.kt"
    click H "https://github.com/imashnake0/animite/tree/main/app/src/main/kotlin/com/imashnake/animite/features/home"
    click M "https://github.com/imashnake0/animite/tree/main/media/"
    click N "https://github.com/imashnake0/animite/tree/main/navigation/"
    click P "https://github.com/imashnake0/animite/tree/main/profile/"
    click S "https://github.com/imashnake0/animite/tree/main/social/"
    click AL "https://github.com/imashnake0/animite/tree/main/api/anilist/"
    click MAL "https://github.com/imashnake0/animite/tree/main/api/mal/"
    click PREF "https://github.com/imashnake0/animite/tree/main/api/preferences/"
    click CORE "https://github.com/imashnake0/animite/tree/main/core/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef data fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef core fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef di fill:#9370DB,stroke:#000,stroke-width:2px;
```
