# leongiscoding/flutter_note_app architecture

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

- Interactive diagram: https://gitdiagram.com/leongiscoding/flutter_note_app
- Repository: https://github.com/leongiscoding/flutter_note_app

## Overview

##### Project type and purpose
- This is a cross-platform Flutter note-taking application (“flutter_note_app”) that uses an embedded Isar local database.
- It targets mobile (Android/iOS) and web (PWA) platforms, with all logic and UI in Dart under lib/.

##### File structure
Top level:
- android/ (Android Gradle project, manifests, resources)
- web/ (PWA assets, index.html, manifest.json)
- lib/ (Dart code)
– components/ (reusable widgets: drawer, note tile, settings toggle)
– pages/ (screen widgets: NotePage, SettingsPage)
– models/ (Note data class, generated code, NoteDatabase service)
– theme/ (theme definitions, ThemeProvider)
– main.dart (app entry point)
- pubspec.yaml (dependencies, Isar, Flutter SDK)

##### Extract key architecture hints from README
- “Using Isar Database” implies a local-storage data layer.
- No external API or backend: all data persistence is on-device.

##### Main components
A. Platform Layer
- Android (android/)
- Web (web/)
- (Optionally iOS if implied)
B. Flutter Engine & Embedder
- Dart VM / AOT runtime
C. Presentation Layer (UI Widgets)
- main.dart → MaterialApp & routes
- components/ (Drawer, NoteTile, NoteSettings)
- pages/ (NotePage: list/create/update notes; SettingsPage)
D. State & Theme Management
- theme/ (ThemeProvider, theme.dart)
E. Data Layer (Business Logic)
- models/note_database.dart (IsarService)
- models/note.dart + note.g.dart (Isar collection schema)
F. Local Persistence
- Isar Database engine (embedded, parked on device storage)

##### Relationships & data flows
1) User taps UI widget →
2) Widget invokes NoteDatabase service (CRUD API) →
3) NoteDatabase uses Isar to read/write Note collection →
4) Results streamed back to widget → UI rebuild

Similarly, theme changes flow from SettingsPage → ThemeProvider → notifies MaterialApp.

##### Architectural patterns & principles
- Separation of Concerns:
- UI (components/pages) vs. Business Logic (NoteDatabase) vs. Persistence (Isar)
- Provider-style state management for theme (and could be extended to notes)
- Modular folder structure mapping to system components

- Clear module names (e.g., “NoteDatabase Service”)
- Entry point “main.dart”
- Platform host blocks (Android / Web) feeding into Flutter runtime

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Layer
    subgraph "Platform Layer"
        direction TB
        Android["Android"]:::platform
        Web["Web (PWA)"]:::platform
    end

    %% Flutter Engine & Embedder
    FlutterEngine["Flutter Engine & Embedder\n(Dart VM/AOT)"]:::engine

    %% Dart App Container
    subgraph "Dart App (lib/)"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB
            Main["main.dart\n(MaterialApp & Routes)"]:::ui
            Drawer["Drawer Widget"]:::ui
            DrawerTile["Drawer Tile Item"]:::ui
            NoteTile["Note Tile Widget"]:::ui
            NoteSettings["Note Settings Toggle"]:::ui
            NotePage["NotePage\n(List/Create/Update)"]:::ui
            SettingsPage["SettingsPage\n(Theme Settings)"]:::ui
        end

        %% State & Theme Management
        subgraph "State & Theme Management"
            direction TB
            ThemeDef["theme.dart\n(Theme Definitions)"]:::theme
            ThemeProv["ThemeProvider"]:::theme
        end

        %% Data Layer (Business Logic)
        subgraph "Data Layer"
            direction TB
            NoteDB["NoteDatabase Service\n(Isar CRUD API)"]:::service
            NoteModel["Note Data Class"]:::model
            NoteSchema["note.g.dart\n(Generated Schema)"]:::model
        end
    end

    %% Persistence Layer
    IsarDB["Isar Database\n(Embedded Local DB)"]:::db

    %% Connections
    Android -->|hosts| FlutterEngine
    Web -->|hosts| FlutterEngine
    FlutterEngine -->|runs| Main

    %% UI to Data flow
    Main -->|"uses UI Widgets"| Drawer
    Main -->|"uses UI Widgets"| DrawerTile
    Main -->|"uses UI Widgets"| NoteTile
    Main -->|"uses UI Widgets"| NoteSettings
    Main -->|"routes to"| NotePage
    Main -->|"routes to"| SettingsPage

    %% User interactions
    NotePage -->|"queryNotes() / writeNote()"| NoteDB
    NoteDB -->|"uses Isar API"| IsarDB
    IsarDB -->|"returns results"| NoteDB
    NoteDB -->|"streams data"| NotePage

    SettingsPage -->|"changeTheme()"| ThemeProv
    ThemeProv -->|"notifies"| Main

    %% Click Events
    click Android "https://github.com/leongiscoding/flutter_note_app/tree/main/android/"
    click Web "https://github.com/leongiscoding/flutter_note_app/tree/main/web/"
    click Main "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/main.dart"
    click Drawer "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/components/drawer.dart"
    click DrawerTile "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/components/drawer_tile.dart"
    click NoteTile "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/components/note_tile.dart"
    click NoteSettings "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/components/note_settings.dart"
    click NotePage "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/pages/note_page.dart"
    click SettingsPage "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/pages/settings_page.dart"
    click ThemeDef "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/theme/theme.dart"
    click ThemeProv "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/theme/theme_provider.dart"
    click NoteDB "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/models/note_database.dart"
    click NoteModel "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/models/note.dart"
    click NoteSchema "https://github.com/leongiscoding/flutter_note_app/blob/main/lib/models/note.g.dart"

    %% Styling
    classDef platform fill:#dddddd,stroke:#666,stroke-width:1px
    classDef engine fill:#cccccc,stroke:#666,stroke-width:1px
    classDef ui fill:#bbe5ff,stroke:#069,stroke-width:1px
    classDef theme fill:#d5ffd6,stroke:#080,stroke-width:1px
    classDef service fill:#d6f5ff,stroke:#069,stroke-width:1px
    classDef model fill:#e8d5ff,stroke:#909,stroke-width:1px
    classDef db fill:#ffd6a5,stroke:#f60,stroke-width:1px
```
