# adrianbl1/mantenimiento_control architecture

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

- Interactive diagram: https://gitdiagram.com/adrianbl1/mantenimiento_control
- Repository: https://github.com/adrianbl1/mantenimiento_control

## Overview

##### Main Components
- User Interface Layer: This includes all the Activities and Fragments (such as MainActivity, Autentificacion, Estadisticas, ExportReport, PerfilAdministrador, PerfilUsuario, RealizarReporteIncidente, RegistrarEstadoIncidente, ReporteIncidente, WithoutConnection, and TimePickerFragment) as found in the app/src/main/res/layout and app/src/main/java/… directories.
- Data Models: Represent the Incidencia and Usuario classes from the models package.
- Business Logic / ViewModel Layer: While your file structure might not explicitly contain “ViewModel” classes, it does mention the MVVM pattern. This implies that there is (or should be) a layer that coordinates UI actions with business logic.
- Firebase Backend Services: This comprises Firebase Authentication, Firestore/Realtime Database (for incident data), and Cloud Storage (for saving evidence/media files).

##### Mapping Relationships and Interactions
- The UI components (Activities, Fragments) interact with the ViewModel (business logic layer) to trigger operations such as user authentication, incident submission, status updates, and report exporting.
- The ViewModel layer then communicates with the Firebase backend services to perform data operations (saving incidents, updating statuses, retrieving reports, managing users, etc.).
- Data Models (Incidencia and Usuario) are used to structure the data transfer between UI, ViewModel, and Firebase.
- There is also a handling mechanism for offline scenarios (“WithoutConnection”), which should be depicted as a fallback UI state in case of network failure.

##### Architectural Patterns and Technologies
- Architecture: MVVM
- Separation of concerns: View (UI), ViewModel (logic), and Model (data).
- Firebase Integration: Show that Firebase handles authentication (login, reset password), data storage (Firestore and/or Firebase Database), and media storage (Cloud Storage) for evidence.
- Android-Specific Components: Note the use of Android Activities, Fragments (like TimePickerFragment), and resource directories holding layouts, drawables, and strings. This is crucial for understanding the flow from user interaction to backend processing.
- UI Feedback / Connectivity Strategy: “WithoutConnection” view which handles loss of connectivity.

##### Additional Details
- Since the project uses Kotlin and Gradle, mention that these tools underpin the development process, even though they might not be a part of the runtime architecture.
- User roles: The existence of distinct user profiles—PerfilAdministrador and PerfilUsuario—to indicate role-based access control, especially in the area of managing incidents.
- Reporting/export features: Show how the ExportReport functionality ties into the reporting workflow and possibly outputs a PDF stored locally.

- Then branch into the main dashboard (MainActivity) that displays incidents and provides navigation to different screens (realizar reporte, registrar estado, etc.)
- Side branches for specific flows like “Sin Conexión” and reporting features.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "User Interface (Activities & Fragments)"
        A1["Autentificacion"]:::ui
        A2["MainActivity"]:::ui
        A3["Estadisticas"]:::ui
        A4["ExportReport"]:::ui
        A5["PerfilAdministrador"]:::ui
        A6["PerfilUsuario"]:::ui
        A7["RealizarReporteIncidente"]:::ui
        A8["RegistrarEstadoIncidente"]:::ui
        A9["ReporteIncidente"]:::ui
        A10["WithoutConnection"]:::ui
        F1["TimePickerFragment"]:::ui
        L1["UI Layouts"]:::ui
    end

    %% Business Logic / ViewModel Layer
    subgraph "Business Logic / ViewModel Layer"
        BL["ViewModel / Business Logic"]:::logic
    end

    %% Data Models
    subgraph "Data Models"
        M1["Incidencia"]:::models
        M2["Usuario"]:::models
    end

    %% Firebase Services
    subgraph "Firebase Services"
        FB1["Firebase Authentication"]:::firebase
        FB2["Firestore/Realtime Database"]:::firebase
        FB3["Cloud Storage"]:::firebase
        FBConfig["Firebase Config"]:::firebase
    end

    %% UI to Business Logic interactions
    A1 -->|"triggers"| BL
    A2 -->|"triggers"| BL
    A3 -->|"triggers"| BL
    A4 -->|"triggers"| BL
    A5 -->|"triggers"| BL
    A6 -->|"triggers"| BL
    A7 -->|"triggers"| BL
    A8 -->|"triggers"| BL
    A9 -->|"triggers"| BL
    A10 -->|"fallback"| BL
    F1 -->|"used by"| BL
    L1 -->|"resources"| A1

    %% Business Logic to Data Models and Firebase interactions
    BL -->|"uses"| M1
    BL -->|"uses"| M2
    BL -->|"auth_request"| FB1
    BL -->|"data_ops"| FB2
    BL -->|"media_upload"| FB3

    %% Firebase configuration connections
    FBConfig -->|"configures"| FB1
    FBConfig -->|"configures"| FB2
    FBConfig -->|"configures"| FB3

    %% Click Events for UI Components
    click A1 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/Autentificacion.kt"
    click A2 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/MainActivity.kt"
    click A3 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/Estadisticas.kt"
    click A4 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/ExportReport.kt"
    click A5 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/PerfilAdministrador.kt"
    click A6 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/PerfilUsuario.kt"
    click A7 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/RealizarReporteIncidente.kt"
    click A8 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/RegistrarEstadoIncidente.kt"
    click A9 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/ReporteIncidente.kt"
    click A10 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/WithoutConnection.kt"
    click F1 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/fragments/TimePickerFragment.kt"
    click L1 "https://github.com/adrianbl1/mantenimiento_control/tree/master/app/src/main/res/layout"
    click M1 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/models/Incidencia.kt"
    click M2 "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/src/main/java/com/adrianbl/mantenimiento_control/models/Usuario.kt"
    click FBConfig "https://github.com/adrianbl1/mantenimiento_control/blob/master/app/google-services.json"

    %% Styles for different layers
    classDef ui fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef logic fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef models fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef firebase fill:#FFE082,stroke:#FF8F00,stroke-width:2px;
```
