# defifundr-labs/defifundr_mobile architecture

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

- Interactive diagram: https://gitdiagram.com/defifundr-labs/defifundr_mobile
- Repository: https://github.com/defifundr-labs/defifundr_mobile

## Overview

##### Project type and purpose
- DefiFundr is a Flutter-based mobile client implementing a decentralised payroll and invoice management system.
- It follows a Clean (V.I.P.E.R-inspired) architecture: each feature is broken into Presentation, Domain, and Data layers.

##### File structure
- Top-level Flutter platforms: android/, ios/, linux/, macos/, web/
- Core engine: lib/ with subfolders:
- app/           → root widget (app.dart)
- core/          → configuration, constants, theming, localization, routing
- infrastructure → DI container, BLoC provider
- modules/       → feature folders (authentication, finance, expenses, invoice, kyc, onboarding, pay_cycle, payment, quickpay, time_off, time_tracking, web3auth) each with data/, domain/, presentation/
- shared/        → generic widgets
- Testing: test/, integration_test/
- Build & code-gen scripts: Makefile, pubspec.yaml, build_runner commands.

##### Insights from the README
- Confirms Clean Architecture, use of code generation (freezed, json_serializable), DI via injection_container.dart.
- No backend code here: app consumes remote datasources (APIs, Web3Auth) and local storage.

a. Main components
- Presentation Layer (UI)
- Flutter screens & widgets (modules/…/presentation)
- BLoC/Cubit classes for state management
- Domain Layer
- UseCases (modules/…/domain/usecase)
- Entities & Repository interfaces
- Data Layer
- Repository implementations (modules/…/data/repository)
- DataSources:
– Remote (HTTP/Web3Auth services, blockchain clients)
– Local (secure storage, shared preferences)
- Core & Infrastructure
- Dependency Injection (injection_container.dart)
- Routing (routers.dart, route_guards)
- Theming, Localization, Constants
- Platform Adapters
- Android (MainActivity.kt)
- iOS (AppDelegate.swift)
- Web, Linux, macOS plugin registrants
- External Services
- Web3Auth Service & blockchain networks
- RESTful backend APIs
- Local persistence (SQLite/secure storage)

b. Relationships & interactions
1. User taps UI widget → triggers BLoC event
2. BLoC invokes Domain UseCase
3. UseCase calls Repository interface
4. Repository implementation delegates to DataSources
5. RemoteDataSource issues HTTP/Web3Auth calls or blockchain transactions
6. LocalDataSource reads/writes secure cache
7. Results propagate back up to UI via BLoC state
8. DI container wires BLoCs, UseCases, Repositories, DataSources at startup (main.dart → injection_container)

c. Architectural patterns & design principles
- Layered Clean Architecture (strict dependency rule: Presentation → Domain → Data)
- Feature-based modularization (each module self-contained)
- Dependency Injection via GetIt (injection_container.dart)
- State management: BLoC/Cubit
- Code generation: freezed, json_serializable, auto_route (routers.gr.dart)
- Platform abstraction via Flutter plugins

