# bmin-mit/floating-notes architecture

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

- Interactive diagram: https://gitdiagram.com/bmin-mit/floating-notes
- Repository: https://github.com/bmin-mit/floating-notes

## Overview

##### Main Components
- Cross-platform Flutter Application Core – This is the central part of your system, where the Dart code and Flutter framework reside.
- UI/Presentation Layer – Under the “lib/src/screens” (for pages like home and note creation) and “lib/src/widgets” (for note lists, editors, and buttons). These components define the user interfaces.
- Business Logic Layer (BLoC) – Found in “lib/src/blocs/notes”. This layer handles state management and event processing for note-related operations.
- Data Layer – Includes “lib/src/models” (e.g., note.dart representing the data model) and “lib/src/resources/notes” (the provider and repository for handling and abstracting data operations).
- Platform Specific Launchers – All directories like “android”, “ios”, “linux”, “macos”, “windows”, and “web” illustrate how Flutter packages its core code into native projects. They interact with the Flutter engine and serve as the entry points for the app on each platform.

##### Relationships and Interactions
- The UI Layer sends user actions to the Business Logic (BLoC), which then processes events and updates state.
- The BLoC communicates with the Data Layer (via the notes provider and repository) to fetch, update, or store note data.
- The Data Layer accesses and formats the data (based on the note model) for use by the BLoC.
- At runtime, the Flutter engine (managed by each platform-specific project) integrates the cross-platform code, handling rendering and platform channel communications.

##### Architectural Patterns and Key Design Principles
- The separation of concerns is enforced via the layered approach: UI, Business Logic (using the BLoC pattern), and Data.
- This design supports modularity and testability, as each layer is decoupled from the others.
- Use of the “provider” pattern within the “notes_provider” and “notes_repository” which may abstract data sources (local storage, APIs, etc.) even though this project is minimal and may only use local state.
- The cross-platform nature of Flutter is ensured by generating multiple platform-specific projects that integrate with the single shared codebase.

##### Relevant Technologies, Frameworks, and Libraries
- Flutter & Dart – The foundational technology for building the UI, managing state through the BLoC pattern, and overall application logic.
- BLoC Library – Evidenced by files like “notes_bloc.dart”, “notes_event.dart”, and “notes_state.dart.”
- Native platform projects – Managed through Gradle for Android, Xcode for iOS/macOS, and CMake for Linux/Windows.
- Resource & Model Management – Handled in the “lib/src/models” and “lib/src/resources” directories.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Cross-platform Flutter Application Core"
        Core1["main.dart"]:::core
        Core2["bootstrap.dart"]:::core
    end

    subgraph "UI/Presentation Layer"
        subgraph "Screens"
            UI1["home.dart"]:::ui
            UI2["note_create.dart"]:::ui
        end
        subgraph "Widgets"
            UI3["note_list.dart"]:::ui
            UI4["note_create_button.dart"]:::ui
            UI5["note_editor.dart"]:::ui
        end
    end

    subgraph "Business Logic (BLoC)"
        Bloc1["notes_bloc.dart"]:::bloc
        Bloc2["notes_event.dart"]:::bloc
        Bloc3["notes_state.dart"]:::bloc
    end

    subgraph "Data Layer"
        subgraph "Model"
            Data1["note.dart"]:::data
        end
        subgraph "Resources"
            Data2["notes_provider.dart"]:::data
            Data3["notes_repository.dart"]:::data
        end
    end

    subgraph "Platform Specific Launchers"
        Plat1["Android (MainActivity.kt)"]:::platform
        Plat2["iOS (AppDelegate.swift)"]:::platform
        Plat3["Linux (main.cc)"]:::platform
        Plat4["macOS (AppDelegate.swift)"]:::platform
        Plat5["Windows (main.cpp)"]:::platform
        Plat6["Web (index.html)"]:::platform
    end

    %% Data flow from UI to BLoC to Data Layer and back to UI
    UI1 -->|"triggers"| Bloc1
    UI2 -->|"triggers"| Bloc1
    Bloc1 -->|"fetch_update"| Data3
    Data3 -->|"returns"| Bloc1
    Bloc1 -->|"updates"| UI3
    Bloc1 -->|"updates"| UI4
    Bloc1 -->|"updates"| UI5

    %% Core initialization flow
    Core1 -->|"initializes"| UI1
    Core1 -->|"initializes"| Bloc1

    %% Platform integration launching the Flutter Core
    Plat1 -->|"launches"| Core1
    Plat2 -->|"launches"| Core1
    Plat3 -->|"launches"| Core1
    Plat4 -->|"launches"| Core1
    Plat5 -->|"launches"| Core1
    Plat6 -->|"launches"| Core1

    %% Styles
    classDef core fill:#f9c,stroke:#333,stroke-width:2px;
    classDef ui fill:#ccf,stroke:#333,stroke-width:2px;
    classDef bloc fill:#cfc,stroke:#333,stroke-width:2px;
    classDef data fill:#fcf,stroke:#333,stroke-width:2px;
    classDef platform fill:#ffc,stroke:#333,stroke-width:2px;

    %% Click Events
    click Core1 "https://github.com/bmin-mit/floating-notes/blob/master/lib/main.dart"
    click Core2 "https://github.com/bmin-mit/floating-notes/blob/master/lib/bootstrap.dart"
    click UI1 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/screens/home.dart"
    click UI2 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/screens/note_create.dart"
    click UI3 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/widgets/notes/note_list.dart"
    click UI4 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/widgets/notes/note_create_button.dart"
    click UI5 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/widgets/notes/note_editor.dart"
    click Bloc1 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/blocs/notes/notes_bloc.dart"
    click Bloc2 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/blocs/notes/notes_event.dart"
    click Bloc3 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/blocs/notes/notes_state.dart"
    click Data1 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/models/note.dart"
    click Data2 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/resources/notes/notes_provider.dart"
    click Data3 "https://github.com/bmin-mit/floating-notes/blob/master/lib/src/resources/notes/notes_repository.dart"
    click Plat1 "https://github.com/bmin-mit/floating-notes/tree/master/android/"
    click Plat2 "https://github.com/bmin-mit/floating-notes/tree/master/ios/"
    click Plat3 "https://github.com/bmin-mit/floating-notes/tree/master/linux/"
    click Plat4 "https://github.com/bmin-mit/floating-notes/tree/master/macos/"
    click Plat5 "https://github.com/bmin-mit/floating-notes/tree/master/windows/"
    click Plat6 "https://github.com/bmin-mit/floating-notes/tree/master/web/"
```
