# leventeasztalos/simu_bank architecture

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

- Interactive diagram: https://gitdiagram.com/leventeasztalos/simu_bank
- Repository: https://github.com/leventeasztalos/simu_bank

## Overview

##### Project Type and Purpose
- This is a Flutter-based mobile application project designed as a starting point for a new Flutter app. Its structure clearly indicates support for both Android and iOS platforms (with separate native folders) and contains a core Flutter codebase in the “lib” directory.
- Additionally, there is a separate module named “simubank_api” which appears to be an auto-generated API client library (using OpenAPI specifications). This module is used for handling API calls such as authentication, transactions, and other backend interactions.

##### File Structure
- Top-Level Folders:
- android and ios: Contain the native project files, configurations, resources, and platform-specific settings.
- lib: Contains the Flutter application’s core code, including UI components, view models, routing, repositories (for handling authentication and transaction data), services (API service and local storage), and configuration.
- simubank_api: Provides an API client library that encapsulates API calls, model definitions, and authentication logic. This separation suggests the use of the Repository pattern to abstract API calls.
- Architectural Patterns:
- The state management / view model structure in the “lib/ui” folder (with separate directories for login, logout, transactions, etc.) strongly suggests an MVVM or a cleaned-up separation of UI and business logic.
- The “lib/data” directory holds repositories and services, indicating a layered architecture where the UI layer (in the “lib/ui” folder) communicates with view models, which in turn interact with repositories that call the underlying API services.
- Configuration & Routing:
- The “lib/config” and “lib/routing” directories imply a modular design where configuration/dependency injections and navigation are managed separately.

##### Key Components
a. Mobile Application (Flutter Client):
- UI Layer (inside lib/ui): Represents authentication screens, transactions display, settings screen, etc.
- ViewModels/State Management (within each UI feature subfolder).
- Routing Module (in lib/routing): Manages navigation between different screens.
- Data Layer:
- Repositories (in lib/data/repositories): Includes separate modules for authentication and transactions.
- Services (in lib/data/services): Contains API service abstractions (e.g., open_api.dart) and local storage (shared_preferences_service.dart).
- Configurations (in lib/config): Likely handles dependency injection and configuration settings.

b. API Client Module:
- simubank_api:
- API Layer: Contains API client implementation (in simubank_api/lib/src/api) for calling backend endpoints.
- Authentication and Security: Handled in simubank_api/lib/src/auth with different strategies (API key, basic auth, bearer token, OAuth).
- Models and Serializers: Representations of API data models and JSON converters (in simubank_api/lib/src/model and serializers).
- Documentation & Tests: Documentation files and unit tests that ensure API responses are parsed correctly.

c. Native Layers:
- Android & iOS Folders: Illustrate the native platform wrappers that launch the Flutter application. They include platform-specific configurations and assets.

##### Relationships and Interaction (Data Flow)
- The primary Flutter UI components (screens) interact with their respective ViewModels.
- ViewModels invoke Repository methods within the Data Layer.
- Repositories use Services (for API calls or local shared preferences) which integrate with the simubank_api module.
- The simubank_api module abstracts the underlying HTTP calls, handles authentication, and provides parsed data back to the repositories.
- The data flows upward from simubank_api -> Services -> Repositories -> ViewModels -> UI.

