# yojr23/hive_proyecto_final architecture

> Architecture diagram of the GitHub repository yojr23/hive_proyecto_final, 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/yojr23/hive_proyecto_final
- Repository: https://github.com/yojr23/hive_proyecto_final

## Overview

##### Project Type and Purpose
- The project is a mobile application aimed at social event networking. Its core functionalities include QR code-based event check-in, event discovery, user profile management, and real-time interaction.

##### Identifying Main Components
- UI Layer: Represented by Activities and Fragments (e.g., LoginActivity, MainActivity, HomePageFragment, CalendarFragment, EventCreationFragment, etc.) and supplemented by RecyclerView adapters (EventsAdapter, MyEventsAdapter).
- Domain/Model Layer: Contains data models such as User, Event, and UserSession.
- ViewModel Layer: Although not explicitly visible in the file structure, the README confirms that a dedicated viewmodels folder (or logically separated classes) exists which holds the business logic and acts as the mediator between the UI and data layers.
- Services/Utils: Helper classes for functionalities like sign-up, login, session management, and event creation (e.g., SignUpHelper, LoginHelper, EventCreationHelper).
- Data Persistence: Use of Firebase Cloud Firestore and Firebase Authentication for online data storage and user management; Room (SQLite) for offline data persistence.
- External Services: Google ML Kit for QR code scanning functionality.

##### Analyzing the File Structure for Architectural Insights
- The file hierarchy under app/src/main/java shows a structure grouping UI components (Activities, Fragments), adapters, models, and utility classes.
- The existence of configuration files (build.gradle.kts, proguard-rules.pro) indicates standard Android build and optimization practices.

##### Relationships and Interactions
- UI components (Activities/Fragments) interact with ViewModels to fetch and manipulate data.
- ViewModels interact with Models and use Services/Utils for handling business logic.
- Data layer: The application sends and retrieves data from Firebase services (for authentication and event/user data) and uses Room for local storage.
- QR code scanning is handled via an integration with Google ML Kit; the scanning module feeds information into the service layer which then updates user events or check-in statuses.

##### Architectural Patterns and Design Principles
- View: Activities, Fragments, and UI Adapters.
- ViewModel: Business logic and LiveData management.
- Model: Data representation (User, Event, etc.).
- Clearly distinguish between remote (Firebase, ML Kit) and local (Room) data sources.

##### Elements
- UI Components: LoginActivity, MainActivity, various Fragments (HomePageFragment, CalendarFragment, etc.), and Adapters.
- Business Logic: ViewModels, utilities (e.g., LoginHelper, EventCreationHelper).
- Data Management: Models (User, Event, UserSession), Room Database (offline storage), Firebase Authentication & Firestore (remote data).
- External Services: Google ML Kit for QR scanning.
- How scanning results from Google ML Kit travel via a service to update event attendance.
- Use labels to indicate the type of interactions (e.g., “Fetch Data”, “Authenticate”, “Scan QR”, “Store Data”).

##### Final Checklist
- That each module (view, viewmodel, model, service) is clearly labeled.
- MVVM architecture by showing a clear separation between presentation (UI), business logic (ViewModel/Services), and data (Models, External Services).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% UI Layer
    subgraph "UI Layer"
        UI1["LoginActivity"]:::ui
        UI2["MainActivity"]:::ui
        UI3["SignUpActivity"]:::ui
        UI4["CalendarFragment"]:::ui
        UI5["EventCreationFragment"]:::ui
        UI6["HomePageFragment"]:::ui
        UI7["UserProfileFragment"]:::ui
        UI8["EventsAdapter"]:::ui
        UI9["MyEventsAdapter"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        VM1["AppViewModel"]:::viewmodel
    end

    %% Service/Utility Layer
    subgraph "Service & Utility Layer"
        U1["LoginHelper"]:::utility
        U2["SignUpHelper"]:::utility
        U3["EventCreationHelper"]:::utility
        U4["SessionManager"]:::utility
    end

    %% Model Layer
    subgraph "Model Layer"
        M1["User"]:::model
        M2["Event"]:::model
        M3["UserSession"]:::model
    end

    %% Data Persistence & External Services
    subgraph "Data & External Services"
        D1["Firebase Auth & Firestore"]:::data
        D2["Room Database"]:::data
        E1["Google ML Kit"]:::external
    end

    %% Connections
    %% UI Layer connects to ViewModel
    UI1 -->|"binds"| VM1
    UI2 -->|"binds"| VM1
    UI3 -->|"binds"| VM1
    UI4 -->|"binds"| VM1
    UI5 -->|"binds"| VM1
    UI6 -->|"binds"| VM1
    UI7 -->|"binds"| VM1
    UI8 -->|"displays"| VM1
    UI9 -->|"displays"| VM1

    %% ViewModel interactions with Services/Utils
    VM1 -->|"calls"| U1
    VM1 -->|"calls"| U2
    VM1 -->|"calls"| U3
    VM1 -->|"manages"| U4

    %% Service/Utility interactions with Data Persistence
    U1 -->|"authenticates"| D1
    U2 -->|"registers"| D1
    U3 -->|"createsEvent"| D1
    U3 -->|"updatesLocal"| D2

    %% UI interactions for QR scanning
    UI5 -->|"scanQR"| E1
    E1 -->|"processQR"| U3

    %% ViewModel and Model relationship
    VM1 -->|"manipulates"| M1
    VM1 -->|"manipulates"| M2
    VM1 -->|"manipulates"| M3

    %% Data persistence: offline support
    VM1 -->|"storesOffline"| D2

    %% Firebase data flow for user and event data
    VM1 -->|"fetchesData"| D1

    %% Click Events for UI Components
    click UI1 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/LoginActivity.java"
    click UI2 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/MainActivity.java"
    click UI3 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/SignUpActivity.java"
    click UI4 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/CalendarFragment.java"
    click UI5 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/EventCreationFragment.java"
    click UI6 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/HomePageFragment.java"
    click UI7 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/UserProfileFragment.java"

    %% Click Events for RecyclerView Adapters
    click UI8 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/adapters/EventsAdapter.java"
    click UI9 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/adapters/MyEventsAdapter.java"

    %% Click Events for Data Models
    click M2 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/model/Event.java"
    click M1 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/model/User.java"
    click M3 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/model/UserSession.java"

    %% Click Events for Service/Utility Classes
    click U3 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/utils/EventCreationHelper.java"
    click U1 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/utils/LoginHelper.java"
    click U2 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/utils/SignUpHelper.java"

    %% Click Event for SessionManager
    click U4 "https://github.com/yojr23/hive_proyecto_final/blob/master/app/src/main/java/com/vicenterincon/hive_proyectofinal/adapters/SessionManager.java"

    %% Styling
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef viewmodel fill:#ABEBC6,stroke:#229954,stroke-width:2px;
    classDef utility fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef model fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef data fill:#FADBD8,stroke:#EC7063,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
