# condoriluis/control-de-gastos architecture

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

- Interactive diagram: https://gitdiagram.com/condoriluis/control-de-gastos
- Repository: https://github.com/condoriluis/control-de-gastos

## Overview

##### Project Identification & Purpose
- Project Type: A multi-platform (mobile, desktop, web) Flutter application.
- Purpose: "Control de Gastos" – an expense-tracking tool that records, categorizes, and visualizes financial data.
- Key Features (from the README):
– Registro de gastos (expense registration)
– Categorías personalizadas
– Gráficos interactivos (using fl_chart)
– Autenticación local y almacenamiento seguro (via local_auth, flutter_secure_storage)
– Almacenamiento local con sqflite
– Exportación/importación de datos (CSV)

##### Analyzing the File Structure
- Top-Level Separation for Platforms: Directories like android, ios, linux, macos, windows, and web indicate that the project is built for multiple platforms.
- Lib Directory:
– Contains the entry point (main.dart), models, providers (handling state and business logic), screens (UI views), utils, and widgets.
– The use of a providers folder implies reliance on the Provider package for state management.
- Models: Define the data structures (such as categories, expenses, users).
- Providers: Manage the business logic for authentication, managing expenses, categories, etc.
- Screens & Widgets: Represent the user interface, including the dashboard, login, registration, reporting screens, and reusable UI elements like the app bar and bottom navigation.
- Native Platform Code: android, ios, and other OS folders host platform-specific launchers and configurations crucial for building a proper Flutter app.

a. Main components:
– User Interface (UI) Layer:
- Flutter screens (home, login, dashboard, expense lists, etc.)
- Custom widgets (app bar, bottom navigation, dialogs)
– Business Logic Layer:
- Provider classes (auth_provider, expenses_provider, categories_provider, etc.)
- State management flow (reactive data changes affecting the UI)
– Data Models:
- Object definitions for expenses, categories, and users stored in the models folder.
– Data Persistence Layer:
- Local database using sqflite (as referenced in database_helper.dart)
- Secure storage for authentication credentials (flutter_secure_storage)
- CSV-based import/export functionality.
– External Integrations & Services:
- Native device APIs (authentication for biometrics via local_auth, permissions via permission_handler)
- Visualization library (fl_chart) for generating charts.
– Cross-platform/Platform-specific Configurations:
- Separate directories for Android, iOS, web, etc., each handling platform-level configurations and integrations.

b. Relationships and Interactions:
– UI components (screens/widgets) interact with Provider classes that encapsulate the business rules.
– Providers manipulate and use Models for representing data.
– Data persistence components (like database_helper) are invoked by Providers to perform CRUD operations.
– UI updates occur reactively when Providers update state, creating a data flow from user input to data layer and back as updates.
– External libraries and native APIs integrate into Providers and UI as needed (for charts, authentication, file I/O).

c. Architectural Patterns & Principles:
– MVC/MVVM-like separation: UI (screens/widgets) are decoupled from business logic (providers) which in turn operate on the models.
– Clear separation of concerns: UI, state management, and data storage are distinctly separated.
– Reactive design: Using Provider to manage dependencies and state, ensuring UI reflects changes.

d. Technologies/Frameworks:
- Flutter & Dart for UI and app development.
- Provider for state management.
- sqflite and flutter_secure_storage for local data persistence.
- fl_chart for rendering interactive charts.
- local_auth for biometric authentication.
- Various native integrations in the platform-specific folders.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1["Screens"]:::ui
        UI2["Widgets"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL["Providers"]:::provider
    end

    %% Data & Persistence Layer
    subgraph "Data & Persistence Layer"
        DM["Models"]:::model
        DB["Database Helper"]:::database
    end

    %% External Integrations & Services
    subgraph "External Integrations & Services"
        EXT["External Services (local_auth, fl_chart, CSV, flutter_secure_storage)"]:::external
    end

    %% Platform Specific Configurations
    subgraph "Platform Specific Configurations"
        AND["Android"]:::platform
        IOS["iOS"]:::platform
        LNX["Linux"]:::platform
        MAC["macOS"]:::platform
        WIN["Windows"]:::platform
        WEB["Web"]:::platform
    end

    %% Core Flutter Engine
    ENG["Flutter Engine"]:::engine

    %% Connections between layers
    UI1 -->|"triggers"| BL
    UI2 -->|"interacts"| BL
    BL -->|"uses"| DM
    BL -->|"stores data via"| DB
    BL -->|"integrates with"| EXT

    %% Platform to Flutter Engine connections
    AND --> ENG
    IOS --> ENG
    LNX --> ENG
    MAC --> ENG
    WIN --> ENG
    WEB --> ENG

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef provider fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef model fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef platform fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef engine fill:#FADBD8,stroke:#922B21,stroke-width:2px;

    %% Click Events
    click UI1 "https://github.com/condoriluis/control-de-gastos/tree/main/lib/screens/"
    click UI2 "https://github.com/condoriluis/control-de-gastos/tree/main/lib/widgets/"
    click BL "https://github.com/condoriluis/control-de-gastos/tree/main/lib/providers/"
    click DM "https://github.com/condoriluis/control-de-gastos/tree/main/lib/models/"
    click DB "https://github.com/condoriluis/control-de-gastos/blob/main/lib/utils/database_helper.dart"
    click AND "https://github.com/condoriluis/control-de-gastos/tree/main/android/"
    click IOS "https://github.com/condoriluis/control-de-gastos/tree/main/ios/"
    click LNX "https://github.com/condoriluis/control-de-gastos/tree/main/linux/"
    click MAC "https://github.com/condoriluis/control-de-gastos/tree/main/macos/"
    click WIN "https://github.com/condoriluis/control-de-gastos/tree/main/windows/"
    click WEB "https://github.com/condoriluis/control-de-gastos/tree/main/web/"
```