##### Architectural Patterns and Design Principles
- The project uses a layered architecture with clear separation of concerns (UI, state management, data access, and API interaction).
- Design patterns like MVVM (or a variant) and the Repository pattern are used to keep UI logic separate from data fetching and business logic.
- Dependency injection and centralized routing further modularize the code and improve scalability.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Native Platform Layers
    subgraph "Native Platform Layers"
        Android["Android Native Code"]:::native
        iOS["iOS Native Code"]:::native
    end

    %% Flutter Mobile Application
    subgraph "Flutter Mobile Application"
        UI["UI Layer"]:::ui
        Routing["Routing Module"]:::routing

        subgraph "State Management"
            AuthLoginVM["Auth Login ViewModel"]:::vm
            AuthLogoutVM["Auth Logout ViewModel"]:::vm
            TransactionsVM["Transactions ViewModel"]:::vm
        end

        subgraph "Data Layer"
            subgraph "Repositories"
                AuthRepo["Authentication Repository"]:::repo
                TransRepo["Transactions Repository"]:::repo
            end
            subgraph "Services"
                APIService["API Service"]:::service
                LocalStorage["Local Storage Service"]:::service
            end
            Config["Configuration Module"]:::config
        end
    end

    %% API Client Module
    subgraph "API Client Module"
        APIMain["API Client Main"]:::api
        APIImpl["API Implementation"]:::api
        APIAuth["Authentication Implementations"]:::api
        Models["Models & Serializers"]:::api
    end

    %% Connections within Flutter Application
    UI -->|"triggers"| AuthLoginVM
    UI -->|"triggers"| AuthLogoutVM
    UI -->|"triggers"| TransactionsVM
    UI -->|"navigates"| Routing

    AuthLoginVM -->|"calls"| AuthRepo
    AuthLogoutVM -->|"calls"| AuthRepo
    TransactionsVM -->|"calls"| TransRepo

    AuthRepo -->|"uses"| APIService
    TransRepo -->|"uses"| APIService

    Config -->|"configures"| AuthRepo
    Config -->|"configures"| TransRepo
    Config -->|"configures"| APIService

    APIService -->|"invokes"| APIMain

    APIMain -->|"delegates"| APIImpl
    APIMain -->|"delegates"| APIAuth
    APIMain -->|"delegates"| Models

    %% Native Layers launching the Flutter App
    Android -->|"launches"| UI
    iOS -->|"launches"| UI

    %% Click Events
    click UI "https://github.com/leventeasztalos/simu_bank/tree/main/lib/ui"
    click AuthLoginVM "https://github.com/leventeasztalos/simu_bank/blob/main/lib/ui/auth/login/view_models/login_viewmodel.dart"
    click AuthLogoutVM "https://github.com/leventeasztalos/simu_bank/blob/main/lib/ui/auth/logout/view_models/logout_view_model.dart"
    click TransactionsVM "https://github.com/leventeasztalos/simu_bank/blob/main/lib/ui/transactions/view_models/transactions_viewmodel.dart"
    click Routing "https://github.com/leventeasztalos/simu_bank/tree/main/lib/routing"
    click AuthRepo "https://github.com/leventeasztalos/simu_bank/tree/main/lib/data/repositories/auth"
    click TransRepo "https://github.com/leventeasztalos/simu_bank/tree/main/lib/data/repositories/transactions"
    click APIService "https://github.com/leventeasztalos/simu_bank/blob/main/lib/data/services/api/open_api.dart"
    click LocalStorage "https://github.com/leventeasztalos/simu_bank/blob/main/lib/data/services/shared_prefernces_service.dart"
    click Config "https://github.com/leventeasztalos/simu_bank/blob/main/lib/config/dependencies.dart"
    click APIMain "https://github.com/leventeasztalos/simu_bank/blob/main/simubank_api/lib/simubank_api.dart"
    click APIImpl "https://github.com/leventeasztalos/simu_bank/tree/main/simubank_api/lib/src/api"
    click APIAuth "https://github.com/leventeasztalos/simu_bank/tree/main/simubank_api/lib/src/auth"
    click Models "https://github.com/leventeasztalos/simu_bank/tree/main/simubank_api/lib/src/model"
    click Android "https://github.com/leventeasztalos/simu_bank/tree/main/android"
    click iOS "https://github.com/leventeasztalos/simu_bank/tree/main/ios"

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,stroke-width:2px;
    classDef vm fill:#FFECB3,stroke:#FF6F00,stroke-width:2px;
    classDef repo fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef service fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef routing fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef api fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef native fill:#DCEDC8,stroke:#558B2F,stroke-width:2px;
```
