# 7anv1r/thriftycash architecture

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

- Interactive diagram: https://gitdiagram.com/7anv1r/thriftycash
- Repository: https://github.com/7anv1r/thriftycash

## Overview

##### Main Components

a) Client Layer (Mobile Application)
- Flutter UI Components (Features)
- Local State Management
- Offline Storage
- Platform-specific implementations (iOS/Android)

b) Data Layer
- Local Database (Collections)
- API Services
- Isolates for background processing

c) Backend Services
- Supabase Integration
- Authentication Services
- Data Synchronization

**[User Interface Layer]**
- ↓↑
**[Business Logic Layer]**
- ↓↑
**[Data Layer]**
- ↓↑
**[External Services]**

##### Detailed Component Breakdown

Frontend (UI Layer):
- Auth Features (login_part.dart, signup_part.dart)
- Home Features (homepage.dart)
- Profile Features (profile_page.dart)
- Navigation (main_layout_page.dart)

Business Logic:
- Controllers (auth_state_controller.dart, homepage_controller.dart)
- Services (connectivity_services.dart)
- Error Handling (error_util.dart)

Data Layer:
- Local Collections:
- Personal Info
- Transaction Category
- Transaction Model
- API Interfaces:
- Authentication API
- Transaction API
- Database Download API

External Services:
- Supabase Backend
- API Services

##### Key Interactions to Highlight

a) Authentication Flow:
**UI → Auth Controller → Auth API → Supabase**
- ↓
- Local Storage

b) Data Synchronization:
**Local DB ←→ DB Isolate ←→ API Services ←→ Supabase**

##### Implementation Details

Use these symbols:
- Rectangles: Components/Modules
- Diamonds: Decision Points

##### External Services

Left to Right:
- Core Features
- Supporting Services
- External Integrations

##### Additional Elements

- Component types
- State flow indicators

##### Notes for Implementation

- Use clear labels for all components
- Version numbers for major components
- Error handling paths
- Offline vs online paths
- Data persistence flow

This system design should effectively communicate the architecture while maintaining clarity about the application's offline-first nature and synchronization capabilities.

- Flutter for cross-platform development
- Offline-first architecture
- Supabase for backend services
- Isolates for background processing
- Local storage for offline capability

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef logic fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef service fill:#95a5a6,stroke:#7f8c8d,color:white

    %% User Interface Layer
    subgraph UI
        Auth["Authentication UI"]
        Home["Home Interface"]
        Profile["Profile Interface"]
        Nav["Navigation System"]
    end

    %% Business Logic Layer
    subgraph Logic
        AuthCtrl["Auth Controller"]
        HomeCtrl["Home Controller"]
        ErrorUtil["Error Handling"]
        Validators["Validators"]
        UIUtils["UI Utils"]
    end

    %% Services Layer
    subgraph Services
        ConnService["Connectivity Service"]
        SharedPref["Shared Preferences"]
        DBIsolate["Database Isolate"]
    end

    %% Data Layer
    subgraph Data
        LocalDB["Local Database"]
        subgraph Collections
            PersonalInfo["Personal Info Collection"]
            TrxCategory["Transaction Category Collection"]
            TrxModel["Transaction Model Collection"]
        end
        subgraph APIs
            AuthAPI["Authentication API"]
            TrxAPI["Transaction API"]
            DBAPI["Database Download API"]
        end
        UserModel["User Info Model"]
    end

    %% External Services
    Supabase["Supabase Backend"]:::external

    %% Relationships
    Auth --> AuthCtrl
    Home --> HomeCtrl
    Profile --> HomeCtrl
    Nav --> |Navigation State| HomeCtrl

    AuthCtrl --> AuthAPI
    HomeCtrl --> TrxAPI
    AuthCtrl --> SharedPref
    HomeCtrl --> LocalDB

    ConnService --> APIs
    DBIsolate --> LocalDB
    DBIsolate --> APIs

    LocalDB --> Collections
    APIs --> Supabase

    ErrorUtil --> UIUtils
    Validators --> UIUtils

    %% Click Events
    click Auth "https://github.com/7ANV1R/ThriftyCash/tree/main/lib/features/auth/"
    click Home "https://github.com/7ANV1R/ThriftyCash/tree/main/lib/features/home/"
    click Profile "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/features/profile/profile_page.dart"
    click Nav "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/features/nav_bar/main_layout_page.dart"
    click LocalDB "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/local_db/db.dart"
    click PersonalInfo "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/local_db/collections/personal_info/personal_info_collection.dart"
    click TrxCategory "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/local_db/collections/trx_category/trx_category_collection.dart"
    click TrxModel "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/local_db/collections/trx_model/trx_collection.dart"
    click AuthAPI "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/api/auth_api.dart"
    click TrxAPI "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/api/trx_api.dart"
    click DBAPI "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/api/db_download_api.dart"
    click AuthCtrl "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/features/auth/controller/auth_state_controller.dart"
    click HomeCtrl "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/features/home/controller/homepage_controller.dart"
    click ErrorUtil "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/common/logic/error_util.dart"
    click ConnService "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/services/connectivity_services.dart"
    click SharedPref "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/services/shared_pref_services.dart"
    click DBIsolate "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/isolate/db_isolate.dart"
    click UIUtils "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/common/ui/ui_utils.dart"
    click Validators "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/common/ui/validator.dart"
    click UserModel "https://github.com/7ANV1R/ThriftyCash/blob/main/lib/data/model/user_info_model.dart"

    %% Style Applications
    class Auth,Home,Profile,Nav ui
    class AuthCtrl,HomeCtrl,ErrorUtil,Validators,UIUtils logic
    class LocalDB,Collections,APIs,UserModel data
    class ConnService,SharedPref,DBIsolate service
```
