# priyank-0401/flextime architecture

> Architecture diagram of the GitHub repository priyank-0401/flextime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/priyank-0401/flextime
- Repository: https://github.com/priyank-0401/flextime

## Overview

##### Project Type and Purpose
- This is a cross‐platform Flutter application (“flextime_app”) that runs on Android, iOS, Web, and Windows.
- It is structured using a Clean Architecture / feature–driven approach: UI → Presentation → Domain → Data → Core services.

##### File Structure Highlights
- Top-level platform folders: android/, ios/, web/, windows/ (each holds platform embedder code).
- lib/ is the main Dart code:
- core/ – app-wide services, utils, theme, navigation, database setup
- features/ – two major feature sets (“dead_minutes” & “energy_planner”) and shared home, plan, settings
- main.dart – application entry point
- Each feature follows the layers: data/ (models, datasources, repos), domain/ (entities, repos interfaces, use cases), engine/ (business logic), presentation/ (UI pages, providers, widgets).

##### Key Components
a. Presentation Layer
- Flutter Widgets (Pages, Screens, Widgets)
- State Management / Providers
b. Domain Layer
- Use Cases (e.g., SuggestActivities, LogCompletion, TimelineGeneration)
- Entities & Repositories Interfaces
c. Data Layer
- Repository Implementations
- Local Data Sources (e.g., SQLite via app_database.dart & migrations)
- Models (DTOs / ORM objects)
d. Core Services
- DatabaseService (wraps Drift/Moor or sqflite)
- NotificationService (schedules OS notifications)
- Navigation (main_navigation.dart)
- Utilities & Error Handling
e. Platform/External
- Android, iOS, Web, Windows embedding layers
- OS Notifications, Local Storage (SQLite), Platform Channels

##### Interactions & Data Flows
- UI Widgets → Providers (presentation state) → Use Cases
- Use Cases → Repository Interfaces → RepositoryImpl
- RepositoryImpl → LocalDataSource → Core DatabaseService → SQLite
- Engine modules invoked by Use Cases or Providers to run business rules
- NotificationService triggered by engine or presentation to schedule OS notifications
- main.dart initializes Core (database, services) and hooks platform channels

