# bizz84/starter_architecture_flutter_firebase architecture

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

- Interactive diagram: https://gitdiagram.com/bizz84/starter_architecture_flutter_firebase
- Repository: https://github.com/bizz84/starter_architecture_flutter_firebase

## Overview

##### Main Components
- Presentation Layer: Include modules for each major feature such as Authentication, Jobs, Entries, and Onboarding. Under each, note the corresponding screens/widgets (for example, Custom Sign In Screen, Jobs Screen, Entries Screen, etc.) and the “common_widgets” module.
- Application/State Management Layer: Indicate the presence of Riverpod providers, controllers/notifiers, and services (for example, entriesService, authProviders, and onboarding controllers). Highlight the autogenerated files (using Riverpod Generator) that integrate with business logic.
- Domain Layer: Note the models and business logic – such as AppUser, Job, Entry, and Job-related domain models – which encapsulate the state and rules of the application.
- Data Layer: Illustrate data repositories that manage communication with Firebase and Firestore (e.g., firebase_auth_repository, entries_repository, jobs_repository, onboarding_repository). These are the components responsible for data fetching, storage, and synchronization.
- External Services: Clearly show Firebase services including Firebase Auth (with support from Firebase UI Auth), Cloud Firestore, and Firebase UI for Firestore. Connect these to the Data Layer, indicating that they’re external resources with APIs that the repositories call.

##### Component Interactions
- The Flutter Client (UI Layer) invokes Riverpod providers and controllers when events occur (user interactions on Authentication, Jobs, Entries, or Onboarding screens).
- The Providers and application controllers then initiate calls to the repositories in the Data Layer.
- The Data Layer manages interactions with external Firebase services (Firebase Auth, Cloud Firestore) ensuring that data is read, written, and kept in sync across devices.
- The Routing component (utilizing GoRouter) directs navigation between different feature screens, while providing support for nested navigation flows.
- Additional utilities (like localization, common widgets, and shared preferences providers) serve ancillary roles, enhancing responsiveness and user experience.

##### Architectural Patterns
- Feature-first Modularization: Every feature (authentication, jobs, entries, onboarding) is structured with its own domain, application, and presentation submodules.
- Layered Architecture: Clearly separates UI (presentation), business logic (application/service/controllers), and data handling (repositories with Firebase integration).
- Dependency Injection and State Management are provided by Riverpod, where providers are injected into widgets and other controllers.

##### Relevant Technologies
- Flutter and its widget library as the base UI framework.
- Riverpod (and its generator/lint) for state management and dependency injection.
- GoRouter for navigation.
- Firebase Auth and Cloud Firestore (along with Firebase UI helpers) as backend services.
- Additional libraries like RxDart for reactive programming, Intl for formatting, and Equatable for model simplification are also part of the ecosystem.

##### Essential Architectural Elements
- Integration scripts/configurations for Android, iOS, macOS, and Web to indicate that the client is multi-platform—with a note that the Firebase configuration (google-services.json, GoogleService-Info.plist) connects these clients to the backend.
- Repository pattern used to hide the complexities of Firebase interactions behind well-defined interfaces.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Flutter UI Client"]:::ui

    subgraph "Presentation Layer"
        B["Authentication UI"]:::ui
        C["Jobs UI"]:::ui
        D["Entries UI"]:::ui
        E["Onboarding UI"]:::ui
    end

    subgraph "Common Widgets"
        U["Common Widgets"]:::common
    end

    subgraph "Application/State Management"
        F["Auth Providers"]:::state
        G["Entries Service"]:::state
        H["Jobs Controller"]:::state
        I["Onboarding Controller"]:::state
    end

    subgraph "Domain Layer"
        J["AppUser"]:::domain
        K["Job"]:::domain
        L["Entry"]:::domain
    end

    subgraph "Data Layer"
        M["Firebase Auth Repo"]:::data
        N["Jobs Repository"]:::data
        O["Entries Repository"]:::data
        P["Onboarding Repository"]:::data
    end

    subgraph "Routing"
        Q["GoRouter"]:::routing
    end

    subgraph "External Services"
        R["Firebase Auth"]:::external
        S["Cloud Firestore"]:::external
    end

    %% Connections between layers
    A -->|"routes"| Q

    Q -->|"navigates"| B
    Q -->|"navigates"| C
    Q -->|"navigates"| D
    Q -->|"navigates"| E

    %% Common Widgets shared with Presentation
    U --> B
    U --> C
    U --> D
    U --> E

    %% Presentation to State Management
    B -->|"triggers"| F
    C -->|"triggers"| H
    D -->|"triggers"| G
    E -->|"triggers"| I

    %% State Management to Domain (binding models)
    F -->|"binds"| J
    H -->|"binds"| K
    G -->|"binds"| L

    %% State Management to Data Layer
    F -->|"calls"| M
    H -->|"calls"| N
    G -->|"calls"| O
    I -->|"calls"| P

    %% Data Layer to External Services
    M -->|"authAPI"| R
    N -->|"dataAPI"| S
    O -->|"dataAPI"| S
    P -->|"dataAPI"| S

    %% Click Events
    click A "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/main.dart"
    click B "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/authentication/presentation"
    click C "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/jobs/presentation"
    click D "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/entries/presentation"
    click E "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/onboarding/presentation"
    click U "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/common_widgets"
    click F "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/authentication/presentation/auth_providers.dart"
    click G "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/entries/application"
    click H "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/jobs/presentation"
    click I "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/onboarding/presentation/onboarding_controller.dart"
    click J "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/authentication/domain"
    click K "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/jobs/domain"
    click L "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/features/entries/domain"
    click M "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/authentication/data/firebase_auth_repository.dart"
    click N "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/jobs/data/jobs_repository.dart"
    click O "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/entries/data/entries_repository.dart"
    click P "https://github.com/bizz84/starter_architecture_flutter_firebase/blob/master/lib/src/features/onboarding/data/onboarding_repository.dart"
    click Q "https://github.com/bizz84/starter_architecture_flutter_firebase/tree/master/lib/src/routing"

    %% Classes/Styles
    classDef ui fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef state fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef domain fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef data fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
    classDef routing fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef external fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef common fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
```
