# entitycuber/wallhavenerandroid architecture

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

- Interactive diagram: https://gitdiagram.com/entitycuber/wallhavenerandroid
- Repository: https://github.com/entitycuber/wallhavenerandroid

## Overview

##### Project type & purpose (from file tree + README)
This is a **Flutter mobile application** (“Wallpaper App”) with:
- A **Flutter/Dart UI** in `lib/` (pages, widgets)
- A small **service layer** in `lib/services/` (likely networking / thumbnail retrieval)
- An **Android host shell** in `android/` (Gradle build, `MainActivity.kt`, Android manifests/resources)

There is no backend service in this repo; the app most likely talks directly to an **external wallpaper API/provider** (commonly wallhaven, given the name), fetches images/thumbnails, and displays them.

Use the directory boundaries as the first partitioning, then refine into subcomponents:

##### Application / Domain services (Flutter)
- `lib/services/thumbs.dart`
Indicates a service responsible for retrieving/generating/handling thumbnail data.
In a typical Flutter app, this means:
- HTTP requests to an API endpoint
- mapping JSON → model objects (models aren’t explicitly present in tree; may be inside the service or omitted)
- possibly pagination/filters

**Subcomponents:** “Thumbs Service (API client)”, optionally “Models / DTOs” (even if inlined, represent it conceptually)

##### Assets

**Flows:** UI reads assets locally (no network).

##### Platform host (Android)
- `android/app/src/main/kotlin/.../MainActivity.kt`
Flutter Android embedding entry point.
- `android/app/src/main/AndroidManifest.xml` (+ debug/profile manifests)
- `android/app/src/main/res/...`
- Gradle build files: `android/build.gradle`, `android/app/build.gradle`, wrapper, etc.

**Subcomponents:** “MainActivity”, “Android OS APIs”, “Build/Packaging (Gradle)”

Even if the app is “Flutter-only”, include the Android host because it’s part of runtime packaging and (potentially) platform permissions (storage, internet, wallpaper setting).

##### User → Flutter UI
- User navigates Home/Drawer/Wallpaper View
##### Flutter UI → Thumbs Service
- UI triggers “load thumbnails”, “search”, “load next page”, “load wallpaper details”
##### Thumbs Service → External Wallpaper API
- HTTPS requests (REST/JSON)
##### External API → Thumbs Service
- JSON response (metadata, image URLs)
##### Thumbs Service → Flutter UI
- Parsed results used to render grids/lists
##### Flutter UI → Image CDN/Host (direct image fetch)
- either “UI fetches images from Image Host/CDN”
- or “Service returns URLs; Image Loader fetches binary”
##### Image Loader ↔ Cache/Storage (optional but recommended to include)
- Even if not explicit in code tree, real Flutter image loading often involves:
- in-memory cache
- disk cache (if using packages)

##### Platform integration flows (Android)
- **Flutter Engine → Android OS**
- Permissions (Internet, storage), wallpaper setting action (if implemented)
- “Platform Channels / Plugins”

**Goal:** Show what the app is and what it depends on.
Include:
- “User”
- “Wallhavener Flutter App”
- “External Wallpaper API” (and optionally “Image CDN/Host” if separate)
- (Optional) “Device Storage / Cache”
- User interacts with App
- App calls External API (HTTPS)
- App downloads images from Image Host
- App reads/writes cache locally

**Containers inside the app package:**
- Flutter UI Layer (`lib/pages/*`, `lib/widgets/*`)
- Service Layer (`lib/services/thumbs.dart`)
- Image Loading & Caching (conceptual container; annotate “Flutter ImageProvider + caching” or package-based caching if used)
- Android Host Container (`android/…`, `MainActivity.kt`, manifests/resources)

External containers:
- Wallpaper API (REST/JSON)
- Image Host/CDN (binary image content)

Inside “Flutter UI Layer”, show:
- `main.dart` (App bootstrap / route setup)
- `home.dart` (Wallpaper feed/list)
- `wallview.dart` (Detail/fullscreen view)
- `side_drawer.dart` (Filters/nav/settings UI)

