# albinpk/tasque architecture

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

- Interactive diagram: https://gitdiagram.com/albinpk/tasque
- Repository: https://github.com/albinpk/tasque

## Overview

##### Main Components
- Mobile Application UI: Illustrate the Flutter front-end that includes screens such as the Dashboard, Task List, Task Details, and Authentication screens.
- State Management: Include the Bloc (Cubit) layer managing reactive state changes.
- Data Layer (Repositories):
- Local Database Component: ObjectBox used for local persistent storage.
- Remote Data Source: Firebase Firestore syncing tasks in real time.
- Repository Abstractions: Separate modules such as task_repository.dart and task_sync_repository.dart backed by the repository pattern.
- Core Utilities: Highlight common utilities (themes, routing, notifications, logger) present under the “core” module.
- Feature Modules: Identify the separate feature directories (e.g., “src/features/auth” and “src/features/task”) that encapsulate domain-specific business logic and UI.
- External Services: Firebase Authentication and Google Sign-In for user authentication.
- Navigation: The “GoRouter” navigation arrangement, with a centralized control in routes.dart.

##### Relationships and Data Flow
- User Interactions on the UI trigger actions handled by the Cubit (business logic) layer.
- The Cubit interacts with repository classes in the data layer, which abstract access to both the local ObjectBox database and Firebase Firestore.
- The repositories also handle synchronization between local and remote data sources.
- External services (Firebase Auth, Google Sign-In, and Firestore) are shown connecting with the repository layer for authentication and real-time data synchronization.
- The core utilities (routing, themes, and notifications) serve as shared services used across different features.

##### Architectural Patterns and Important Design Principles
- Feature-based Modularity: The project is divided into “features”, “core”, and “shared” components which clearly separate concerns.
- Repository Pattern: Abstracts data access via local (ObjectBox) and remote (Firebase) repositories.
- Reactive State Management: Using Bloc (Cubit) for a predictable and scalable state flow.
- Separation of UI and Business Logic: Leveraging the clean architecture where UI components and business logic do not directly interact with data sources.
- Monorepo Structure: Managed with Melos, ensuring that shared components and multiple packages are managed centrally.

##### Relevant Technologies and Frameworks
- Flutter: The primary framework for building the UI.
- Bloc (Cubit): For state management.
- GoRouter: For navigation and deep linking.
- ObjectBox: For local database storage.
- Firebase Firestore & Firebase Auth: For remote data storage and user authentication.
- Google Sign-In: Supporting user authentication.
- Additional UI/UX libraries: Lottie for animations, form_builder_validators for validations, etc.

##### Putting It All Together
- Branch into two main layers: "Presentation Layer" and "Data/Business Logic Layer".
- Under the Presentation Layer: Show the different screens (Dashboard, Task List, Task Details, Authentication) and a navigation component indicating GoRouter.
- In the Business Logic Layer: Represent the Bloc (Cubit) layer that processes user input and handles state changes.
- A Local Data Source (ObjectBox) block.
- A Remote Data Source block (Firebase Firestore and Firebase Auth).

## Diagram (Mermaid)

