# nguyenvanthai2904/project_cnpm architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenvanthai2904/project_cnpm
- Repository: https://github.com/nguyenvanthai2904/project_cnpm

## Overview

##### Project Type and Purpose
- This is an Android mobile application. The directory structure clearly indicates standard Android components (Activities, Fragments, Adapters, etc.) and configuration files (AndroidManifest.xml, Gradle build scripts, google-services.json) indicating integration with external services (likely Firebase).
- The app appears to handle functionalities related to money management or expense tracking (files like Expense.java, activity layouts for login, group details, personal, report, etc.).

##### Main Components
a. UI Layer:
- Activities – e.g., LoginActivity, SignupActivity, MainActivity, GroupExpensesActivity, etc.
- Fragments – e.g., CalendarFragment, ChartFragment, MoreFragment, TransactionFragment.
- Layouts & Resources – All XML layout files and resources (drawables, menus, values) represent the visual elements and UI design.
- Adapters – MoreMyArrayAdapter and MyArrayAdapter used to bind data to ListViews or RecyclerViews.

b. Business and Controller Layer:
- Controller Package – Contains activity controllers and fragments that react to user interactions and mediate flows between UI and data.
- Model Package – Holds the domain models such as Expense, Service, and item which represent the business data.

c. External & Supporting Components:
- External Services – The presence of google-services.json hints at Firebase integration or another cloud-based service for authentication, analytics, or data sync.
- Build & Infrastructure – Gradle build scripts, wrapper files, and configuration settings portray the project’s build and dependency management.
- Testing – The androidTest and test directories indicate where unit and instrumented tests are integrated into the system.

##### Relationship and Interactions
- The user interacts with the app’s UI (Activities and Fragments), triggering events.
- These UI components, part of the Controller layer, communicate with model objects (Expense, Service, etc.) to apply business logic.
- The Adapters facilitate data presentation in lists or grids by binding model data to UI components.
- External services (i.e., Firebase) can be depicted as a separate module that supports authentication, analytics, or backend storage.
- Gradle and configuration files are responsible for building, managing dependencies, and packaging the app.

##### Architectural Patterns and Design Principles
- An MVC/MVVM pattern is suggested by the clear separation between controllers (activities & fragments), models, and views (layouts & XML resources).
- There is a modular separation: the “app” module encapsulates the main application and its core functionalities.
- Emphasis on separation of concerns is visible with dedicated directories for UI controllers, data models, and adapters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    user["User"]:::user

    subgraph "UI Layer"
        activities["Activities"]:::ui
        fragments["Fragments"]:::ui
        adapters["Adapters"]:::ui
        resources["Layouts & Resources"]:::ui
    end

    subgraph "Business/Controller Layer"
        controller["Controller"]:::controller
    end

    model["Model Layer"]:::model
    firebase["External Services (Firebase)"]:::external
    build["Build & Infrastructure"]:::build
    testing["Testing Components"]:::testing

    %% User interactions
    user -->|"triggers"| activities
    user -->|"triggers"| fragments
    user -->|"triggers"| adapters
    user -->|"triggers"| resources

    %% UI to Business/Controller communication
    activities -->|"sendsInput"| controller
    fragments -->|"sendsInput"| controller
    adapters -->|"sendsData"| controller
    resources -->|"rendersWith"| controller

    %% Controller interactions with Model and External Services
    controller -->|"processes"| model
    controller -->|"syncs"| firebase

    %% Support modules
    build -->|"builds"| controller
    testing -->|"tests"| controller

    %% Click Events
    click activities "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/java/com/example/moneymate/controller/activity"
    click fragments "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/java/com/example/moneymate/controller/fragment"
    click adapters "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/java/com/example/moneymate/controller/adapter"
    click controller "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/java/com/example/moneymate/controller"
    click model "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/java/com/example/moneymate/model"
    click firebase "https://github.com/nguyenvanthai2904/project_cnpm/blob/master/src/app/google-services.json"
    click resources "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/main/res"
    click build "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/build.gradle.kts, src/build.gradle.kts, src/gradle.properties, src/gradle/wrapper"
    click testing "https://github.com/nguyenvanthai2904/project_cnpm/tree/master/src/app/src/androidTest and test"

    %% Styles
    classDef user fill:#DDEBF7,stroke:#000,stroke-width:2px;
    classDef ui fill:#CFE2F3,stroke:#000,stroke-width:2px;
    classDef controller fill:#FFD966,stroke:#000,stroke-width:2px;
    classDef model fill:#F4CCCC,stroke:#000,stroke-width:2px;
    classDef external fill:#D9EAD3,stroke:#000,stroke-width:2px;
    classDef build fill:#FFF2CC,stroke:#000,stroke-width:2px;
    classDef testing fill:#EAD1DC,stroke:#000,stroke-width:2px;
```
