# phongnickchinh/cnpm-20231 architecture

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

- Interactive diagram: https://gitdiagram.com/phongnickchinh/cnpm-20231
- Repository: https://github.com/phongnickchinh/cnpm-20231

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack web application: a Java Spring Boot RESTful back-end paired with a jQuery-based front-end that lives under src/main/resources/public.
- Its purpose is to manage roommate expenses in dormitory rooms: user sign-up, join/create rooms, record personal and room-level transactions, view statistics, and send notifications.

##### File structure
- Top-level directories:
- src/main/java/.../controller, service, repository, model, dto, config → the layered Spring Boot back-end
- src/main/resources/public → static front-end assets (HTML, CSS, JS, images)
- src/main/resources/application*.properties → environment configurations
- pom.xml, mvnw → Maven build and wrapper
- bin/ and frontend/ appear to be clones or staging but can be ignored for core architecture
- Spring Boot layers follow MVC / layered-architecture:
- Controller layer (REST endpoints)
- Service layer (business logic)
- Repository layer (data access via Spring Data JPA)
- Model/DTO objects
- SecurityConfig indicates there is authentication/authorization (JWT or form-based) protecting certain endpoints.

##### README for additional insights
- Confirms use of Java Spring Boot and MySQL as the database.
- Front-end uses jQuery to call REST endpoints.
- No external services beyond MySQL are mentioned.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static UI and Client Browser
    subgraph "Client (Browser)" 
        direction TB
        Browser["Client Browser"]:::frontend
        StaticUI["Static UI\n(HTML/CSS/JS)"]:::frontend
        APIPage["API Description Page"]:::frontend
        UserImages["User-Image Storage"]:::frontend
    end

    Browser -->|loads| StaticUI
    StaticUI -->|includes| APIPage
    StaticUI -->|serves images| UserImages
    Browser -->|AJAX /api/*| Security

    %% Spring Boot Application
    subgraph "Spring Boot Application"
        direction TB
        EntryPoint["Application Entry Point"]:::backend
        Security["Security Layer"]:::security
        Controllers["Controllers\n(REST API Endpoints)"]:::backend
        Services["Service Layer"]:::backend
        Repositories["Repository Layer"]:::backend
        Models["Domain Models\n(JPA Entities)"]:::backend
        DTOs["Data Transfer Objects (DTOs)"]:::backend
        ConfigFiles["Environment Config Files"]:::config
    end

    Security --> Controllers
    Controllers --> Services
    Services --> Repositories
    Repositories --> Models
    Controllers --> DTOs
    EntryPoint --> Security
    EntryPoint --> Controllers
    ConfigFiles --> EntryPoint

    %% Database
    subgraph "Database"
        direction TB
        MySQL["MySQL Database"]:::database
    end

    Repositories --> MySQL

    %% Click Events
    click StaticUI "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/resources/public"
    click APIPage "https://github.com/phongnickchinh/cnpm-20231/blob/main/src/main/resources/public/api-description.md"
    click UserImages "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/resources/public/resources/user-images"
    click EntryPoint "https://github.com/phongnickchinh/cnpm-20231/blob/main/src/main/java/com/example/cnpm/quanlythuchinhatro/QuanLyThuChiNhaTroApplication.java"
    click Controllers "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/java/com/example/cnpm/quanlythuchinhatro/controller/"
    click Security "https://github.com/phongnickchinh/cnpm-20231/blob/main/src/main/java/com/example/cnpm/quanlythuchinhatro/config/SecurityConfig.java"
    click Services "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/java/com/example/cnpm/quanlythuchinhatro/service/"
    click Repositories "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/java/com/example/cnpm/quanlythuchinhatro/repository/"
    click Models "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/java/com/example/cnpm/quanlythuchinhatro/model/"
    click DTOs "https://github.com/phongnickchinh/cnpm-20231/tree/main/src/main/java/com/example/cnpm/quanlythuchinhatro/dto/"
    click ConfigFiles "https://github.com/phongnickchinh/cnpm-20231/blob/main/src/main/resources/application.properties"
    click ConfigFiles "https://github.com/phongnickchinh/cnpm-20231/blob/main/src/main/resources/application-prod.properties"

    %% Styles
    classDef frontend fill:#fdd,stroke:#d00,color:#600
    classDef backend fill:#ddf,stroke:#00d,color:#006
    classDef security fill:#fbb,stroke:#d33,color:#600
    classDef database fill:#bfb,stroke:#080,color:#060
    classDef config fill:#eee,stroke:#666,color:#333
```
