# v0-mvp/flutter-bloc-clean-architecture-boilerplate architecture

> Architecture diagram of the GitHub repository v0-mvp/flutter-bloc-clean-architecture-boilerplate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/v0-mvp/flutter-bloc-clean-architecture-boilerplate
- Repository: https://github.com/v0-mvp/flutter-bloc-clean-architecture-boilerplate

## Overview

##### Main Components

a) Presentation Layer (Top Layer)
- Pages/Screens (Authentication, Dashboard, Splash)
- Widgets (Custom Components)
- BLoC/Cubit Components
- UI State Management

b) Domain Layer (Middle Layer)
- Use Cases
- Repository Interfaces
- Domain Entities

c) Data Layer (Bottom Layer)
- Repository Implementations
- Data Sources
- External Services/APIs

##### Specific Implementation Details

- Rectangles with rounded corners for UI components (blue)
- Hexagons for BLoC/Cubit components (purple)
- Rectangles for use cases (orange)

b) Layer Organization:
**┌─────────────────────────────────────────────┐**
- Presentation Layer                          │
- ┌─────────┐ ┌──────────┐ ┌──────────────┐  │
- Pages  │ │ Widgets  │ │ BLoC/Cubit   │  │
- ┘ └──────────┘ └──────────────┘  │
- ┘
- ▲
- Dependencies
- ▼
**┌─────────────────────────────────────────────┐**
- Domain Layer                                │
- ┌─────────┐ ┌──────────────────────┐       │
- Use Cases│ │Repository Interfaces  │       │
- ┘ └──────────────────────┘       │
- ┘
- ▲
- Dependencies
- ▼
**┌─────────────────────────────────────────────┐**
- Data Layer                                  │
- ┌────────────┐ ┌────────────────┐          │
- Repositories│ │Data Sources    │          │
- ┘ └────────────────┘          │
- ┘

##### Key Relationships to Highlight

- Dependency injection flow using GetIt
- BLoC pattern data flow:
- Events → BLoC → States
- BLoC → Repository → DataSource
- Authentication flow:
- SignInScreen → SignInFormBloc → AuthenticationRepository
- Theme management:
- ThemeCubit interaction with UI

##### Additional Elements

Supporting components:
- Error handling flow
- Router configuration (GoRouter)
- Platform-specific implementations
- Common utilities and extensions

##### Implementation Notes

Callouts for:
- Dependency injection setup
- BLoC observer implementation
- Error handling strategy
- Platform-specific considerations
- Testing approach

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef presentation fill:#e1f5fe,stroke:#01579b
    classDef bloc fill:#e1bee7,stroke:#4a148c
    classDef domain fill:#ffe0b2,stroke:#e65100
    classDef data fill:#c8e6c9,stroke:#1b5e20
    classDef common fill:#f5f5f5,stroke:#212121
    classDef interface stroke-dasharray: 5 5

    %% Presentation Layer
    subgraph PresentationLayer["Presentation Layer"]
        Pages["Pages"]:::presentation
        Widgets["Widgets"]:::presentation
        BlocCubit["BLoC/Cubit Components"]:::bloc

        %% Pages
        Pages --> AuthScreens["Authentication Screens"]:::presentation
        Pages --> DashboardScreen["Dashboard Screen"]:::presentation
        Pages --> SplashScreen["Splash Screen"]:::presentation

        %% Widgets
        Widgets --> CustomDialog["Custom Dialog"]:::presentation
        Widgets --> CustomTextForm["Custom Text Form Field"]:::presentation
        Widgets --> CustomButton["Custom Elevated Button"]:::presentation

        %% BLoC/Cubit
        BlocCubit --> AuthBloc["Authentication BLoC"]:::bloc
        BlocCubit --> SignInBloc["Sign In Form BLoC"]:::bloc
        BlocCubit --> ThemeCubit["Theme Cubit"]:::bloc
    end

    %% Domain Layer
    subgraph DomainLayer["Domain Layer"]
        UseCases["Use Cases"]:::domain
        RepoInterfaces["Repository Interfaces"]:::domain
        
        UseCases --> LoginUseCase["Login Use Case"]:::domain
        RepoInterfaces --> AuthRepoInterface["Authentication Repository Interface"]:::interface
    end

    %% Data Layer
    subgraph DataLayer["Data Layer"]
        RepoImpl["Repository Implementations"]:::data
        DataSources["Data Sources"]:::data

        RepoImpl --> AuthRepoImpl["Authentication Repository Impl"]:::data
        DataSources --> AuthDataSource["Authentication Remote Data Source"]:::data
    end

    %% Supporting Components
    subgraph SupportingComponents["Supporting Components"]
        DI["Dependency Injection"]:::common
        Router["Router Configuration"]:::common
        ThemeManagement["Theme Management"]:::common
        ErrorHandling["Error Handling"]:::common
        BlocObserver["BLoC Observer"]:::common
    end

    %% Common Components
    subgraph CommonComponents["Common Components"]
        Constants["Constants"]:::common
        Routes["Routes"]:::common
        Colors["Colors"]:::common
        APIConfig["API Configuration"]:::common
    end

    %% Relationships
    PresentationLayer --> DomainLayer
    DomainLayer --> DataLayer
    SupportingComponents --> PresentationLayer
    CommonComponents --> PresentationLayer

    %% Click events
    click AuthScreens "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/tree/main/lib/src/presentation/page/auth/"
    click DashboardScreen "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/presentation/page/dashboard/dashboard_screen.dart"
    click SplashScreen "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/presentation/page/splash/splash_screen.dart"
    click CustomDialog "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/presentation/widget/custom_dialog.dart"
    click CustomTextForm "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/presentation/widget/custom_text_form_field.dart"
    click CustomButton "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/presentation/widget/custom_elevated_button.dart"
    click AuthBloc "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/tree/main/lib/src/presentation/bloc/authenticator_watcher/"
    click SignInBloc "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/tree/main/lib/src/presentation/bloc/sign_in_form/"
    click ThemeCubit "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/tree/main/lib/src/presentation/cubit/theme/"
    click LoginUseCase "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/domain/usecase/login.dart"
    click AuthRepoInterface "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/domain/repositories/autentication_repository.dart"
    click AuthRepoImpl "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/data/repository/authentication_repository_impl.dart"
    click AuthDataSource "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/data/datasource/authentication_remote_data_source.dart"
    click DI "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/injection.dart"
    click Router "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/utilities/go_router_init.dart"
    click ThemeManagement "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/themes.dart"
    click ErrorHandling "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/exception.dart"
    click BlocObserver "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/utilities/app_bloc_observer.dart"
    click Constants "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/constant.dart"
    click Routes "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/routes.dart"
    click Colors "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/colors.dart"
    click APIConfig "https://github.com/V0-MVP/flutter-bloc-clean-architecture-boilerplate/blob/main/lib/src/comman/api.dart"
```