```mermaid
graph TD
    A["Tasque Flutter App"]:::main

    subgraph "Presentation Layer"
        UI1["Dashboard Screen"]:::presentation
        UI2["Task List Screen"]:::presentation
        UI3["Task Details Screen"]:::presentation
        UI4["Create Task View"]:::presentation
        UI5["Authentication Screen"]:::presentation
        UI6["Navigation (GoRouter)"]:::presentation
        FMAuth["Authentication Feature Module"]:::presentation
        FMTask["Task Feature Module"]:::presentation
    end

    subgraph "Business Logic Layer"
        BL1["Task Cubit"]:::business
        BL2["Task State"]:::business
    end

    subgraph "Data Layer"
        subgraph "Local Data Source"
            DB1["Local DB (ObjectBox)"]:::data
            DRL["Task Repository (Local)"]:::data
        end
        subgraph "Remote Data Source"
            RTR["Task Sync Repository"]:::data
            FTSR["Firebase Task Sync Repository"]:::data
            AuthS["Auth Services (Firebase Auth & Google Sign-In)"]:::external
        end
    end

    subgraph "Core Utilities"
        CU1["Global App Setup"]:::utilities
        CU2["Router Setup"]:::utilities
        CU3["Routes Definitions"]:::utilities
        CU4["Themes"]:::utilities
        CU5["Notifications"]:::utilities
        CU6["Logger"]:::utilities
        CU7["Shared Extensions & Widgets"]:::utilities
    end

    %% Connections from top-level app to layers
    A --> UI1
    A --> UI2
    A --> UI3
    A --> UI4
    A --> UI5
    A --> UI6
    A --> FMAuth
    A --> FMTask
    A --> BL1
    A --> DRL
    A --> RTR
    A --> CU1

    %% Presentation to Business Logic and Feature Modules
    UI2 -->|"triggers"| BL1
    UI3 -->|"triggers"| BL1
    UI4 -->|"triggers"| BL1
    UI5 -->|"triggers"| AuthS
    UI6 -->|"uses"| CU2
    FMAuth -->|"contains"| UI5
    FMTask -->|"contains"| UI2
    FMTask -->|"contains"| UI3
    FMTask -->|"contains"| UI4

    %% Business Logic internal flow
    BL1 -->|"updates"| BL2
    BL1 -->|"calls"| DRL
    BL1 -->|"calls"| RTR

    %% Data Layer flows
    DRL -->|"reads/writes"| DB1
    RTR -->|"syncs"| FTSR
    RTR -->|"auth"| AuthS

    %% Core Utilities and Navigation
    CU2 -->|"defines"| CU3
    UI6 -->|"configuredBy"| CU2
    UI6 -->|"configuredBy"| CU3

    %% Class Definitions for styling
    classDef main fill:#D3E4CD,stroke:#333,stroke-width:2px;
    classDef presentation fill:#FFF2CC,stroke:#333,stroke-width:2px;
    classDef business fill:#CCE5FF,stroke:#333,stroke-width:2px;
    classDef data fill:#D1E7DD,stroke:#333,stroke-width:2px;
    classDef external fill:#F8D7DA,stroke:#333,stroke-width:2px;
    classDef utilities fill:#E2E3E5,stroke:#333,stroke-width:2px;

    %% Click Events for Mobile Application UI
    click UI5 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/auth/presentation/login_screen.dart"
    click UI2 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/presentation/task_list_screen.dart"
    click UI3 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/presentation/task_details_screen.dart"
    click UI4 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/presentation/create_task_view.dart"

    %% Click Events for State Management (Bloc/Cubit Layer)
    click BL1 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/presentation/cubit/task_cubit.dart"
    click BL2 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/presentation/cubit/task_state.dart"

    %% Click Events for Data Layer (Repositories)
    click DB1 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/core/db/object_box.dart"
    click DRL "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/data/local/task_local_repository.dart"
    click FTSR "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/data/sync/firebase_task_sync_repository.dart"
    click RTR "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/features/task/data/sync/task_sync_repository.dart"

    %% Click Events for Core Utilities
    click CU1 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/app.dart"
    click CU2 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/core/router/router.dart"
    click CU3 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/core/router/routes.dart"
    click CU4 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/core/themes/app_theme.dart"
    click CU5 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/core/notifications/notification_service.dart"
    click CU6 "https://github.com/albinpk/tasque/blob/dev/apps/tasque/lib/src/shared/logger.dart"
    click CU7 "https://github.com/albinpk/tasque/tree/dev/apps/tasque/lib/src/shared/extensions/"

    %% Click Events for Feature Modules
    click FMAuth "https://github.com/albinpk/tasque/tree/dev/apps/tasque/lib/src/features/auth/"
    click FMTask "https://github.com/albinpk/tasque/tree/dev/apps/tasque/lib/src/features/task/"
```
