# thanghoang54/rental-property-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/thanghoang54/rental-property-management-system
- Repository: https://github.com/thanghoang54/rental-property-management-system

## Overview

##### Main Components
- User Interface:
- Represented by the ManagerUI.java component, which handles the text-based user interactions.
- Business Logic & Controllers:
- ModelManager and its implementation (ModelManagerImp.java) manage the data retrieval and business rules surrounding the different entities.
- RentalAgreementManager (with RentalManager and its implementation) specifically handles operations related to rental agreements, such as addition, deletion, and update.
- The Build or Builder component may be used for constructing RentalAgreement objects in a controlled manner.
- Data Management:
- FileManager and DataPersistence classes indicate that the system uses file-based persistence (CSV files) to store and retrieve data.
- The CSV files located in the src/data folder represent the persistent storage for various models (Tenant, Host, Owner, Payment, Properties, RentalAgreement).
- Report Generation:
- A dedicated SaveReport submodule is responsible for generating and exporting reports as CSV files after processing.
- Domain Models:
- The model directory contains the classes for the core entities (e.g., CommercialProperty, ResidentialProperty, Tenant, Owner, Host, Payment, RentalAgreement, and Person) that are central to the business logic.
- Utilities:
- Helper classes in src/util (Input.java, ValidateInput.java) assist with user input and validation across the application.

##### Relationships and Interactions
- The UI layer (ManagerUI) collects user commands and input, then passes these to the appropriate controller (ModelManager or RentalAgreementManager) based on the task (e.g., view, add, update, delete).
- The controller components encapsulate business logic by:
- Interacting with the FileManager to load and persist data stored as CSV files.
- Handling object creation using the builder pattern from the Build module.
- Mediating between the UI and the underlying domain models.
- The domain model classes form the core data structures that are manipulated by both the business logic and persistence layers.
- Data flows from:
- CSV files in the “src/data” directory → to FileManager → to Business Controllers → then, optionally, to the user via ManagerUI, or to reports via the SaveReport module.
- Report generation at the end of the application flow takes the processed or filtered models and writes them out as CSV files into the SaveReport folder.

##### Important Architectural Patterns and Design Principles
- Separation of Concerns:
- The application clearly separates the user interface, business logic, data persistence, and domain models into distinct modules.
- Layered Architecture:
- UI, business logic (controllers and managers), and data management (persistence and file access) layers communicate in a clear, sequential manner.
- Use of the Builder Pattern:
- The presence of a Builder (e.g., BuilderRentalAgreement.java) indicates an effort to manage object creation in a flexible and standardized way.
- File-based Persistence:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface"
        UI["ManagerUI"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        MM["ModelManager.java"]:::bl
        MMI["ModelManagerImp.java"]:::bl
        RAM["RentalManager.java"]:::bl
        RAMI["RentalManagerImp.java"]:::bl
        BR["BuilderRentalAgreement.java"]:::bl
    end

    %% Data Persistence Layer
    subgraph "Data Persistence"
        DPM["DataPersistenceManager.java"]:::dp
        DPI["DataPersistenceImp.java"]:::dp
        CSV["CSV Data (src/data)"]:::storage
    end

    %% Domain Models Layer
    subgraph "Domain Models"
        DM["Domain Models (src/model)"]:::domain
    end

    %% Report Generation Layer
    subgraph "Report Generation"
        SR["SaveReport (src/SaveReport)"]:::report
    end

    %% Utilities (Input & Validation)
    subgraph "Utilities"
        UT["Utilities (src/util)"]:::util
    end

    %% Arrows for interactions
    UI -->|"triggers"| MM
    UI -->|"triggers"| RAM
    UI -->|"validatesUsing"| UT

    MM -->|"delegates"| MMI
    RAM -->|"delegates"| RAMI
    RAM -->|"usesBuilder"| BR

    MM -->|"operatesOn"| DM
    RAM -->|"operatesOn"| DM

    MM -->|"calls"| DPM
    RAMI -->|"calls"| DPI

    DPM -->|"reads/writes"| CSV
    DPI -->|"reads/writes"| CSV

    MM -->|"generatesReport"| SR
    RAMI -->|"generatesReport"| SR

    %% Click Events
    click UI "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/ManagerUI.java"
    click MM "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/ModelManager/ModelManager.java"
    click MMI "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/ModelManager/ModelManagerImp.java"
    click RAM "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/RentalAgreementManager/RentalManager.java"
    click RAMI "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/RentalAgreementManager/RentalManagerImp.java"
    click BR "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/Build/BuilderRentalAgreement.java"
    click DPM "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/FileManager/DataPersistenceManager.java"
    click DPI "https://github.com/thanghoang54/rental-property-management-system/blob/main/src/FileManager/DataPersistenceImp.java"
    click CSV "https://github.com/thanghoang54/rental-property-management-system/tree/main/src/data"
    click SR "https://github.com/thanghoang54/rental-property-management-system/tree/main/src/SaveReport"
    click DM "https://github.com/thanghoang54/rental-property-management-system/tree/main/src/model"
    click UT "https://github.com/thanghoang54/rental-property-management-system/tree/main/src/util"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef bl fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef dp fill:#F4A460,stroke:#000,stroke-width:2px;
    classDef domain fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef report fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef util fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef storage fill:#FFE4B5,stroke:#000,stroke-width:2px;
```
