# chauminhtrung/rrms architecture

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

## Overview

##### Project Type and Purpose
- This is a full-stack web application to manage rental accommodations. The aim is to provide a user-friendly interface for searching, booking, and managing rental rooms along with the administrative and operational functionalities behind the scenes.
- The README confirms it is a “hệ thống quản lý nhà trọ” (rental management system) and describes features such as secure personal information, efficient room booking, and ease of management.

##### High-Level Architecture Overview
a. Frontend (Client Side):
- Located in the “client” directory.
- Built with modern front-end tools such as React (seen from .jsx files and React components), Vite (vite.config.js), and styling using Bootstrap/MUI.
- Contains separate directories for public assets, components, pages (like Login, Home, Detail, admin, etc.), configurations, internationalization (i18n), and utilities.
- Provides the user interface and communicates with backend REST APIs.

b. Backend (Server Side):
- Located in the “server” directory and built with Java using Spring Boot.
- Implements a layered architecture:
- Controllers: REST endpoints handling incoming HTTP requests.
- Services: Business logic implementations.
- Repositories: Data layer accessing MySQL (as suggested by data.sql and repository classes).
- Models & DTOs: Representing domain and data transfer objects.
- Configurations: Security (JWT, Redis, CORS), third-party integrations (Stripe, VNPay, MoMo), and others.
- Contains extensive configuration for logging (Logstash with its own configuration files) and uses Maven for build automation.

c. Data Storage and External Tools:
- Database: MySQL is used (data.sql and ERD .mwb files) to store application data.
- Caching: Redis configuration files indicate use for caching and rate limiting.
- Integration with external payment providers (Stripe, VNPay, MoMo) and possibly messaging/email services.
- Deployment: Docker (Dockerfile and docker-compose) is set up for containerization. There’s also configuration for Vercel for the client side.
- Logging & Analytics: Logstash setup in the server folder, indicating monitoring/logging integration that might connect with Elasticsearch/Kibana.

##### Relationships and Interactions
- The flow begins with users interacting with the frontend (React client) which consumes REST API endpoints provided by the backend (Spring Boot controllers).
- The backend layer processes business logic via its service layer, then interacts with a MySQL database for persistence and Redis for caching and rate limiting.
- External services for payments, messaging, file uploads, and possibly third-party APIs are integrated within the backend configuration.
- Logging is centralized using Logstash, which collects logs from various server components.

##### Architectural Patterns and Technologies
- Layered / MVC Architecture: Clear separation between presentation (client), business logic (services, controllers), and data access (repositories).
- Microservice-like separation within the backend modules (multiple controllers for account, authentication, room management, etc.) but within a monolithic Spring Boot application layout.
- Use of RESTful APIs for communication between the client and server.
- Modern development tools: Vite for fast client-side builds and Maven for Java backend builds.
- Use of containerization (Docker) for deployment consistency.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        A["React Client (Vite, JavaScript)"]:::frontend
    end

    %% Server Layer
    subgraph "Server Layer (Spring Boot)"
        B["REST API Controllers"]:::backend
        C["Service Layer (Business Logic)"]:::backend
        D["Data Access (Repositories)"]:::backend
        E["Configurations & Integrations"]:::backend
        F["Logging (Logstash)"]:::backend
    end

    %% Data & External Services
    subgraph "Data & External Services"
        G["MySQL Database"]:::database
        H["Redis (Cache & RateLimiter)"]:::external
        I["Payment Gateways (Stripe,VNPay,MoMo)"]:::external
    end

    %% Deployment & Containerization
    subgraph "Deployment & Containerization"
        L["Docker Deployment"]:::deployment
        M["Vercel Deployment"]:::deployment
    end

    %% Connections
    A -->|"REST_API"| B
    B -->|"process"| C
    C -->|"dataOps"| D
    C -->|"call"| E
    E -->|"uses"| H
    E -->|"integrates"| I
    B -->|"log"| F
    C -->|"log"| F
    E -->|"log"| F
    D -->|"read/write"| G
    M --> A
    L --> B

    %% Click Events
    click A "https://github.com/chauminhtrung/rrms/tree/main/client/"
    click B "https://github.com/chauminhtrung/rrms/tree/main/server/src/main/java/com/rrms/rrms/controllers"
    click C "https://github.com/chauminhtrung/rrms/tree/main/server/src/main/java/com/rrms/rrms/services"
    click D "https://github.com/chauminhtrung/rrms/tree/main/server/src/main/java/com/rrms/rrms/repositories"
    click E "https://github.com/chauminhtrung/rrms/tree/main/server/src/main/java/com/rrms/rrms/configs"
    click F "https://github.com/chauminhtrung/rrms/tree/main/server/logstash"
    click G "https://github.com/chauminhtrung/rrms/blob/main/ERD.mwb"
    click L "https://github.com/chauminhtrung/rrms/tree/main/server/Dockerfile"
    click M "https://github.com/chauminhtrung/rrms/blob/main/client/vercel.json"

    %% Styles
    classDef frontend fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef backend fill:#9fd3c7,stroke:#333,stroke-width:2px;
    classDef database fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef external fill:#c9daf8,stroke:#333,stroke-width:2px;
    classDef deployment fill:#d9ead3,stroke:#333,stroke-width:2px;
```
