# dev-tatsuya/flutter-qiita-client architecture

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

- Interactive diagram: https://gitdiagram.com/dev-tatsuya/flutter-qiita-client
- Repository: https://github.com/dev-tatsuya/flutter-qiita-client

## Overview

##### Project Type and Purpose
- The project is a Flutter mobile client application that interacts with the Qiita API.
- It implements a layered architecture using Domain, Infra, and Presentation layers. The app is built with Riverpod for state management as highlighted by the accompanying article in the README.
- Additionally, the project is set up with comprehensive testing layers – including Unit, Widget (visual regression), and End-to-End tests (via Maestro) – and is integrated with GitHub Actions for CI execution.

##### File Structure
- Native Code: The directories “android” and “ios” contain platform-specific configuration and build files. These represent the mobile client wrappers.
- Main Flutter Code: Under the “lib” directory, you have distinct subdirectories:
– domain: Contains Models (e.g., qiita_post.dart, qiita_user.dart, tag.dart), Repository Interfaces, and Service definitions. This is your “business logic” layer.
– infra: Implements the repository and API service functionality including network exception handling and data model serialization. This layer interacts with the external Qiita API.
– presentation: Contains the UI components (pages, widgets, state management, etc.) including the main entry point (app.dart) and various screen implementations.
- Testing: The “test” folder is structured with subdirectories that mirror the code structure—unit tests, widget tests (golden tests), and mocks. There is also a “.maestro” folder for Maestro-based E2E tests.
- CI/CD: The “.github/workflows” contains YAML files for executing unit tests, E2E tests, and visual regression tests (VRT) through GitHub Actions.
- Configuration & Build Tools: Files like Makefile, pubspec.yaml, and .env.template manage build commands, dependencies, and environment variables.

A. Frontend (Presentation Layer):
- “lib/presentation” module representing UI screens, base pages, widget components, and the navigation (page_dispatcher.dart).
- How this layer is the entry point (via lib/main.dart and app.dart) both on native (android / ios) wrappers and Flutter UI.
B. Domain Layer (Business Logic):
- “lib/domain” folder including models (qiita_post, qiita_user, tag) and the repository interface (post_repository.dart) along with service abstractions.
C. Infra Layer (Data Access & API):
- “lib/infra” components which implement the repository (post_repository_impl.dart) and API service (api_service_impl.dart) and handle API calls to Qiita (qiita_api.dart) and error handling.
D. External Services:
- External Qiita API as a service accessed by the Infra layer.
E. Testing and CI/CD Modules:
- Separate testing components:
– Unit tests in the “test” directory that validate both business logic and presentation behavior.
– Widget tests (VRT) using packages like golden_toolkit with image comparison, along with their reporting via reg-suit.
– Integration/E2E tests using Maestro (defined in the “.maestro” directory) to simulate complete UX flows.
- CI jobs as separately triggered components (via GitHub Actions workflows) that automatically execute tests, generate coverage reports, and deploy artifacts.

##### Relationships and Interactions
- Domain layer components (repositories and service abstractions) with their Infra implementations responsible for web/API calls.
- From the Infra layer, indicate the connection to the external Qiita API.
- For testing, show separate “test modules” that mirror these layers and simulate interactions, as well as CI/CD pipelines triggering these tests.

##### Architectural Patterns or Design Principles
- Use of clean architecture to separate concerns: UI (presentation) → business logic (domain) → data/API (infra).
- Use of dependency injection or interfaces for the repository and API service that allow for clear isolability and stubbing/mocking in tests.
- Mention that state management is handled via Riverpod (as inferred from the supporting documentation).

