# g-aggarwal/pollinator architecture

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

- Interactive diagram: https://gitdiagram.com/g-aggarwal/pollinator
- Repository: https://github.com/g-aggarwal/pollinator

## Overview

##### Project Type & Purpose
- Pollinator is a native Android application (Jetpack Compose + Kotlin) that transforms text prompts into AI-generated images by calling the Pollinations AI REST API.
- It follows a standard MVVM/mobile client architecture: UI (Compose) → ViewModels → Repository/Data layer → External service.

##### File Structure
- Top-level “app” module: contains everything needed to build the APK.
- src/main/java/com/gauravaggarwal/pollinator — subdivided into:
– data/…: repository interfaces and implementations (GenerationRepository, PollinationsAiRepository)
– model/…: data classes (GenerationParameters, GenerationResult, Models, Sizes)
– ui/…:
- PollinatorApp.kt (entry point + theme host)
- screens/…: Compose screens + ViewModel + UI-state classes
- src/androidTest & src/test: instrumentation & unit tests.
- build.gradle.kts, Gradle wrapper, ProGuard rules, and config files.

##### Extract Additional Insights from README
- Uses Jetpack Compose, Material3, OkHttp.
- Two build variants (debug vs. release).
- Flexible architecture designed for future AI-service integrations.

##### Components & Interactions
a. Main Components
1. Android Platform & OS
2. UI Layer (Jetpack Compose Screens)
3. ViewModel Layer (PollinatorViewModel)
4. Repository Layer (GenerationRepository interface + PollinationsAiRepository implementation)
5. Network Layer (OkHttp HTTP client, JSON serialization)
6. External Service: Pollinations AI REST API
7. (Optional) Local Android Backup Manager (backup_rules.xml)
8. Testing modules (unit + instrumentation)

b. Relationships & Data Flow
- User interacts with Compose UI → sends UI events to ViewModel
- ViewModel transforms events → calls Repository methods
- Repository uses OkHttp to issue HTTP requests to Pollinations AI endpoints → returns GenerationResult
- ViewModel updates UI-state → Compose UI renders images
- Tests invoke ViewModel/Repository directly to validate logic

c. Architectural Patterns & Principles
- MVVM: clear separation between UI (Compose), state/business logic (ViewModel), and data access (Repository)
- Dependency inversion: ViewModel depends on repository interface (GenerationRepository)
- Single-source of truth for UI state via PollinatorUiState
- Theming via centralized theme package

d. Technologies & Frameworks
- Kotlin + Coroutines (assumed in Repository calls)
- Jetpack Compose + Material3
- OkHttp (network)
- Gradle (build system)

##### Putting It All Together
[Android OS/Platform] → [Compose UI Screens] → [ViewModels] → [Repository + OkHttp Client] → [Pollinations AI REST API]
Underneath, add test modules branching off ViewModel & Repository.
Surround everything with a “Pollinator App” boundary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Pollinator App"
        subgraph "Android Platform & OS"
            AndroidOS["Android Platform & OS"]:::platform
        end

        subgraph "UI Layer"
            PollinatorApp["PollinatorApp (Entry + Theme)"]:::ui
            GS["GeneratorScreen"]:::ui
            RS["ResultScreen"]:::ui
            AO["AdvancedOptions"]:::ui
        end

        subgraph "ViewModel Layer"
            VM["PollinatorViewModel"]:::viewmodel
        end

        subgraph "Repository & Network"
            GenRepo["GenerationRepository (interface)"]:::repo
            PollAiRepo["PollinationsAiRepository"]:::repo
            Network["OkHttp HTTP Client & JSON"]:::network
        end

        subgraph "External Services"
            PollAPI["Pollinations AI REST API"]:::external
        end

        subgraph "Local Backup"
            Backup["Android Backup Manager\n(backup_rules.xml)"]:::platform
        end

        subgraph "Testing"
            IT["Instrumentation Tests"]:::test
            UT["Unit Tests"]:::test
        end
    end

    AndroidOS --> PollinatorApp
    PollinatorApp --> GS
    PollinatorApp --> RS
    PollinatorApp --> AO
    GS --> VM
    RS --> VM
    AO --> VM
    VM --> GenRepo
    GenRepo --> PollAiRepo
    PollAiRepo --> Network
    Network --> PollAPI
    VM --> IT
    GenRepo --> UT

    click AndroidOS "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/AndroidManifest.xml"
    click GS "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/ui/screens/GeneratorScreen.kt"
    click RS "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/ui/screens/ResultScreen.kt"
    click AO "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/ui/screens/AdvancedOptions.kt"
    click PollinatorApp "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/ui/PollinatorApp.kt"
    click VM "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/ui/screens/PollinatorViewModel.kt"
    click GenRepo "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/data/GenerationRepository.kt"
    click PollAiRepo "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/java/com/gauravaggarwal/pollinator/data/PollinationsAiRepository.kt"
    click Backup "https://github.com/g-aggarwal/pollinator/blob/main/app/src/main/res/xml/backup_rules.xml"
    click IT "https://github.com/g-aggarwal/pollinator/blob/main/app/src/androidTest/java/com/gauravaggarwal/pollinator/ExampleInstrumentedTest.kt"
    click UT "https://github.com/g-aggarwal/pollinator/blob/main/app/src/test/java/com/gauravaggarwal/pollinator/ExampleUnitTest.kt"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef viewmodel fill:#90EE90,stroke:#333,stroke-width:1px
    classDef repo fill:#FFA500,stroke:#333,stroke-width:1px
    classDef network fill:#FF8C00,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef platform fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef test fill:#F5DEB3,stroke:#333,stroke-width:1px
```
