# minhphan46/nha_gia_re_mobile architecture

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

## Overview

##### Main Components
- Frontend (UI/Presentation): Represented by the Flutter codebase. The “lib/features/presentation” directory is organized by modules (e.g., account, chat, home, search, etc.) and includes both global widgets and feature-specific screens along with controllers and bindings using GetX.
- Domain Layer: Shown in the “lib/features/domain” directory—it contains entities, usecases, enums, and repository interfaces defining the business logic.
- Data Layer: In “lib/features/data” you have data sources (both local and remote), models, and repository implementations that deal with data persistence, API calls, and local databases.
- Core & Config: Common helpers and configurations such as error handling, network utilities, theming, route settings, and language translations are under “lib/core” and “lib/config”.
- Dependency Injection: Represented by “injection_container.dart”, indicating how different layers are connected.

##### Relationships and Interactions
- Data layer is linked to:
– Remote Data Sources (via REST API calls to the NodeJS backend)
– Local Data Sources (e.g., local databases or JSON data used for caching, as seen in assets and database helper files).
- The external backend and database are separate external components that the app calls into from the Data layer.
- Global services (e.g., network info, device-specific services) in “lib/core/service” also interact across multiple layers.

##### Architectural Patterns and Design Principles
- Clean Architecture: Clearly distinguish between presentation, domain, and data layers. Represent the dependency rule (outer layers depend on inner ones but not vice versa).
- Use of GetX for state management and dependency injection.
- Separation of configuration values (theme, languages, routes) supports modularity.
- Multi-platform support is evident from dedicated directories (android, ios, linux, macos, windows, web).

##### Relevant Technologies/Frameworks
- Flutter & Dart for the UI and application code.
- GetX for state management and dependency injection.
- Clean Architecture - organizing code into data (infrastructure), domain (business logic), and presentation (UI) layers.
- External API and PostgreSQL for backend services (provided via a NodeJS API).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Flutter Client"
        A["Presentation Layer (Flutter UI)"]:::presentation
        B["Domain Layer (Usecases & Entities)"]:::domain
        C["Data Layer (Remote & Local Data Sources)"]:::data
        A -->|"triggers_usecases"| B
        B -->|"calls_repository"| C
    end

    subgraph "Configuration"
        D["Core & Config"]:::core
        E["Dependency Injection"]:::di
    end

    subgraph "External Services"
        F["External Backend (NodeJS API)"]:::external
        G["Database (PostgreSQL)"]:::external
        subgraph "Multi-Platform Setup"
            H["Assets"]:::external
            I["Android"]:::external
            J["iOS"]:::external
            K["Linux"]:::external
            L["macOS"]:::external
            M["Web"]:::external
            N["Windows"]:::external
        end
    end

    D --- A
    D --- B
    D --- C
    E --- A
    E --- B
    E --- C

    C -->|"API_calls"| F
    C -->|"data_persistence"| G

    H --- A
    I --- A
    J --- A
    K --- A
    L --- A
    M --- A
    N --- A

    %% Click Events
    click A "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/lib/features/presentation"
    click B "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/lib/features/domain"
    click C "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/lib/features/data"
    click D "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/lib/core"
    click D "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/lib/config"
    click E "https://github.com/minhphan46/nha_gia_re_mobile/blob/main/lib/injection_container.dart"
    click H "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/assets"
    click I "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/android"
    click J "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/ios"
    click K "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/linux"
    click L "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/macos"
    click M "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/web"
    click N "https://github.com/minhphan46/nha_gia_re_mobile/tree/main/windows"

    %% Styles
    classDef presentation fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef domain fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef data fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef core fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
    classDef di fill:#d7ccc8,stroke:#5d4037,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
```
