# haiau2501/apartment-management-solution architecture

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

- Interactive diagram: https://gitdiagram.com/haiau2501/apartment-management-solution
- Repository: https://github.com/haiau2501/apartment-management-solution

## Overview

##### Project Type & Purpose
- This is a full-stack mobile and multi-platform application built with Flutter and Dart.
- It is designed to manage apartment/community operations, catering to three main user groups (administrators, residents, and guests) by applying a Modular Monolith architecture with Domain-Driven Design (DDD).
- The application implements features such as user authentication, admin dashboards, payment and fee management, event handling, complaints, and notifications.

##### Analyzing the File Structure
- The top-level directories include configuration and platform-specific folders (android, ios, web, windows, macos, linux), which indicate support across multiple platforms.
- The core business logic and UI code reside in the “lib” folder. Notice the two main parts:
- “core” – Contains shared constants, utilities (e.g., extensions, translations), themes, and common widgets.
- “features” – Organized into several submodules (e.g., .authentication, admin, resident, guest). Each module shows further separation into data, domain, and presentation layers, which is in line with DDD.
- Additional documentation files (in the .document folder) and CI/CD config files are also present, ensuring the project’s maintainability and automation.

##### Key Components
a. Frontend/UI Layer:
- Represented by Flutter’s presentation components.
- The “presentation” subdirectories under each feature (authentication, admin, resident, guest) serve as the UI pages and widgets.
b. Domain/Business Logic Layer:
- Each feature retains a “domain” folder, modeling business entities (users, complaints, fees, events, etc.) and core rules.
- DDD aspect by showing entities and services which represent core business logic.
c. Data Access/Repository Layer:
- “data” directories in each feature encapsulate repositories and service implementations for backend operations (such as authentication, fee processing, complaint handling) including external service integrations (example: weather service).
d. Core Module:
- Acts as the shared layer of utilities, constants, themes, and common widgets, which is used by all feature modules.
e. Platform-Specific Layers:
- Although the primary code is in Dart/Flutter, include an outer layer for cross-platform compatibility (Android, iOS, web, desktop) managed by Flutter’s engine and platform-specific configuration.
f. External Systems & Integration Points:

##### Relationships & Interactions
- From UI (presentation layer) → Domain/Business Logic (domain layer) → Data/Repository layer.
- Dependencies from feature modules to the shared “core” module.

##### Architectural Patterns & Design Principles
- Modular Monolith: Emphasize how each module (feature) is self-contained yet integrated to the whole system.
- Domain-Driven Design: Highlight the separation between domain models, business rules, and data access logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Outer Container for Flutter Application
    subgraph "Flutter Application"
        %% Platform Layer
        subgraph "Platform Layer"
            android("Android"):::platform
            ios("iOS"):::platform
            web("Web"):::platform
            linux("Linux"):::platform
            macos("MacOS"):::platform
            windows("Windows"):::platform
        end

        %% Core Module
        subgraph "Core Module"
            core("Core Shared Utilities"):::core
            constants("Constants"):::core
            utils("Utils"):::core
        end

        %% Features Section
        subgraph "Features"
            %% Authentication Module
            subgraph "Authentication Module"
                Auth_UI("UI"):::ui
                Auth_Domain("Domain"):::domain
                Auth_Data("Data"):::data
            end
            %% Admin Module
            subgraph "Admin Module"
                Admin_UI("UI"):::ui
                Admin_Domain("Domain"):::domain
                Admin_Data("Data"):::data
            end
            %% Resident Module
            subgraph "Resident Module"
                Resident_UI("UI"):::ui
                Resident_Domain("Domain"):::domain
                Resident_Data("Data"):::data
            end
            %% Guest Module
            subgraph "Guest Module"
                Guest_UI("UI"):::ui
            end
        end

        %% External Integrations
        subgraph "External Integrations"
            External("Remote API/Database"):::external
        end
    end

    %% Platform to Core Connections
    android -->|"runs_on"| core
    ios -->|"runs_on"| core
    web -->|"runs_on"| core
    linux -->|"runs_on"| core
    macos -->|"runs_on"| core
    windows -->|"runs_on"| core

    %% Feature Layer Internal Flows
    %% Authentication Module
    Auth_UI -->|"trigger"| Auth_Domain
    Auth_Domain -->|"dataReq"| Auth_Data

    %% Admin Module
    Admin_UI -->|"trigger"| Admin_Domain
    Admin_Domain -->|"dataReq"| Admin_Data

    %% Resident Module
    Resident_UI -->|"trigger"| Resident_Domain
    Resident_Domain -->|"dataReq"| Resident_Data

    %% Core Module connections to Features (shared utilities)
    core -->|"provides"| Auth_UI
    core -->|"provides"| Auth_Domain
    core -->|"provides"| Auth_Data
    core -->|"provides"| Admin_UI
    core -->|"provides"| Admin_Domain
    core -->|"provides"| Admin_Data
    core -->|"provides"| Resident_UI
    core -->|"provides"| Resident_Domain
    core -->|"provides"| Resident_Data
    core -->|"provides"| Guest_UI

    constants -->|"defines"| Auth_UI
    constants -->|"defines"| Admin_UI
    constants -->|"defines"| Resident_UI
    constants -->|"defines"| Guest_UI

    utils -->|"assists"| Auth_Domain
    utils -->|"assists"| Admin_Domain
    utils -->|"assists"| Resident_Domain

    %% Data Layers to External Integrations
    Auth_Data -->|"external"| External
    Admin_Data -->|"external"| External
    Resident_Data -->|"external"| External

    %% Click Events for Frontend/UI Layer
    click Auth_UI "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/.authentication/presentation"
    click Admin_UI "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/admin/presentation"
    click Guest_UI "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/guest/presentation"
    click Resident_UI "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/resident/presentation"

    %% Click Events for Domain/Business Logic Layer
    click Auth_Domain "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/.authentication/domain"
    click Admin_Domain "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/admin/domain"
    click Resident_Domain "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/resident/domain"

    %% Click Events for Data Access/Repository Layer
    click Auth_Data "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/.authentication/data"
    click Admin_Data "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/admin/data"
    click Resident_Data "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/features/resident/data"

    %% Click Events for Core Module
    click core "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/core"
    click constants "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/core/constants"
    click utils "https://github.com/haiau2501/apartment-management-solution/tree/main/lib/core/utils"

    %% Click Events for Platform-Specific Layers
    click android "https://github.com/haiau2501/apartment-management-solution/tree/main/android"
    click ios "https://github.com/haiau2501/apartment-management-solution/tree/main/ios"
    click web "https://github.com/haiau2501/apartment-management-solution/tree/main/web"
    click linux "https://github.com/haiau2501/apartment-management-solution/tree/main/linux"
    click macos "https://github.com/haiau2501/apartment-management-solution/tree/main/macos"
    click windows "https://github.com/haiau2501/apartment-management-solution/tree/main/windows"

    %% Style Definitions
    classDef ui fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef domain fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef data fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef core fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef platform fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe5b4,stroke:#333,stroke-width:2px;
```