##### Final Advice
- Verify that every key part referenced in the file tree and README (such as the Maestro E2E tests, GitHub Actions workflows, and the separation of concerns in the lib folder) is represented.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Native Wrappers
    subgraph "Native Wrappers"
        N_android("Android"):::native
        N_ios("iOS"):::native
    end

    %% Flutter Entry and Presentation Layer
    P_app("Entry Point (lib/main.dart & app.dart)"):::presentation
    P_ui("UI Screens & Widgets (lib/presentation)"):::presentation

    %% Domain Layer Components
    subgraph "Domain Layer"
        D_post("qiita_post.dart"):::domain
        D_user("qiita_user.dart"):::domain
        D_tag("tag.dart"):::domain
        D_repo("Repository Interface (post_repository.dart)"):::domain
        D_service("Service Abstraction (api_service.dart)"):::domain
    end

    %% Infra Layer Components
    subgraph "Infra Layer"
        I_repo("Repository Impl (post_repository_impl.dart)"):::infra
        I_api("API Service Impl (api_service_impl.dart)"):::infra
        I_qiita("Qiita API (qiita_api.dart)"):::infra
    end

    %% External Service
    EX("External Qiita API"):::external

    %% Testing Modules
    subgraph "Testing Modules"
        T_unit("Unit & Widget Tests (test/)"):::test
        T_golden("Visual Regression Test (post_list_page_golden_test.dart)"):::test
        T_e2e("E2E Tests (.maestro/main.yaml)"):::test
    end

    %% CI/CD Integration
    CICD("GitHub Actions Workflows (.github/workflows)"):::cicd

    %% Connections - Native to Flutter
    N_android --> P_app
    N_ios --> P_app

    %% Presentation Flow
    P_app --> P_ui

    %% Presentation to Domain (User actions)
    P_ui -->|"userAction"| D_repo
    P_ui -->|"userAction"| D_service

    %% Domain to Infra
    D_repo -->|"calls"| I_repo
    D_service -->|"calls"| I_api

    %% Infra to External API
    I_repo -->|"queries"| I_qiita
    I_api -->|"calls"| I_qiita
    I_qiita -->|"responds"| EX

    %% CI/CD triggering Testing Modules
    CICD -->|"triggers"| T_unit
    CICD -->|"triggers"| T_golden
    CICD -->|"triggers"| T_e2e

    %% Styling Classes
    classDef presentation fill:#a3d5ff,stroke:#333,stroke-width:2px;
    classDef domain fill:#ffb3ba,stroke:#333,stroke-width:2px;
    classDef infra fill:#ffffba,stroke:#333,stroke-width:2px;
    classDef external fill:#baffc9,stroke:#333,stroke-width:2px;
    classDef test fill:#c9c9ff,stroke:#333,stroke-width:2px;
    classDef cicd fill:#ffdfba,stroke:#333,stroke-width:2px;
    classDef native fill:#dcdcdc,stroke:#333,stroke-width:2px;

    %% Click Events
    click P_app "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/main.dart"
    click P_ui "https://github.com/dev-tatsuya/flutter-qiita-client/tree/main/lib/presentation"
    click D_post "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/domain/model/qiita_post.dart"
    click D_user "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/domain/model/qiita_user.dart"
    click D_tag "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/domain/model/tag.dart"
    click D_repo "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/domain/repository/post_repository.dart"
    click D_service "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/domain/service/api_service.dart"
    click I_repo "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/infra/repository/post_repository_impl.dart"
    click I_qiita "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/infra/service/api/qiita_api.dart"
    click I_api "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/lib/infra/service/api_service_impl.dart"
    click T_unit "https://github.com/dev-tatsuya/flutter-qiita-client/tree/main/test"
    click T_golden "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/test/presentation/post_list_page_golden_test.dart"
    click T_e2e "https://github.com/dev-tatsuya/flutter-qiita-client/blob/main/.maestro/main.yaml"
    click CICD "https://github.com/dev-tatsuya/flutter-qiita-client/tree/main/.github/workflows"
    click N_android "https://github.com/dev-tatsuya/flutter-qiita-client/tree/main/android"
    click N_ios "https://github.com/dev-tatsuya/flutter-qiita-client/tree/main/ios"
```
