# divo662/monity-mobile-banking-app architecture

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

- Interactive diagram: https://gitdiagram.com/divo662/monity-mobile-banking-app
- Repository: https://github.com/divo662/monity-mobile-banking-app

## Overview

##### Main Components
- Mobile Client (Flutter App):
- Represents the frontend, handling user interactions, UI, and navigation.
- Contains multiple screens that cover authentication (login, signup, verify, forgot/reset password), account management (profile setup, passcode setup), transactions (send money, view transactions), and onboarding.
- Separated by directories under "lib/" (e.g., lib/screens/auth, lib/screens/home, lib/screens/transaction).

- Core Flutter Services and Utilities:

- Mobile Platform-Specific Code:
- Android directory houses the Android-specific implementation.
- iOS directory contains iOS-specific configuration & platform code.
- Both platforms are leveraged by Flutter's cross-platform framework.

- Backend (Supabase Database and Functions):
- Supabase is used for user authentication (auth.users), profile management (profile_info), storing user passcodes (user_passcodes), and logging transactions (transaction_logs_with_names and transaction_receipt).
- Contains SQL functions and triggers such as generate_account_number and send_transaction_notification to manage domain logic automatically.
- The README details how Supabase tables are structured and how functions work (e.g., generating account numbers, sending notifications).

##### Relationships and Interactions
- The Mobile Client (Flutter App) interacts with the Supabase backend through API calls:
- Authentication endpoints (using auth.users).
- Data CRUD for user profiles and transaction records.
- Real-time notifications where a trigger (inspecting transaction logs) invokes server-side functions that send push notifications.
- Within the Mobile App:
- The UI layer is structured around multiple screens organized by function (auth, home, profile settings, etc.).
- The service layer in lib/core communicates with the backend for data fetching and processing (as illustrated by the Dart code samples in the README).
- The Supabase backend:
- Functions and triggers are used to ensure data integrity (e.g., generating unique account numbers) and provide event-driven communications (notifications).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear division between the UI (Flutter screens) and backend data/business logic (Supabase functions, tables, and triggers).
- Modular Architecture: Screens and utilities are divided into folders which represent individual features (authentication, transactions, onboarding, etc.), making it easier to maintain and scale.
- Event-Driven Architecture: The Supabase triggers (especially for notifications) indicate an event-driven mechanism where database changes automatically invoke business logic.
- Cross-Platform Mobile Development: Flutter enables a unified codebase for Android and iOS, simplifying the mobile client design but still maintaining native configurations in the respective directories.

##### Relevant Technologies, Frameworks, and Libraries
- Flutter – For building the mobile UI and handling cross-platform development.
- Dart – The programming language used in Flutter.
- Supabase – For backend services (database, authentication, and real-time functionalities).
- SQL/PLpgSQL – For writing Supabase functions and triggers.
- Android & iOS Native Code – Specific configurations and project setups are managed in the android and ios directories.

##### Elements
- Clear Labels: Each module/component should have a clearly defined label (e.g., "Authentication Module," "Transaction Service").
- Backend services and database elements can use a different hue.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile Client (Flutter App)"
        Auth("Authentication Module"):::mobile
        Home("Home Module"):::mobile
        Trans("Transaction Module"):::mobile
        Onboard("Onboarding Module"):::mobile
        Profile("Profile Settings Module"):::mobile
        Splash("Splash Screen"):::mobile
    end

    subgraph "Core Flutter Services & Utilities"
        CoreServices("Core Services"):::services
        Utils("Utilities"):::services
        Resources("Resources"):::services
    end

    subgraph "API Layer"
        SupabaseIntegration("Supabase Integration"):::api
    end

    subgraph "Backend (Supabase)"
        Database("Database (Supabase)\nauth.users, profile_info, user_passcodes,\ntransaction_logs_with_names, transaction_receipt"):::backend
        Triggers("Triggers & Functions\ngenerate_account_number, send_transaction_notification"):::backend
        RTNotifications("Real-Time Notifications"):::backend
    end

    subgraph "Mobile Platform-Specific Code"
        Android("Android Code"):::platform
        iOS("iOS Code"):::platform
    end

    %% Connections from Mobile Client to API Layer
    Auth -->|"api_call"| SupabaseIntegration
    Home -->|"api_call"| SupabaseIntegration
    Trans -->|"api_call"| SupabaseIntegration
    Onboard -->|"api_call"| SupabaseIntegration
    Profile -->|"api_call"| SupabaseIntegration
    Splash -->|"init_call"| SupabaseIntegration

    %% Connections from Core Services & Utilities to API Layer
    CoreServices -->|"support"| SupabaseIntegration
    Utils -->|"support"| SupabaseIntegration
    Resources -->|"support"| SupabaseIntegration

    %% API Layer to Backend Database
    SupabaseIntegration -->|"CRUD"| Database

    %% Database triggers and event notifications
    Database -->|"trigger_event"| Triggers
    Triggers -->|"push_notification"| RTNotifications
    RTNotifications -->|"notify"| Auth
    RTNotifications -->|"notify"| Home
    RTNotifications -->|"notify"| Profile

    %% Mobile Client interacts with Platform-Specific Code
    Auth ---|"native_config"| Android
    Auth ---|"native_config"| iOS
    Home ---|"native_config"| Android
    Home ---|"native_config"| iOS
    Trans ---|"native_config"| Android
    Trans ---|"native_config"| iOS
    Onboard ---|"native_config"| Android
    Onboard ---|"native_config"| iOS
    Profile ---|"native_config"| Android
    Profile ---|"native_config"| iOS
    Splash ---|"native_config"| Android
    Splash ---|"native_config"| iOS

    %% Click Events
    click Auth "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/auth"
    click Home "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/home"
    click Trans "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/transaction"
    click Onboard "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/onboarding"
    click Profile "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/profile settings"
    click Splash "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/splashscreen"
    click CoreServices "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/core/services"
    click Utils "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/core/utils"
    click Resources "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/res"
    click Android "https://github.com/divo662/monity-mobile-banking-app/tree/main/android"
    click iOS "https://github.com/divo662/monity-mobile-banking-app/tree/main/ios"
    click SupabaseIntegration "https://github.com/divo662/monity-mobile-banking-app/tree/main/lib/screens/home/supabase"

    %% Styling for clarity
    classDef mobile fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef services fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef api fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef platform fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
```
