# chedy256/todo_team architecture

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

- Interactive diagram: https://gitdiagram.com/chedy256/todo_team
- Repository: https://github.com/chedy256/todo_team

## Overview

##### Project Type & Purpose
- This is a Flutter-based, cross-platform (Android & iOS) mobile client for a collaborative “Offline-First” task management system.
- It consumes a remote REST API (JWT-authenticated) and integrates Firebase Cloud Messaging (FCM) for push notifications.

##### File Structure
- Top‐level:
- android/ & ios/ — native platform projects
- lib/ — Dart sources split into controllers (state), models, services, utils, views (UI)
- Key config: .env (backend URL), firebase.json, devtools_options.yaml
- Build files: pubspec.yaml, Gradle scripts, Xcode project files

##### Core Architecture (from README & tree)
- UI Layer: Flutter widgets (lib/views)
- State Management: Provider controllers (lib/controllers)
- Data Layer:
- Sqflite local DB (tasks, users, pending_changes)
- flutter_secure_storage for JWT & credentials
- Networking Layer: HTTP/REST with JWT (lib/services/online_service.dart)
- Notification Layer:
- Local (flutter_local_notifications)
- Push (firebase_messaging + FCM)
- Connectivity & Sync: ConnectivityService + ReconnexionService

##### Main Components
- Presentation/UI Layer
– Widgets & Screens (login, signup, task screens)
- State Layer
– AuthController, TaskProvider, UserProvider
- Services Layer
– ConnectivityService, OnlineService, LocalDatabaseService, SecureStorage, NotifService, ReconnexionService, DialogsService
- Persistence
– Sqflite Database (tasks, users, pending_changes)
– Secure Storage (JWT, expiry)
- Notification Broker
– Local notifications plugin
– FCM client
- External Systems
– Remote REST API server
– Firebase Cloud Messaging

##### Relationships & Data Flow
UI → State Providers (dispatch user actions)
State Providers → Services
- OnlineService ↔ REST API (HTTP + JWT)
- LocalDatabaseService ↔ Sqflite (CRUD + pending_changes)
- SecureStorage ↔ flutter_secure_storage (JWT tokens)
ConnectivityService monitors network → ReconnexionService triggers sync (pending_changes → REST API)
FCM → NotifService → State/UI updates
NotifService schedules local notifications

##### Architectural Patterns & Principles
- Layered Separation of Concerns (UI / State / Data / Network)
- Offline-First Sync Pattern (local queue & reconciliation)
- Provider Pattern for MVVM-like state management
- Dependency Injection of services into controllers
- Secure handling of credentials & token refresh

