# haberleslucas/app-android architecture

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

- Interactive diagram: https://gitdiagram.com/haberleslucas/app-android
- Repository: https://github.com/haberleslucas/app-android

## Overview

##### Project Type and Purpose
- The project is a native Android app written in Kotlin.
- Its primary functions include calculating costs, managing client data, generating receipts, and facilitating the sending of these receipts via WhatsApp.
- That there are both UI elements (activities, layouts) and business logic that work together to deliver these features.

##### Analyzing the File Structure
- The top-level “app” directory shows that all Android-specific code resides here.
- Under “app/src/main”, you find:
- AndroidManifest.xml: which declares the application’s components.
- Java packages containing MainActivity.kt and SecondActivity.kt indicate primary screens.
- “res” directory contains layout XML files (activity_main.xml, second_activity.xml) and other resources (drawables, values, xml configuration files).
- The “src/androidTest” and “src/test” directories indicate there are both instrumented and unit tests, which might be part of quality assurance rather than the central system architecture.
- Gradle files and the settings indicate standard Android project configurations.

##### Components
a. UI Layer:
- MainActivity and SecondActivity – representing distinct screens for entering calculation data (like time, hourly cost) and registering client information.
- Layouts (activity_main.xml, second_activity.xml) – show the visual composition of these screens.
b. Business Logic Layer:
- Calculation module – handles the core computation of total cost based on user input.
- Client management and form processing – logic to register and update client details.
- Receipt generation module – compiles calculation results, client info, timestamps, and formatting into a receipt.
c. Integration Layer:
- WhatsApp integration – a module or intent invocation responsible for sending the generated receipt.
d. Supporting Components:
- Android resource management – images, drawable files, and styles that secure the app’s aesthetic.
- Testing modules – indicating unit tests and instrumented tests to ensure reliability.
- (Optional) External libraries – if any framework or dependency injection is used (though not explicitly visible, often projects have integrations through Gradle).

##### Relationships and Interactions
- Data flow starts at the UI layer (user inputs provided in the activities via forms and buttons).
- These inputs are processed in the business logic layer (where calculation and validations occur).
- Once a calculation is complete and a client is registered, the receipt generation module formats the output.
- Finally, the integration component invokes WhatsApp functionality to deliver the receipt.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        MA["MainActivity (UI)"]:::ui
        LM["activity_main.xml"]:::ui
        SA["SecondActivity (UI)"]:::ui
        LS["second_activity.xml"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        CC["Cost Calculator Module"]:::logic
        CR["Client Registration Module"]:::logic
        RG["Receipt Generator"]:::logic
    end

    %% Integration Layer
    subgraph "Integration Layer"
        WA["WhatsApp Integration"]:::integration
    end

    %% Supporting Components: Android Resources
    subgraph "Android Resources"
        DR["Drawable Resources"]:::resource
        VT["Values & Themes"]:::resource
    end

    %% Supporting Components: Testing Modules
    subgraph "Testing Modules"
        IT["Instrumented Tests"]:::testing
        UT["Unit Tests"]:::testing
    end

    %% Data Flow Connections
    MA -->|"input_cost_details"| CC
    SA -->|"input_client_details"| CR
    CC -->|"send_calculation"| RG
    CR -->|"send_client_data"| RG
    RG -->|"formatted_receipt"| WA

    %% Optional UI to Resource connections
    LM --- DR
    LM --- VT
    LS --- DR
    LS --- VT

    %% Testing Connections (dotted lines)
    IT -.-> CC
    IT -.-> RG
    UT -.-> CC
    UT -.-> CR
    UT -.-> RG

    %% Legend
    subgraph "Legend"
        LUI["UI Layer: Blue"]:::ui
        LBL["Business Logic: Green"]:::logic
        LINT["Integration: Orange"]:::integration
        LRES["Android Resources: Yellow"]:::resource
        LTEST["Testing: Purple"]:::testing
    end

    %% Click Events
    click MA "https://github.com/haberleslucas/app-android/blob/main/app/src/main/java/com/example/tarifariohaberles/MainActivity.kt"
    click LM "https://github.com/haberleslucas/app-android/blob/main/app/src/main/res/layout/activity_main.xml"
    click SA "https://github.com/haberleslucas/app-android/blob/main/app/src/main/java/com/example/tarifariohaberles/SecondActivity.kt"
    click LS "https://github.com/haberleslucas/app-android/blob/main/app/src/main/res/layout/second_activity.xml"
    click DR "https://github.com/haberleslucas/app-android/tree/main/app/src/main/res/drawable"
    click VT "https://github.com/haberleslucas/app-android/tree/main/app/src/main/res/values"
    click IT "https://github.com/haberleslucas/app-android/blob/main/app/src/androidTest/java/com/example/tarifariohaberles/ExampleInstrumentedTest.kt"
    click UT "https://github.com/haberleslucas/app-android/blob/main/app/src/test/java/com/example/tarifariohaberles/ExampleUnitTest.kt"

classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
classDef logic fill:#A9DFBF,stroke:#186A3B,stroke-width:2px;
classDef integration fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
classDef resource fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
classDef testing fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
classDef legend fill:#D5DBDB,stroke:#34495E,stroke-width:1px,fontsize:10px;
```