Inside “Service Layer”, show:
- `thumbs.dart` (thumbnail retrieval, pagination/filtering, JSON parsing)

- “HomePage → ThumbsService: fetchThumbs(query, page)”
- “WallView → (Image Host): GET imageUrl”

##### Use the file tree as your source of truth for names
- “Home Page (`lib/pages/home.dart`)”
- “Wallpaper View (`lib/pages/wallview.dart`)”
- “Thumbs Service (`lib/services/thumbs.dart`)”
- “Android MainActivity (`android/.../MainActivity.kt`)”

This avoids hand-wavy components that aren’t evidenced in the repo.

##### Likely-but-not-proven elements explicitly as “conceptual”
Example: caching, models, platform channels.
Them as:
- “(Conceptual) Image Cache”
- “(Implicit) JSON Models (in ThumbsService)”
- “(Optional) Platform Channel to Android WallpaperManager”

Labels:
- UI ↔ Service: “Dart objects (thumb metadata)”
- Service ↔ API: “HTTPS REST (JSON)”
- UI/Image Loader ↔ Image Host: “HTTPS (JPEG/PNG binary)”
- App ↔ Storage: “cached files/thumbnails”

##### Runtime boundaries
- “Mobile Device”
- Flutter runtime
- Android OS
- “Internet”
- External API
- Image host

##### Suggested “final architecture” inventory (don’t overthink—split into many components)

**Inside Mobile Device**
- Flutter App
- `main.dart` (bootstrap/router)
- `HomePage` (`home.dart`)
- `WallViewPage` (`wallview.dart`)
- `SideDrawer` (`side_drawer.dart`)
- `ThumbsService` (`thumbs.dart`)
- (Conceptual) Image Loader/Cache
- Android Container
- `MainActivity.kt`
- Android Manifest/Resources
- (Optional) Android Wallpaper Manager / Permissions

**Outside Device**
- Wallpaper API (metadata/search)
- Image CDN/Host (actual image files)