##### Architectural Patterns & Principles
- Clean/Onion Architecture with strict layer dependence:
UI only knows Presentation; Presentation depends on Domain; Domain is independent; Data knows Domain interfaces; Core services are shared.
- Feature-based modularization to isolate “dead_minutes” vs “energy_planner.”
- Dependency Injection via service locators or Flutter providers.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Platform Runners
  subgraph "Platform Runners" 
    direction TB
    Android["Android Runner"]:::external
    iOS["iOS Runner"]:::external
    Web["Web Entry"]:::external
    Windows["Windows Runner"]:::external
  end

  %% Flutter Entry
  Main["main.dart / app.dart"]:::core

  %% Core Services
  subgraph "Core Services"
    direction TB
    DBService["DatabaseService"]:::core
    AppDB["AppDatabase & Migrations"]:::core
    Notification["NotificationService"]:::core
    Navigation["MainNavigation"]:::core
    Utils["ErrorHandler"]:::core
  end

  %% Data Layer
  subgraph "Data Layer"
    direction TB
    subgraph "Dead Minutes Data"
      DMModels["DTOs / ORM Models"]:::data
      DMLocalDS["micro_activity_local_datasource"]:::data
      DMRepoImpl["micro_activity_repository_impl"]:::data
    end
    subgraph "Energy Planner Data"
      EPModels["Models"]:::data
      EPLocalDS["goal_local_datasource"]:::data
      EPRepoImpl["goal_repository_impl"]:::data
    end
    DBService -->|uses| AppDB
    DMLocalDS -->|reads/writes| DBService
    EPLocalDS -->|reads/writes| DBService
    DMRepoImpl -->|calls| DMLocalDS
    EPRepoImpl -->|calls| EPLocalDS
  end

  %% Domain Layer
  subgraph "Domain Layer"
    direction TB
    subgraph "Dead Minutes Domain"
      DMEntities["Entities"]:::domain
      DMUseCases["SuggestActivities / LogCompletion UseCases"]:::domain
      DMRepos["Repository Interfaces"]:::domain
    end
    subgraph "Energy Planner Domain"
      EPEntities["Entities"]:::domain
      EPRepos["Repository Interfaces"]:::domain
    end
    DMUseCases -->|depend on| DMRepos
    EPRepos
  end

  %% Presentation Layer
  subgraph "Presentation Layer"
    direction TB
    subgraph "Dead Minutes Presentation"
      DMPages["Pages"]:::presentation
      DMProviders["Providers"]:::presentation
      DMWidgets["Widgets"]:::presentation
    end
    subgraph "Energy Planner Presentation"
      EPEntry["Presentation Entry"]:::presentation
    end
    Home["Home Screen"]:::presentation
    Plan["Plan Screen"]:::presentation
    Settings["Settings Screen"]:::presentation
    DMPages -->|state via| DMProviders
    DMProviders -->|triggers| DMUseCases
    DMWidgets -->|UI Components| DMPages
    EPEntry -->|triggers| EPRepos
    Home -->|navigation| Navigation
    Plan -->|navigation| Navigation
    Settings -->|navigation| Navigation
  end

  %% Interactions
  Main -->|initializes| DBService
  Main -->|initializes| Notification
  Main -->|initializes| Navigation
  Main -->|registers| Utils
  Main -->|launches| Home
  Main -->|launches| Android
  Main -->|launches| iOS
  Main -->|launches| Web
  Main -->|launches| Windows

  DMUseCases -->|fetch/save| DMRepoImpl
  EPRepos -->|implemented by| EPRepoImpl
  DMRepoImpl -->|implements| DMRepos
  EPRepoImpl -->|implements| EPRepos

  Notification -->|schedules| Android
  Notification -->|schedules| iOS
  Notification -->|schedules| Web
  Notification -->|schedules| Windows

  %% Click Events
  click DMPages "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/presentation/pages/dead_minutes_page.dart"
  click DMProviders "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/presentation/providers/providers.dart"
  click DMWidgets "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/presentation/widgets/widgets.dart"
  click EPEntry "https://github.com/priyank-0401/flextime/blob/main/lib/features/energy_planner/presentation/presentation.dart"
  click Home "https://github.com/priyank-0401/flextime/blob/main/lib/features/home/home_screen.dart"
  click Plan "https://github.com/priyank-0401/flextime/blob/main/lib/features/plan/plan_screen.dart"
  click Settings "https://github.com/priyank-0401/flextime/blob/main/lib/features/settings/settings_screen.dart"
  click DMUseCases "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/domain/usecases/suggest_activities_usecase.dart"
  click DMUseCases "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/domain/usecases/log_completion_usecase.dart"
  click DMEntities "https://github.com/priyank-0401/flextime/tree/main/lib/features/dead_minutes/domain/entities/"
  click DMRepos "https://github.com/priyank-0401/flextime/tree/main/lib/features/dead_minutes/domain/repositories/"
  click EPEntities "https://github.com/priyank-0401/flextime/tree/main/lib/features/energy_planner/domain/entities/"
  click EPRepos "https://github.com/priyank-0401/flextime/tree/main/lib/features/energy_planner/domain/repositories/"
  click DMModels "https://github.com/priyank-0401/flextime/tree/main/lib/features/dead_minutes/data/models/"
  click DMLocalDS "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/data/datasources/micro_activity_local_datasource.dart"
  click DMRepoImpl "https://github.com/priyank-0401/flextime/blob/main/lib/features/dead_minutes/data/repositories/micro_activity_repository_impl.dart"
  click EPModels "https://github.com/priyank-0401/flextime/tree/main/lib/features/energy_planner/data/models/"
  click EPLocalDS "https://github.com/priyank-0401/flextime/blob/main/lib/features/energy_planner/data/datasources/goal_local_datasource.dart"
  click EPRepoImpl "https://github.com/priyank-0401/flextime/blob/main/lib/features/energy_planner/data/repositories/goal_repository_impl.dart"
  click DBService "https://github.com/priyank-0401/flextime/blob/main/lib/core/services/database_service.dart"
  click Notification "https://github.com/priyank-0401/flextime/blob/main/lib/core/services/notification_service.dart"
  click AppDB "https://github.com/priyank-0401/flextime/blob/main/lib/core/database/app_database.dart"
  click Navigation "https://github.com/priyank-0401/flextime/blob/main/lib/core/navigation/main_navigation.dart"
  click Utils "https://github.com/priyank-0401/flextime/blob/main/lib/core/utils/error_handler.dart"
  click Main "https://github.com/priyank-0401/flextime/blob/main/lib/main.dart"

  %% Styles
  classDef external fill:#eeeeee,stroke:#666,stroke-width:1px
  classDef core fill:#e0e0e0,stroke:#333,stroke-width:1px
  classDef data fill:#d8bfd8,stroke:#800080,stroke-width:1px
  classDef domain fill:#ffa500,stroke:#cc8400,stroke-width:1px
  classDef presentation fill:#98fb98,stroke:#008000,stroke-width:1px
  classDef ui fill:#87cefa,stroke:#0000cd,stroke-width:1px
```
