# titomitto/counter-mini architecture

> Architecture diagram of the GitHub repository titomitto/counter-mini, 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/titomitto/counter-mini
- Repository: https://github.com/titomitto/counter-mini

## Overview

##### Project type and purpose
- This is a cross-platform Flutter application (“Counter Mini”) implementing Clean Architecture, BDD, TDD and Riverpod state management.
- Its purpose is to serve as a teaching and reference app: a counter with increment, decrement, reset (with confirmation), limits, history tracking and validation.

##### File structure
- Top-level directories:
- android, ios, linux, macos, windows, web – platform integration code generated by Flutter
- lib – the heart of the application, subdivided into “app” and “counter” modules
- test – Gherkin (feature files) and Dart tests
- config files: pubspec.yaml, env.json, analysis_options.yaml, build.yaml
- In lib/app:
- app.dart – root widget
- config/go_router.dart(.g.dart) – routing configuration
- data – shared data definitions
- ui – potential shared UI components
- In lib/counter:
- config/counter_routes.dart(.g.dart) – feature-specific routing
- counter.dart – domain entity and use-cases definitions
- data – repository implementations or in-memory data storage
- ui/notifiers – Riverpod state-notifiers (counter logic)
- ui/screens – Flutter screens (presentation layer)

##### README for additional insights
- Emphasis on:
- Clean Architecture (layered separation)
- BDD (Gherkin feature files under test/counter/*.feature)
- TDD with unit/widget/integration tests
- Riverpod for state management

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External platforms
    Platforms(("Platforms")):::external
    Android(("Android")):::external
    iOS(("iOS")):::external
    Web(("Web")):::external
    macOS(("macOS")):::external
    Windows(("Windows")):::external
    Linux(("Linux")):::external

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

    %% Flutter engine
    FlutterEngine["Flutter Engine"]:::engine
    Platforms --> FlutterEngine

    %% App Core
    subgraph "App Core" 
        direction TB
        AppMain["main.dart"]:::config
        AppEntry["app.dart"]:::config
        GoRouter["go_router.dart"]:::config
        GoRouterGen["go_router.g.dart"]:::config
        CounterRoutes["counter_routes.dart"]:::config
        CounterRoutesGen["counter_routes.g.dart"]:::config
        Env["env.json"]:::config
    end
    click AppMain "https://github.com/titomitto/counter-mini/blob/main/lib/main.dart"
    click AppEntry "https://github.com/titomitto/counter-mini/blob/main/lib/app/app.dart"
    click GoRouter "https://github.com/titomitto/counter-mini/blob/main/lib/app/config/go_router.dart"
    click GoRouterGen "https://github.com/titomitto/counter-mini/blob/main/lib/app/config/go_router.g.dart"
    click CounterRoutes "https://github.com/titomitto/counter-mini/blob/main/lib/counter/config/counter_routes.dart"
    click CounterRoutesGen "https://github.com/titomitto/counter-mini/blob/main/lib/counter/config/counter_routes.g.dart"
    click Env "https://github.com/titomitto/counter-mini/blob/main/env.json"

    FlutterEngine --> AppMain
    AppMain --> AppEntry
    AppEntry --> GoRouter
    AppEntry --> CounterRoutes

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Screens1["counter_screens.dart"]:::presentation
        Screens2["screens.dart"]:::presentation
        SharedUI["ui.dart"]:::presentation
    end
    click Screens1 "https://github.com/titomitto/counter-mini/blob/main/lib/counter/ui/screens/counter_screens.dart"
    click Screens2 "https://github.com/titomitto/counter-mini/blob/main/lib/counter/ui/screens/screens.dart"
    click SharedUI "https://github.com/titomitto/counter-mini/blob/main/lib/app/ui/ui.dart"

    GoRouter -->|navigate| Screens1
    CounterRoutes -->|navigate| Screens2

    %% State Management
    subgraph "State Management" 
        direction TB
        NotifierCode["counter.dart"]:::presentation
        NotifierGen["counter.g.dart"]:::presentation
        NotifiersIndex["notifiers.dart"]:::presentation
    end
    click NotifierCode "https://github.com/titomitto/counter-mini/blob/main/lib/counter/ui/notifiers/counter.dart"
    click NotifierGen "https://github.com/titomitto/counter-mini/blob/main/lib/counter/ui/notifiers/counter.g.dart"
    click NotifiersIndex "https://github.com/titomitto/counter-mini/blob/main/lib/counter/ui/notifiers/notifiers.dart"

    Screens1 -->|dispatch event| NotifierCode
    Screens2 -->|dispatch event| NotifierCode

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        DomainEntity["counter.dart"]:::domain
    end
    click DomainEntity "https://github.com/titomitto/counter-mini/blob/main/lib/counter/counter.dart"

    NotifierCode -->|execute use case| DomainEntity

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RepoIndex["data.dart"]:::data
        HistoryStorage[(In-memory History Storage)]:::storage
    end
    click RepoIndex "https://github.com/titomitto/counter-mini/blob/main/lib/counter/data/data.dart"

    DomainEntity -->|persist history| RepoIndex
    RepoIndex -->|return result| NotifierCode

    %% Test Harness
    TestHarness(("Test Harness")):::external
    FeatureFile["counter.feature"]:::external
    TestFile["counter_test.dart"]:::external
    StepDefs["step/*.dart"]:::external
    click FeatureFile "https://github.com/titomitto/counter-mini/blob/main/test/counter/counter.feature"
    click TestFile "https://github.com/titomitto/counter-mini/blob/main/test/counter/counter_test.dart"
    click StepDefs "https://github.com/titomitto/counter-mini/blob/main/test/counter/step/*.dart"

    TestHarness --> FeatureFile
    TestHarness --> TestFile
    TestHarness -.-> Screens1
    TestHarness -.-> DomainEntity

    %% Styles
    classDef external fill:#ffe4e1,stroke:#ff69b4,stroke-dasharray: 4 2;
    classDef engine fill:#e0ffff,stroke:#008b8b;
    classDef config fill:#d3d3d3,stroke:#696969;
    classDef presentation fill:#add8e6,stroke:#00008b;
    classDef domain fill:#90ee90,stroke:#006400;
    classDef data fill:#f0e68c,stroke:#b8860b;
    classDef storage fill:#ffa500,stroke:#ff8c00;
```