##### Elements
- UI Widgets & Screens
- Provider Controllers
- Service Modules
- Local DB + Secure Storage
- Connectivity & Sync Services
- Local & Push Notification Flow
- External REST API & FCM endpoints

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation / UI Layer
    subgraph "Presentation / UI Layer"
        direction TB
        LoginScreen["Login Screen"]:::ui
        SignUpScreen["Sign Up Screen"]:::ui
        TasksScreen["Tasks List Screen"]:::ui
        AddTaskScreen["Add Task Screen"]:::ui
        EditTaskScreen["Edit Task Screen"]:::ui
        Widgets["Reusable Widgets"]:::ui
    end

    %% State Layer
    subgraph "State Layer"
        direction TB
        AuthController["AuthController"]:::state
        TaskProvider["TaskProvider"]:::state
        UserProvider["UserProvider"]:::state
    end

    %% Services Layer
    subgraph "Services Layer"
        direction TB
        ConnectivityService["ConnectivityService"]:::service
        OnlineService["OnlineService"]:::service
        LocalDatabaseService["LocalDatabaseService"]:::service
        SecureStorageService["SecureStorage (Service)"]:::service
        NotifService["NotifService"]:::service
        ReconnexionService["ReconnexionService"]:::service
        DialogsService["DialogsService"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        SqfliteDB[(Sqflite DB)]:::persistence
        SecureStorageStore[(Secure Storage)]:::persistence
        TaskModel["Task Model"]:::persistence
        UserModel["User Model"]:::persistence
        CurrentUser["Current User & Session"]:::persistence
        ApiModel["API Response Model"]:::persistence
        TaskFilter["Task Filter DTO"]:::persistence
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        RESTAPI["Remote REST API"]:::external
        FCM["Firebase Cloud Messaging"]:::external
    end

    %% Application Entry Point & Config
    Main["Main Application (DI Setup)"]:::state
    Env[".env"]:::external
    FirebaseConf["firebase.json"]:::external
    DevTools["devtools_options.yaml"]:::external

    %% Relationships
    LoginScreen -->|dispatch actions| AuthController
    SignUpScreen -->|dispatch actions| AuthController
    TasksScreen -->|dispatch actions| TaskProvider
    AddTaskScreen -->|dispatch actions| TaskProvider
    EditTaskScreen -->|dispatch actions| TaskProvider
    Widgets -->|used by| LoginScreen

    AuthController -->|uses| OnlineService
    AuthController -->|uses| SecureStorageService
    TaskProvider -->|uses| OnlineService
    TaskProvider -->|uses| LocalDatabaseService
    UserProvider -->|uses| OnlineService
    UserProvider -->|uses| LocalDatabaseService

    ConnectivityService -->|monitors network| ReconnexionService
    ReconnexionService -->|sync pending_changes| OnlineService

    OnlineService <-->|"HTTP + JWT"| RESTAPI
    LocalDatabaseService <-->|"CRUD"| SqfliteDB
    SecureStorageService <-->|"store tokens"| SecureStorageStore

    FCM -->|push events| NotifService
    NotifService -->|update| TaskProvider
    NotifService -->|schedules| SqfliteDB

    Main -->|initializes| AuthController
    Main -->|initializes| TaskProvider
    Main -->|initializes| UserProvider
    Main -->|config from| Env
    Main -->|config from| FirebaseConf
    Main -->|config from| DevTools

    %% Click Events
    click LoginScreen "https://github.com/chedy256/todo_team/blob/dev/lib/views/auth/login_screen.dart"
    click SignUpScreen "https://github.com/chedy256/todo_team/blob/dev/lib/views/auth/sign_up_screen.dart"
    click TasksScreen "https://github.com/chedy256/todo_team/blob/dev/lib/views/home/tasks_screen.dart"
    click AddTaskScreen "https://github.com/chedy256/todo_team/blob/dev/lib/views/home/add_task_screen.dart"
    click EditTaskScreen "https://github.com/chedy256/todo_team/blob/dev/lib/views/home/edit_task_screen.dart"
    click Widgets "https://github.com/chedy256/todo_team/tree/dev/lib/views/widgets"
    click AuthController "https://github.com/chedy256/todo_team/blob/dev/lib/controllers/auth_controller.dart"
    click TaskProvider "https://github.com/chedy256/todo_team/blob/dev/lib/controllers/task_provider.dart"
    click UserProvider "https://github.com/chedy256/todo_team/blob/dev/lib/controllers/user_provider.dart"
    click ConnectivityService "https://github.com/chedy256/todo_team/blob/dev/lib/services/connectivity_service.dart"
    click OnlineService "https://github.com/chedy256/todo_team/blob/dev/lib/services/online_service.dart"
    click LocalDatabaseService "https://github.com/chedy256/todo_team/blob/dev/lib/services/local_database_service.dart"
    click SecureStorageService "https://github.com/chedy256/todo_team/blob/dev/lib/services/secure_storage.dart"
    click NotifService "https://github.com/chedy256/todo_team/blob/dev/lib/services/notif_service.dart"
    click ReconnexionService "https://github.com/chedy256/todo_team/blob/dev/lib/services/reconnexion_service.dart"
    click DialogsService "https://github.com/chedy256/todo_team/blob/dev/lib/services/dialogs_service.dart"
    click TaskModel "https://github.com/chedy256/todo_team/blob/dev/lib/models/task_model.dart"
    click UserModel "https://github.com/chedy256/todo_team/blob/dev/lib/models/user_model.dart"
    click CurrentUser "https://github.com/chedy256/todo_team/blob/dev/lib/models/current_user.dart"
    click ApiModel "https://github.com/chedy256/todo_team/blob/dev/lib/models/api_model.dart"
    click TaskFilter "https://github.com/chedy256/todo_team/blob/dev/lib/models/task_filter.dart"
    click Main "https://github.com/chedy256/todo_team/blob/dev/lib/main.dart"
    click Env "https://github.com/chedy256/todo_team/blob/dev/.env"
    click FirebaseConf "https://github.com/chedy256/todo_team/blob/dev/firebase.json"
    click DevTools "https://github.com/chedy256/todo_team/blob/dev/devtools_options.yaml"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085;
    classDef state fill:#d4edda,stroke:#155724;
    classDef service fill:#fff3cd,stroke:#856404;
    classDef persistence fill:#f8d7da,stroke:#721c24;
    classDef external fill:#d6d8db,stroke:#1b1e21;
```
