# jmancentral/frontendfinanzapp architecture

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

- Interactive diagram: https://gitdiagram.com/jmancentral/frontendfinanzapp
- Repository: https://github.com/jmancentral/frontendfinanzapp

## Overview

##### Main Components
- User Interface (UI) Layer:
- This includes Android activities (e.g., MainActivity, Dashboard, Login, Registro), fragments (e.g., DashboardFragment, FragmentAlertas, FragmentCategorias, FragmentProyecciones, etc.), and layout resources (in the “res/layout” folder).
- Visualizing each major screen or grouping related screens (e.g., finance summaries, recordatorios, tips, etc.).
- ViewModel Layer:
- The “ViewModelsApiRest” package shows that there are view models for various financial aspects (e.g., AlcanciaViewModel, AlertViewModel, IncomeViewModel, etc.).
- Repository and Data Service Layer:
- The “RepositoriosApiRest” package contains repositories such as AlcanciaRepository, AlertRepository, and others which likely manage RESTful API communications.
- Also, the “Utils” folder contains services (e.g., AuthInterceptor, Cliente, various services like IngresoService, GastoService) that support API calls and network communications.
- Local Data & Persistence:
- The “schemas” directory holds JSON files for “AppDatabase” and DAOS which indicate a local database (or local schema definitions) for storing data.
- This component should be depicted as a database layer accessed by the repositories or directly by some service logic.
- Notificaciones / External Services:
- The “Notificaciones” package includes classes like FCMService, NotificationHelper, and RecordatorioReceiver which are used to receive and manage push notifications (presumably via Firebase Cloud Messaging).
- External Libraries:

##### Relationships and Interactions
- The UI layer should be diagrammed as the starting point where user actions trigger interactions.
- From the ViewModels, show connections to the Repository layer (“RepositoriosApiRest”), which in turn either fetch data from the remote services (via APIs) or interact with the local database (represented by the schema files).
- Detail that the “Utils” services (including network interceptors and client classes) assist the repositories with secure and proper API communication.
- That the Notificaciones component independently interacts with both the user (via UI notifications) and back-end services (through FCM).

##### Architectural Patterns and Design Principles
- MVVM Pattern: Clearly label pages (UI layer) linked to view models, which mediate data handling and decisions.
- Repository Pattern: Specify that the repositories are the abstraction layer for API calls and local data management.
- Separation of Concerns: Highlight how each component is responsible for a specific part of the functionality (for example, UI is solely for presentation, the ViewModel for business logic, and repositories for data fetching).
- Integration with External Services: Outline the notification flow from FCM to the app.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface (UI) Layer
    subgraph "User Interface (UI) Layer"
        UI_Components["Android Activities & Fragments"]:::uiLayer
        Layout_Resources["Layout XML Files"]:::uiLayer
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        ViewModels["ViewModels (MVVM)"]:::viewModelLayer
    end

    %% Repository & Data Service Layer
    subgraph "Repository & Data Service Layer"
        Repository["API Repositories"]:::repoLayer
        API_Services["Network Services (Utils)"]:::repoLayer
    end

    %% Local Data & Persistence
    subgraph "Local Data & Persistence"
        Local_Data["Local Database (AppDatabase/DAOS)"]:::dataLayer
    end

    %% Notificaciones / External Services
    subgraph "Notificaciones / External Services"
        Notificaciones["Push Notification Services"]:::notificationLayer
    end

    %% External Libraries
    subgraph "External Libraries"
        HelloCharts["HelloCharts Library"]:::libraryLayer
    end

    %% External APIs
    subgraph "External APIs"
        External_APIs["Firebase Cloud Messaging & Others"]:::external
    end

    %% Connections
    UI_Components -->|"triggers"| ViewModels
    Layout_Resources -->|"supports"| UI_Components
    ViewModels -->|"calls"| Repository
    Repository -->|"uses"| API_Services
    Repository -->|"reads/writes"| Local_Data
    API_Services -->|"communicates_with"| External_APIs
    Notificaciones -->|"sends_notifications_to"| UI_Components
    UI_Components -->|"integrates_charts_via"| HelloCharts

    %% Click Events
    click UI_Components "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/java/com/practica/finazapp/Vista"
    click Layout_Resources "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/res/layout"
    click ViewModels "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/java/com/practica/finazapp/ViewModelsApiRest"
    click Repository "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/java/com/practica/finazapp/RepositoriosApiRest"
    click API_Services "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/java/com/practica/finazapp/Utils"
    click Local_Data "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/schemas"
    click Notificaciones "https://github.com/jmancentral/frontendfinanzapp/tree/main/FinazappFinal/FinazApp/app/src/main/java/com/practica/finazapp/Notificaciones"
    click HelloCharts "https://github.com/jmancentral/frontendfinanzapp/blob/main/FinazappFinal/FinazApp/app/libs/hellocharts-library-1.5.8.jar"

    %% Styles for layers
    classDef uiLayer fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef viewModelLayer fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef repoLayer fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
    classDef dataLayer fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef notificationLayer fill:#F08080,stroke:#DC143C,stroke-width:2px;
    classDef libraryLayer fill:#D8BFD8,stroke:#800080,stroke-width:2px;
    classDef external fill:#FFCCCB,stroke:#FF0000,stroke-width:2px;
```
