# nafishahmeddev/fintracker architecture

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

- Interactive diagram: https://gitdiagram.com/nafishahmeddev/fintracker
- Repository: https://github.com/nafishahmeddev/fintracker

## Overview

##### Main Components
- User Interface (Presentation Layer): Represented by the Flutter “screens” (home, accounts, categories, onboard, settings, etc.) and various widgets (buttons, dialogs, currency displays). This layer is where users interact, and it is organized into directories like lib/screens and lib/widgets.
- Business Logic Layer: This is implemented using the BLoC pattern as seen in the lib/bloc folder (especially the cubit and events). This layer handles state management, event processing, and orchestration between the UI and the data layer.
- Data Access Layer: The lib/dao and lib/model directories alone with migration helpers (lib/helpers/migrations) indicate that data persistence is managed through DAOs for accounts, categories, and payments. There is also a database helper (lib/helpers/db.helper.dart) that suggests local database usage.
- Platform-Specific Modules: The separate folders for android, ios, linux, macos, and windows show that FinTracker is built as a cross-platform app. These modules handle native integration and deployment specifics.

##### Relationships and Interactions
- User actions (e.g., tapping buttons or entering expense details) from the UI trigger events.
- These events are dispatched to the Business Logic (BLoC) components which process them and decide (through state changes) what to update on the UI.
- Business Logic interacts with the Data Access Objects to read from or write to the local database/storage (using the db.helper and migration helpers to manage schema changes).
- UI components then refresh based on updated state and data provided back by BLoC.
– From “UI Layer (Screens/Widgets)” to “BLoC (Cubit/Events)”
– From “BLoC” to “Data Access/DAO” and vice versa.

##### Architectural Patterns & Design Principles
- The app uses the Flutter framework following the BLoC (Business Logic Component) pattern, which promotes a reactive and event-driven design.
- There is a clear separation of concerns: the UI is decoupled from business logic, and data access is isolated behind DAOs. This modularity supports maintainability and testability.
- The multi-platform support indicates that while the core logic is shared, there are platform-specific wrappers and configurations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CoreApp["FinTracker App (Core)"]:::core

    subgraph "Application Layers"
        subgraph "UI Layer – Screens & Widgets"
            UI_Screens["Screens: Home, Accounts, Categories, Onboard, Settings"]:::ui
            UI_Widgets["Widgets: Buttons, Dialogs, Currency Displays"]:::ui
        end
        subgraph "Business Logic – BLoC/Cubit & Events"
            BLoC_Cubit["Cubit (app_cubit)"]:::logic
            BLoC_Events["Events (events.dart)"]:::logic
        end
        subgraph "Data Layer – DAOs, Models & Persistence"
            DAO["DAOs"]:::data
            Models["Models"]:::data
            DB_Helper["DB Helper"]:::data
            Migrations["Migrations"]:::data
        end
    end

    Assets["Assets (e.g., currencies.json)"]:::assets

    subgraph "Platform-Specific Modules"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        Linux["Linux"]:::platform
        MacOS["macOS"]:::platform
        Windows["Windows"]:::platform
    end

    %% Connections from Core to Application Layers
    CoreApp -->|"Initialize"| UI_Screens
    CoreApp -->|"Initialize"| UI_Widgets

    %% UI Layer triggers Business Logic
    UI_Screens -->|"EventDispatch"| BLoC_Cubit
    UI_Widgets -->|"EventDispatch"| BLoC_Cubit

    %% Business Logic queries Data Layer
    BLoC_Cubit -->|"DataQuery"| DAO
    BLoC_Cubit -->|"DataQuery"| Models
    BLoC_Cubit -->|"DataQuery"| DB_Helper
    BLoC_Cubit -->|"DataQuery"| Migrations

    %% Data Layer returns state updates
    DAO -->|"StateUpdate"| BLoC_Cubit
    Models -->|"StateUpdate"| BLoC_Cubit
    DB_Helper -->|"StateUpdate"| BLoC_Cubit
    Migrations -->|"StateUpdate"| BLoC_Cubit

    %% Business Logic updates UI Layer
    BLoC_Cubit -->|"StateUpdate"| UI_Screens
    BLoC_Cubit -->|"StateUpdate"| UI_Widgets

    %% Internal Business Logic communication
    BLoC_Events --- BLoC_Cubit

    %% External Assets provide resources to UI
    Assets -->|"ProvidesAssets"| UI_Screens
    Assets -->|"ProvidesAssets"| UI_Widgets

    %% Core app packaging for Platform-Specific Modules
    CoreApp -->|"PackagedFor"| Android
    CoreApp -->|"PackagedFor"| iOS
    CoreApp -->|"PackagedFor"| Linux
    CoreApp -->|"PackagedFor"| MacOS
    CoreApp -->|"PackagedFor"| Windows

    %% Click Events
    click UI_Screens "https://github.com/nafishahmeddev/fintracker/tree/master/lib/screens"
    click UI_Widgets "https://github.com/nafishahmeddev/fintracker/tree/master/lib/widgets"
    click BLoC_Cubit "https://github.com/nafishahmeddev/fintracker/blob/master/lib/bloc/cubit/app_cubit.dart"
    click BLoC_Events "https://github.com/nafishahmeddev/fintracker/blob/master/lib/events.dart"
    click DAO "https://github.com/nafishahmeddev/fintracker/tree/master/lib/dao"
    click Models "https://github.com/nafishahmeddev/fintracker/tree/master/lib/model"
    click DB_Helper "https://github.com/nafishahmeddev/fintracker/blob/master/lib/helpers/db.helper.dart"
    click Migrations "https://github.com/nafishahmeddev/fintracker/blob/master/lib/helpers/migrations/migrations.dart"
    click Assets "https://github.com/nafishahmeddev/fintracker/tree/master/assets"
    click Android "https://github.com/nafishahmeddev/fintracker/tree/master/android"
    click iOS "https://github.com/nafishahmeddev/fintracker/tree/master/ios"
    click Linux "https://github.com/nafishahmeddev/fintracker/tree/master/linux"
    click MacOS "https://github.com/nafishahmeddev/fintracker/tree/master/macos"
    click Windows "https://github.com/nafishahmeddev/fintracker/tree/master/windows"

    %% Styles
    classDef core fill:#f9d9ff,stroke:#d28dd2,stroke-width:2px;
    classDef ui fill:#c6e2ff,stroke:#2a7aaa,stroke-width:2px;
    classDef logic fill:#fff2cc,stroke:#d6c100,stroke-width:2px;
    classDef data fill:#d0e9c6,stroke:#6aa84f,stroke-width:2px;
    classDef assets fill:#fce5cd,stroke:#e69138,stroke-width:2px;
    classDef platform fill:#ead1dc,stroke:#b91d47,stroke-width:2px;
```