d. Key technologies & libraries
- Flutter & Dart
- flutter_bloc
- get_it (DI)
- auto_route (navigation)
- freezed & build_runner (data classes)
- web3auth_sdk & custom blockchain clients
- shared_preferences / secure_storage

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Entry
    Main["Main Entry Point\nlib/main.dart"]:::core
    App["Root Application Widget\nlib/app/app.dart"]:::core
    Main -->|"runs"| App
    App -->|"initializes"| DI["Dependency Injection Container\ninjection_container.dart"]:::core
    click Main "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/main.dart"
    click App "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/app/app.dart"
    click DI "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/infrastructure/di/injection_container.dart"

    %% Core & Infrastructure
    subgraph "Core & Infrastructure" 
        direction TB
        Routers["Routers\nlib/core/routers/routers.dart"]:::core
        RoutesGen["Generated Routes\nlib/core/routers/routers.gr.dart"]:::core
        AuthGuard["Auth Guard\nlib/core/routers/guards/auth_guard.dart"]:::core
        ThemeMgr["Theme Manager\nlib/core/design_system/theme_extension/theme_manager.dart"]:::core
        AppColors["App Colors\nlib/core/design_system/app_colors/app_colors.dart"]:::core
        IntlEN["intl_en.arb"]:::core
        IntlES["intl_es.arb"]:::core
        GenStrings["Generated Strings\nlib/core/localization/generated/strings.dart"]:::core
        Web3Config["Web3Auth Config\nlib/core/config/web3auth_config.dart"]:::core
    end
    App --> Routers
    DI --> Routers
    DI --> ThemeMgr
    DI --> GenStrings
    DI --> Web3Config
    click Routers "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/routers/routers.dart"
    click RoutesGen "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/routers/routers.gr.dart"
    click AuthGuard "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/routers/guards/auth_guard.dart"
    click ThemeMgr "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/design_system/theme_extension/theme_manager.dart"
    click AppColors "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/design_system/app_colors/app_colors.dart"
    click IntlEN "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/localization/intl_en.arb"
    click IntlES "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/localization/intl_es.arb"
    click GenStrings "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/localization/generated/strings.dart"
    click Web3Config "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/core/config/web3auth_config.dart"

    %% Feature: Authentication
    subgraph "Authentication Module" 
        direction TB
        AuthUI["LoginScreen & BLoC\nlogin_screen.dart & bloc"]:::presentation
        AuthUC["LoginUseCase\nlogin_usecase.dart"]:::domain
        AuthRepoInt["Auth Repository Interface\nauthentication_repository.dart"]:::domain
        AuthRepoImpl["Auth Repository Impl\nauthentication_repository.dart"]:::data
        AuthRemote["Auth Remote DataSource\nremote_datasource.dart"]:::data
        AuthLocal["Auth Local DataSource\nlocal_datasource.dart"]:::data
    end
    DI --> AuthUI
    AuthUI -->|"triggers"| AuthUC
    AuthUC -->|"depends on"| AuthRepoInt
    AuthRepoInt --> AuthRepoImpl
    AuthRepoImpl --> AuthRemote
    AuthRepoImpl --> AuthLocal
    AuthRemote -->|"HTTP/Web3Auth"| ExternalAPI
    AuthLocal -->|"Secure Storage"| LocalStore
    click AuthUI "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/presentation/login/screens/login_screen.dart"
    click AuthUC "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/domain/usecase/login_usecase.dart"
    click AuthRepoInt "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/domain/repository/authentication_repository.dart"
    click AuthRepoImpl "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/data/repository/authentication_repository.dart"
    click AuthRemote "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/data/datasource/remote_datasource/remote_datasource.dart"
    click AuthLocal "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/authentication/data/datasource/local_datasource/local_datasource.dart"

    %% Feature: Invoice
    subgraph "Invoice Module"
        direction TB
        InvoiceUI["Create & List Screens\ncreate_invoice_flow_screen.dart\ninvoices_screen.dart"]:::presentation
        InvoiceModels["Invoice Models\ndata/models/invoice_models.dart"]:::data
    end
    DI --> InvoiceUI
    InvoiceUI -->|"uses"| InvoiceModels
    InvoiceModels --> LocalStore
    click InvoiceUI "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/invoice/presentation/screens/create_invoice_flow_screen.dart"
    click InvoiceUI "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/invoice/presentation/screens/invoices_screen.dart"
    click InvoiceModels "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/invoice/data/models/invoice_models.dart"

    %% Feature: Finance
    subgraph "Finance Module"
        direction TB
        FinanceUC["FinanceUseCase\ndomain/usecase/finance_usecase.dart"]:::domain
        FinanceRepoImpl["Finance Repository Impl\ndata/repository/finance_repository.dart"]:::data
        FinanceRemote["Finance Remote DataSource\ndata/datasource/remote_datasource/remote_datasource.dart"]:::data
    end
    DI --> FinanceUC
    FinanceUC --> FinanceRepoImpl
    FinanceRepoImpl --> FinanceRemote
    FinanceRemote --> ExternalAPI
    click FinanceUC "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/finance/domain/usecase/finance_usecase.dart"
    click FinanceRepoImpl "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/finance/data/repository/finance_repository.dart"
    click FinanceRemote "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/finance/data/datasource/remote_datasource/remote_datasource.dart"

    %% Feature: Web3Auth & Blockchain
    subgraph "Web3Auth & Blockchain"
        direction TB
        W3Service["Web3Auth Service\nweb3auth_service.dart"]:::data
        StarkClient["StarkNet Client\nstarknet_client.dart"]:::data
        WalletIface["Wallet Interfaces\nweb3_wallet.dart"]:::domain
    end
    DI --> W3Service
    W3Service --> StarkClient
    StarkClient -->|"connects"| BlockchainNode
    WalletIface --> W3Service
    click W3Service "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/web3auth/data/service/web3auth_service.dart"
    click StarkClient "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/web3auth/data/clients/starknet_client.dart"
    click WalletIface "https://github.com/defifundr-labs/defifundr_mobile/blob/main/lib/modules/web3auth/domain/interfaces/web3_wallet.dart"

    %% Local & External
    subgraph "Local Persistence" 
        direction TB
        LocalStore("Secure Storage / Shared Preferences"):::external
    end

    subgraph "External Services" 
        direction TB
        ExternalAPI("RESTful Backend APIs"):::external
        Web3AuthExt("Web3Auth SDK"):::external
        BlockchainNode("Blockchain Network Nodes"):::external
    end

    %% Code Generation & Scripts
    subgraph "Build & Code-Gen"
        direction TB
        Pubspec["pubspec.yaml"]:::core
        Makefile["Makefile"]:::core
    end
    App --> Pubspec
    App --> Makefile
    Pubspec -->|"triggers"| CodeGen["build_runner"]:::core

    %% Platform Adapters
    subgraph "Platform Adapters"
        direction TB
        Android["Android MainActivity\nMainActivity.kt"]:::platform
        iOS["iOS AppDelegate\nAppDelegate.swift"]:::platform
        Linux["Linux Plugin Registrant\ngenerated_plugin_registrant.cc"]:::platform
    end
    App --> Android
    App --> iOS
    App --> Linux
    click Android "https://github.com/defifundr-labs/defifundr_mobile/blob/main/android/app/src/main/kotlin/com/example/defifundr_mobile/MainActivity.kt"
    click iOS "https://github.com/defifundr-labs/defifundr_mobile/blob/main/ios/Runner/AppDelegate.swift"
    click Linux "https://github.com/defifundr-labs/defifundr_mobile/blob/main/linux/flutter/generated_plugin_registrant.cc"

    %% Styles
    classDef presentation fill:#E0F7FA,stroke:#006064,color:#000;
    classDef domain fill:#E8F5E9,stroke:#1B5E20,color:#000;
    classDef data fill:#FFF3E0,stroke:#E65100,color:#000;
    classDef core fill:#ECEFF1,stroke:#37474F,color:#000;
    classDef platform fill:#FFF9C4,stroke:#F57F17,color:#000;
    classDef external fill:#FFEBEE,stroke:#B71C1C,color:#000;
```
