# wger-project/flutter architecture

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

- Interactive diagram: https://gitdiagram.com/wger-project/flutter
- Repository: https://github.com/wger-project/flutter

## Overview

##### Project type and purpose
- This is a Flutter‐based, cross-platform mobile application (“wger”) that runs on Android, iOS, Linux, macOS, Windows, and Web.
- Its purpose is to present a rich UI for tracking workouts, exercises, body weight, and nutrition, and to persist data both locally and remotely via a REST API on the wger backend server.

##### File structure
- Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” directories: platform embedding projects.
- “lib/” folder: all Dart code is organized into feature and layer subdirectories:
- core (service locator, app bootstrap)
- database (local persistency: exercise and ingredient DAOs, generated code)
- models (data classes, JSON serialization via Freezed/g.dart)
- providers (state management with ChangeNotifier + Provider)
- screens (UI pages)
- widgets (reusable UI components)
- helpers (utility functions, platform detection, shared pref wrappers)
- Configuration files: pubspec.yaml, analysis_options.yaml, l10n.yaml.
- CI/CD: GitHub Workflows, fastlane, flatpak scripts for packaging, integration_test and test folder for automated testing.

##### README
- Confirms this is a pure Flutter mobile app talking via REST to the wger server (`https://wger-master.rge.uber.space`).
- Notes translation/l10n, testing, and contribution instructions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platform & Engine
    subgraph "Platform Runners" 
        direction TB
        Android["Android"]:::infra
        iOS["iOS"]:::infra
        Linux["Linux"]:::infra
        macOS["macOS"]:::infra
        Windows["Windows"]:::infra
        Web["Web"]:::infra
    end
    FlutterEngine["Flutter Engine"]:::core

    Android --> FlutterEngine
    iOS --> FlutterEngine
    Linux --> FlutterEngine
    macOS --> FlutterEngine
    Windows --> FlutterEngine
    Web --> FlutterEngine

    %% Core Service Locator
    Locator["Service Locator\n(core/locator.dart)"]:::core

    FlutterEngine --> Locator

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Screens["Screens"]:::presentation
        Widgets["Widgets"]:::presentation
    end
    FlutterEngine --> Screens
    FlutterEngine --> Widgets

    Screens -->|"uses"| Providers
    Widgets -->|"uses"| Providers

    %% State Management Layer
    Providers["Providers\n(lib/providers/)"]:::state
    Locator --> Providers

    %% Domain Models
    Models["Domain Models\n(lib/models/)"]:::domain
    Providers --> Models
    Models --> Data

    %% Data Layer
    subgraph "Data Layer" 
        direction TB
        subgraph "Local Persistence (SQLite)" 
            direction TB
            ExerciseDAO["ExerciseDB\n(exercise_database.dart)"]:::data
            IngredientDAO["IngredientDB\n(ingredients_database.dart)"]:::data
            TypeConverters["TypeConverters\n(type_converters.dart)"]:::data
            ExerciseDAO -->|"generated code"| ExerciseDAO_G["exercise_database.g.dart"]:::data
            IngredientDAO -->|"generated code"| IngredientDAO_G["ingredients_database.g.dart"]:::data
        end
        subgraph "Remote API Clients" 
            direction TB
            ExerciseAPI["Exercise API\n(exercise_api.dart)"]:::data
            IngredientAPI["Ingredient API\n(ingredient_api.dart)"]:::data
            SessionAPI["Session API\n(session_api.dart)"]:::data
            SessionAPI -->|"generated code"| SessionAPI_G["session_api.g.dart"]:::data
        end
    end

    Providers --> ExerciseDAO
    Providers --> IngredientDAO
    Providers --> ExerciseAPI
    Providers --> IngredientAPI
    Providers --> SessionAPI

    ExerciseDAO -->|"reads/writes"| SQLite["SQLite DB"]:::infra
    IngredientDAO -->|"reads/writes"| SQLite

    ExerciseAPI -->|"HTTPS"| Backend
    IngredientAPI -->|"HTTPS"| Backend
    SessionAPI -->|"HTTPS"| Backend

    %% Localization
    Localization["Localization\n(lib/l10n/, helpers/i18n.dart)"]:::infra
    FlutterEngine --> Localization
    Screens --> Localization
    Widgets --> Localization

    %% External Backend
    Backend["wger REST Backend\n(cloud)"]:::external

    %% CI/CD & Packaging
    subgraph "CI/CD & Packaging" 
        direction TB
        GitHubActions["GitHub Actions\n(.github/workflows/)"]:::infra
        Fastlane["Fastlane\n(fastlane/)"]:::infra
        Flatpak["Flatpak\n(flatpak/)"]:::infra
        Tests["Tests\n(test/, integration_test/)"]:::infra
    end
    Locator --> GitHubActions
    Locator --> Fastlane
    Locator --> Flatpak
    Locator --> Tests

    %% Styles
    classDef presentation fill:#D0E7FF,stroke:#0366d6,stroke-width:1px
    classDef state fill:#DFFFE0,stroke:#28a745,stroke-width:1px
    classDef data fill:#FFECD1,stroke:#f66a0a,stroke-width:1px
    classDef domain fill:#F0E0FF,stroke:#6f42c1,stroke-width:1px
    classDef core fill:#E8F0FC,stroke:#1b6ec2,stroke-width:1px
    classDef infra fill:#F2F2F2,stroke:#586069,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#444444,stroke-width:1px

    %% Click Events
    click Android "https://github.com/wger-project/flutter/tree/master/android/"
    click iOS "https://github.com/wger-project/flutter/tree/master/ios/"
    click Linux "https://github.com/wger-project/flutter/tree/master/linux/"
    click macOS "https://github.com/wger-project/flutter/tree/master/macos/"
    click Windows "https://github.com/wger-project/flutter/tree/master/windows/"
    click Web "https://github.com/wger-project/flutter/tree/master/web/"
    click Screens "https://github.com/wger-project/flutter/tree/master/lib/screens/"
    click Widgets "https://github.com/wger-project/flutter/tree/master/lib/widgets/"
    click Providers "https://github.com/wger-project/flutter/tree/master/lib/providers/"
    click ExerciseDAO "https://github.com/wger-project/flutter/blob/master/lib/database/exercises/exercise_database.dart"
    click ExerciseDAO_G "https://github.com/wger-project/flutter/blob/master/lib/database/exercises/exercise_database.g.dart"
    click IngredientDAO "https://github.com/wger-project/flutter/blob/master/lib/database/ingredients/ingredients_database.dart"
    click IngredientDAO_G "https://github.com/wger-project/flutter/blob/master/lib/database/ingredients/ingredients_database.g.dart"
    click TypeConverters "https://github.com/wger-project/flutter/blob/master/lib/database/exercises/type_converters.dart"
    click ExerciseAPI "https://github.com/wger-project/flutter/blob/master/lib/models/exercises/exercise_api.dart"
    click IngredientAPI "https://github.com/wger-project/flutter/blob/master/lib/models/exercises/ingredient_api.dart"
    click SessionAPI "https://github.com/wger-project/flutter/blob/master/lib/models/workouts/session_api.dart"
    click SessionAPI_G "https://github.com/wger-project/flutter/blob/master/lib/models/workouts/session_api.g.dart"
    click Models "https://github.com/wger-project/flutter/tree/master/lib/models/"
    click Locator "https://github.com/wger-project/flutter/blob/master/lib/core/locator.dart"
    click Localization "https://github.com/wger-project/flutter/tree/master/lib/l10n/"
    click GitHubActions "https://github.com/wger-project/flutter/tree/master/.github/workflows/"
    click Fastlane "https://github.com/wger-project/flutter/tree/master/fastlane/"
    click Flatpak "https://github.com/wger-project/flutter/tree/master/flatpak/"
    click Tests "https://github.com/wger-project/flutter/tree/master/test/"
```
