# thinh77/student-management architecture

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

## Overview

##### Project Type & Purpose
- This is a full-stack web application focused on managing students, courses, classes, trainers, and related user accounts.
- The backend is implemented using Spring Boot (with controllers, services, repositories, DTOs, and validations), and there is a frontend layer with static assets (HTML, CSS, JavaScript) provided in both the “fe” folder and under “src/main/resources/templates” and “static.”
- Security, exception handling, and custom validations are also integrated, suggesting a robust, modular design following typical multi-layered (MVC) architecture patterns.

##### Breaking Down the File Structure into Main Components

A. Frontend Components:
– “fe/” folder: Contains standalone static pages (e.g., 404.html, new_trainer.html) and associated assets like script.js and CSS files.
– “src/main/resources/static”: Hosts additional CSS, JavaScript, and images for the UI.
– “src/main/resources/templates”: Holds Thymeleaf (or similar templating engine) HTML pages for different roles and parts of the system (admin, auth, class, course, student, trainer).

B. Backend Components:
i. Controllers (Presentation Layer):
- Located under src/main/java/org/example/springbootpractice/controller.
- AdminController, AuthController, ClassController, CourseController, StudentController, and UserController.
ii. Services (Business Logic Layer):
- Interfaces in the “service” package and concrete implementations in “service/impl”.
- Examples include AccountServiceImpl, ClassServiceImpl, CourseServiceImpl, and StudentServiceImpl.
iii. Repositories (Data Access Layer):
- Found under the “repository” package to handle database interactions (e.g., AccountRepository, ClassRepository, CourseRepository, etc.).
iv. Domain/Entities & DTOs:
- Domain models under “entity” and data transfer objects under “dto” that map the business objects.
- Request DTOs are in a subpackage “dto/requestDto”, which represent the incoming data for creating or updating resources.
v. Configuration & Cross-Cutting Concerns:
- “config” folder: Contains various configuration classes such as SecurityConfig, GlobalExceptionHandler, custom authentication handlers, NoCacheFilter, and ModelMapperConfig.
- “validation”: Contains custom validation annotations and corresponding validators for unique emails, past dates, etc.

C. Build & Deployment Artifacts:
– Gradle configuration files (build.gradle, settings.gradle) and Gradle wrapper files.
– GitHub workflow files (.github/workflows/gradle.yml) are used for CI/CD processes.

##### Relationships & Interactions
- The user's browser interacts with the Frontend, which loads static pages (from either “fe” or templates) and makes HTTP requests (as forms submissions or AJAX calls) to the backend.
- HTTP requests are initially received by Controllers. For example:
– Login and registration requests are handled by AuthController.
– Course, student, and class management actions are routed to their respective controllers.
- Controllers invoke the corresponding Service layer (AccountService, StudentService, etc.) to perform business logic.
- The Service layer uses Repository interfaces to access and modify data in the database (while not explicitly visible, there’s an assumed external database per the application.properties file).
- Custom validations, exception handling, and security (via classes in “config” and “validation”) are applied throughout the request-processing pipeline.

##### Important Architectural Patterns & Technologies to Highlight
- MVC Pattern: Clear separation into controllers (presentation), services (business logic), and repositories (persistence).
- Dependency Injection: Managed by Spring Boot (e.g., wiring of controllers, services, repositories).
- Security: Handled via the custom security configuration and authentication handlers.
- Validation & Exception Management: Custom validators and a global exception handler ensure data integrity and consistent error messaging.
- Frontend Separation: Both static assets (in “fe” and “src/main/resources/static”) and dynamic server-rendered views (in “src/main/resources/templates”) are managed accurately.

## Diagram (Mermaid)

```mermaid
graph TB
    browser["User Browser"]:::frontend

    subgraph "Frontend"
        F1["Standalone Static Pages"]:::frontend
        F2["Static Assets"]:::frontend
        F3["Templated Views"]:::frontend
    end

    browser -->|"HTTP_Request"| F3

    subgraph "Backend"
        subgraph "Controllers"
            C["Controllers (Admin,Auth,Class,Course,Student,User)"]:::backend
        end
        subgraph "Service Layer"
            S_int["Service Interfaces"]:::backend
            S_impl["Service Implementations"]:::backend
        end
        subgraph "Repositories"
            R["Repositories"]:::backend
        end
        subgraph "Domain & Data Transfer"
            D["Domain Entities"]:::backend
            DTO["DTOs"]:::backend
        end
        subgraph "Configuration & Cross-Cutting"
            configA["Configuration & Security"]:::config
            exc["Exception Handling"]:::config
            valid["Validation"]:::config
        end
        DB["Database"]:::db
    end

    subgraph "Build & Deployment"
        BD1["build.gradle"]:::deployment
        BD3["settings.gradle"]:::deployment
        BD2["CI/CD Workflow"]:::deployment
    end

    F3 -->|"Submit_Request"| C
    C -->|"Calls"| S_int
    S_int -->|"ImplementedBy"| S_impl
    S_impl -->|"Uses"| R
    R -->|"Queries"| DB
    C -.->|"Data_Transfer"| D
    C -.->|"Data_Transfer"| DTO
    configA -.-> C
    exc -.-> C
    valid -.-> C
    configA -.-> S_impl
    exc -.-> S_impl
    valid -.-> S_impl

    classDef frontend fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef config fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef db fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef deployment fill:#d5f5e3,stroke:#333,stroke-width:2px;

    click F1 "https://github.com/thinh77/student-management/tree/main/fe/"
    click F2 "https://github.com/thinh77/student-management/tree/main/src/main/resources/static"
    click F3 "https://github.com/thinh77/student-management/tree/main/src/main/resources/templates"
    click C "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/controller"
    click S_int "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/service"
    click S_impl "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/service/impl"
    click R "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/repository"
    click D "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/entity"
    click DTO "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/dto"
    click configA "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/config"
    click exc "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/exception"
    click valid "https://github.com/thinh77/student-management/tree/main/src/main/java/org/example/springbootpractice/validation"
    click BD1 "https://github.com/thinh77/student-management/blob/main/build.gradle"
    click BD3 "https://github.com/thinh77/student-management/blob/main/settings.gradle"
    click BD2 "https://github.com/thinh77/student-management/blob/main/.github/workflows/gradle.yml"
```