##### Practical next step
Before finalizing, quickly open `pubspec.yaml` and confirm:
- which HTTP library is used (`http`, `dio`, etc.)
- whether any image caching package exists (`cached_network_image`, etc.)
- whether wallpaper-setting plugins exist

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Diagram 1: System Context (C4 L1)
  %% =========================
  subgraph D1["Diagram 1 — System Context (C4 L1)"]
    direction TB

    U1["User"]:::external

    subgraph MD1["Mobile Device"]
      direction TB
      APP1["Wallhavener Flutter App"]:::app
      AND1["Android Container (Flutter embedding)"]:::android
      CACHE1[("Local Cache / Device Storage\n(Conceptual)")]:::storage
    end

    subgraph NET1["Internet"]
      direction TB
      API1["External Wallpaper API\n(REST/JSON)"]:::externalSvc
      CDN1["Image CDN/Host\n(JPEG/PNG binary)"]:::externalSvc
    end

    U1 -->|"interacts (tap/scroll/search)"| APP1
    APP1 -->|"HTTPS/JSON (search/metadata)"| API1
    APP1 -->|"HTTPS/Image (download)"| CDN1
    APP1 <-->|"read/write cached files"| CACHE1
    APP1 -.->|"runtime host / permissions"| AND1
  end

  %% =========================
  %% Diagram 2: Container Diagram (C4 L2)
  %% =========================
  subgraph D2["Diagram 2 — Container Diagram (C4 L2)"]
    direction TB

    subgraph MD2["Mobile Device"]
      direction TB

      subgraph FLUT2["Flutter Runtime (Dart)"]
        direction TB
        UI2["Flutter UI Layer\n(Pages + Widgets)"]:::flutter
        SVC2["Service Layer (Dart)\n(Networking / JSON parsing)"]:::flutter
        IMG2["Image Loading & Caching\n(Conceptual: ImageProvider + cache)"]:::storage
        ASSET2["Asset Bundle\n(icons/branding)"]:::asset
      end

      subgraph AND2["Android OS + Host"]
        direction TB
        HOST2["Android Container\n(Flutter embedding host)"]:::android
        OS2["Android OS APIs\n(Permissions/Storage/Wallpaper/Share)\n(Optional)"]:::android
        BUILD2["Build/Packaging (Gradle)"]:::android
      end
    end

    subgraph NET2["Internet"]
      direction TB
      API2["Wallpaper API\n(REST/JSON)"]:::externalSvc
      CDN2["Image Host/CDN\n(Binary images)"]:::externalSvc
    end

    UI2 -->|"calls (load/search/paginate)"| SVC2
    SVC2 -->|"HTTPS/JSON"| API2
    SVC2 -->|"returns Dart objects + image URLs"| UI2

    UI2 -->|"provides URLs"| IMG2
    IMG2 -->|"HTTPS/Image"| CDN2
    IMG2 <-->|"mem/disk cache (optional)"| IMG2

    UI2 -->|"loads icons/images"| ASSET2

    FLUT2 -.->|"platform channels (optional)"| HOST2
    HOST2 -.->|"permissions/wallpaper/storage"| OS2
    BUILD2 -->|"packages APK/AAB"| HOST2
  end

  %% =========================
  %% Diagram 3: Component Diagram (C4 L3, repo-mapped)
  %% =========================
  subgraph D3["Diagram 3 — Component Diagram (C4 L3)"]
    direction TB

    subgraph REPO3["Flutter App (repo)"]
      direction TB

      subgraph LIB3["lib/ (Flutter/Dart)"]
        direction TB

        MAIN3["App Bootstrap & Routing\n(main.dart)"]:::flutter
        subgraph UI3G["Flutter UI Layer (Presentation)"]
          direction TB
          HOME3["Home Page\n(home.dart)"]:::flutter
          WALL3["Wallpaper View Page\n(wallview.dart)"]:::flutter
          DRAW3["Drawer / Navigation\n(side_drawer.dart)"]:::flutter
        end

        subgraph SVC3G["Service Layer (Dart)"]
          direction TB
          THUMB3["Thumbs Service (API client)\n(thumbs.dart)"]:::flutter
          DTO3["(Implicit) JSON Models / DTOs\n(inlined or minimal)"]:::concept
        end

        IMG3["(Conceptual) Image Loader\n+ Memory/Disk Cache"]:::storage
      end

      subgraph AS3["assets/"]
        direction TB
        ICON3["icons/branding\n(assets/icon/)"]:::asset
      end

      subgraph AND3["android/ (Host shell)"]
        direction TB
        MA3["MainActivity\n(MainActivity.kt)"]:::android
        subgraph MAN3["Android Manifests"]
          direction TB
          MAMAIN3["Main Manifest\n(AndroidManifest.xml)"]:::android
          MADEBUG3["Debug Manifest\n(AndroidManifest.xml)"]:::android
          MAPROF3["Profile Manifest\n(AndroidManifest.xml)"]:::android
        end
        RES3["Android Resources\n(res/)"]:::android
        GROOT3["Gradle Build (root)\n(build.gradle)"]:::android
        GAPP3["Gradle Build (app)\n(app/build.gradle)"]:::android
      end

      PUB3["Flutter Dependencies & Assets\n(pubspec.yaml)"]:::meta
    end

    subgraph EXT3["External Services (Internet)"]
      direction TB
      API3["Wallpaper API\n(REST/JSON)"]:::externalSvc
      CDN3["Image Host/CDN\n(JPEG/PNG)"]:::externalSvc
    end

    %% Component interactions
    MAIN3 -->|"initializes routes/theme"| HOME3
    MAIN3 -->|"registers navigation"| WALL3
    HOME3 -->|"opens filters/nav"| DRAW3

    HOME3 -->|"fetchThumbs(query,page)"| THUMB3
    DRAW3 -->|"updates query/filters"| HOME3
    WALL3 -->|"load details/related"| THUMB3

    THUMB3 -->|"HTTPS/JSON (search/metadata)"| API3
    API3 -->|"JSON response (urls + metadata)"| THUMB3
    THUMB3 -->|"Dart objects (thumb metadata)"| HOME3
    THUMB3 -->|"image URLs"| WALL3
    THUMB3 -.->|"maps JSON -> DTOs"| DTO3

    HOME3 -->|"renders grid: URLs -> Image widgets"| IMG3
    WALL3 -->|"full-screen image: GET imageUrl"| IMG3
    IMG3 -->|"HTTPS/Image"| CDN3

    HOME3 -->|"reads local icons"| ICON3
    DRAW3 -->|"reads local icons"| ICON3

    %% Platform host relationships (optional/implicit)
    MAIN3 -.->|"runs on Flutter engine hosted by"| MA3
    MA3 -.->|"permissions/network/storage (via manifests)"| MAMAIN3
    MA3 -.->|"debug configuration"| MADEBUG3
    MA3 -.->|"profile configuration"| MAPROF3
    MA3 -.->|"resources/themes/icons"| RES3
    GROOT3 -->|"build config"| GAPP3
    GAPP3 -->|"packages app"| MA3

    PUB3 -->|"declares dependencies"| THUMB3
    PUB3 -->|"declares assets"| ICON3
  end

  %% =========================
  %% Click events (from component_mapping)
  %% =========================
  click MAIN3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/lib/main.dart"
  click LIB3 "https://github.com/entitycuber/wallhavenerandroid/tree/master/lib/"
  click HOME3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/lib/pages/home.dart"
  click WALL3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/lib/pages/wallview.dart"
  click DRAW3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/lib/widgets/side_drawer.dart"
  click SVC3G "https://github.com/entitycuber/wallhavenerandroid/tree/master/lib/services/"
  click THUMB3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/lib/services/thumbs.dart"
  click ICON3 "https://github.com/entitycuber/wallhavenerandroid/tree/master/assets/icon/"
  click AND3 "https://github.com/entitycuber/wallhavenerandroid/tree/master/android/"
  click MA3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/app/src/main/kotlin/com/entitydev/wallhavener/MainActivity.kt"
  click MAMAIN3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/app/src/main/AndroidManifest.xml"
  click MADEBUG3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/app/src/debug/AndroidManifest.xml"
  click MAPROF3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/app/src/profile/AndroidManifest.xml"
  click RES3 "https://github.com/entitycuber/wallhavenerandroid/tree/master/android/app/src/main/res/"
  click GROOT3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/build.gradle"
  click GAPP3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/android/app/build.gradle"
  click PUB3 "https://github.com/entitycuber/wallhavenerandroid/blob/master/pubspec.yaml"

  %% =========================
  %% Styles
  %% =========================
  classDef flutter fill:#3B82F6,stroke:#1D4ED8,color:#FFFFFF,stroke-width:1px
  classDef app fill:#2563EB,stroke:#1E40AF,color:#FFFFFF,stroke-width:1px
  classDef android fill:#22C55E,stroke:#15803D,color:#0B1B0F,stroke-width:1px
  classDef externalSvc fill:#FB923C,stroke:#C2410C,color:#1F1308,stroke-width:1px
  classDef external fill:#94A3B8,stroke:#475569,color:#0B1220,stroke-width:1px
  classDef storage fill:#E5E7EB,stroke:#6B7280,color:#111827,stroke-width:1px
  classDef asset fill:#A78BFA,stroke:#6D28D9,color:#140B2D,stroke-width:1px
  classDef concept fill:#F3F4F6,stroke:#9CA3AF,color:#111827,stroke-dasharray: 4 3
  classDef meta fill:#FDE68A,stroke:#B45309,color:#1F1308,stroke-width:1px
```
