# nkduyennn/student-management-system architecture

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

## Overview

##### Main Components
- Frontend/UI: Represented by the HTML templates (found under src/main/resources/templates) and static resources (CSS files under src/main/resources/static). These pages handle registration, login, and personalized views for students, teachers, and administrators.
- Controller Layer: The controllers under the directory “controller” (e.g., AdminController, LoginController, RegistrationController, StudentController, and TeacherController) use Spring MVC to handle HTTP requests, routing users to the correct views.
- Service Layer: Service interfaces and implementations (e.g., AssignmentService, CourseService, StudentService, TeacherService) encapsulate the business logic.
- Data Access Object (DAO) Layer: DAO interfaces and implementations (e.g., CourseDao, AssignmentDao, etc.) abstract the operations to the underlying persistence store.
- Domain/Entity Models: Represented in the “entity” package; these classes map to tables in the MySQL database.
- Security & Configuration: Components under “config” (like DemoSecurityConfig and CustomAuthenticationSuccessHandler) manage authentication and authorization for the three user roles.
- Database: The system uses MySQL with Hibernate for ORM to persist and query data.

##### Relationships and Interactions
- Users (students, teachers, and admins) interact with the Frontend (views created with HTML/CSS).
- The web browser sends HTTP/HTTPS requests that are handled by the corresponding Controller based on URL routing.
- Controllers invoke the Service Layer which contains the business logic (e.g., handling enrollment, assignment updates, or statistic retrieval).
- The Service Layer interacts with the DAO Layer for CRUD operations on domain entities.
- The DAO Layer communicates with the underlying MySQL database using Hibernate, ensuring persistence.
- Security configuration components intercept requests to enforce role-based access control.
- Maven is used to maintain dependencies and build the project, while the Dockerfile (present at the root) indicates that containerization might also be part of the deployment strategy.

##### Architectural Patterns and Design Principles
- Layered Architecture: The clear separation into controllers, services, DAOs, and entity models aligns with the best practices in software engineering.
- MVC Pattern: The project uses Spring MVC to separate the presentation layer from the business logic.
- Role-Based Access Control (RBAC): Security configurations ensure that each type of user has access only to the relevant parts of the system.
- Configuration/Convention Over Configuration: Spring Boot’s auto-configuration and sensible defaults are utilized to simplify setup.

##### Additional Details
- Since there are multiple packages for controllers, services, and repositories, consider summarizing them into “Controller”, “Service”, and “DAO” components to avoid clutter.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser (admin,teacher,student)"]:::client

    subgraph "Frontend/UI Layer"
        T["HTML Templates"]:::frontend
        S["Static Resources"]:::frontend
    end

    C["Controller Layer"]:::controller
    D["Service Layer"]:::service
    E["DAO Layer"]:::dao
    F["Domain/Entity Models"]:::entity
    G(("MySQL Database")):::db
    H["Security & Configuration"]:::security

    subgraph "Build & Deployment"
        I1["Maven"]:::build
        I2["Docker"]:::build
    end

    %% User interactions with Frontend
    Browser -->|"HTTP_Request"| T
    Browser -->|"HTTP_Request"| S

    %% Frontend to Controller
    T -->|"Routes_to"| C
    S -->|"Routes_to"| C

    %% Security intercepts
    Browser -->|"Authenticate"| H
    H -->|"Secures"| C

    %% Request flow through backend layers
    C -->|"Calls"| D
    D -->|"Invokes"| E
    E -->|"Uses"| F
    F -->|"Persisted_in"| G

    %% Build & Deployment updates the system
    I1 -->|"Builds"| C
    I2 -->|"Containers"| C

    %% Class styles
    classDef client fill:#f9c74f,stroke:#000,stroke-width:1px;
    classDef frontend fill:#90be6d,stroke:#000,stroke-width:1px;
    classDef controller fill:#f94144,stroke:#000,stroke-width:1px;
    classDef service fill:#577590,stroke:#000,stroke-width:1px;
    classDef dao fill:#f8961e,stroke:#000,stroke-width:1px;
    classDef entity fill:#f3722c,stroke:#000,stroke-width:1px;
    classDef security fill:#277da1,stroke:#000,stroke-width:1px;
    classDef build fill:#6a4c93,stroke:#000,stroke-width:1px;
    classDef db fill:#90caf9,stroke:#000,stroke-width:1px;

    %% Click Events
    click T "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/resources/templates"
    click S "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/resources/static"
    click C "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/java/com/burak/studentmanagement/controller"
    click D "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/java/com/burak/studentmanagement/service"
    click E "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/java/com/burak/studentmanagement/dao"
    click F "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/java/com/burak/studentmanagement/entity"
    click H "https://github.com/nkduyennn/student-management-system/tree/nkduyen/src/main/java/com/burak/studentmanagement/config"
    click I1 "https://github.com/nkduyennn/student-management-system/blob/nkduyen/pom.xml"
    click I2 "https://github.com/nkduyennn/student-management-system/tree/nkduyen/Dockerfile"
```
