# int710/managestudentgrade architecture

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

- Interactive diagram: https://gitdiagram.com/int710/managestudentgrade
- Repository: https://github.com/int710/managestudentgrade

## Overview

##### Project type and purpose
- The project is a desktop-based student score management system developed in Java using Swing for its GUI.
- Its core functionality includes user authentication (with role-based access for Admin/Student), management of student grades (adding, updating, deleting, and searching), password changes, and exporting reports to PDF.
- The backend relies on a MySQL database, and external libraries such as itextpdf and mysql-connector are used for PDF generation and database connectivity respectively.

##### File structure
- The project is structured into multiple layers under the "src/studentmanagementpoint" package.
- Key directories include:
- /views: Contains Java Swing forms and corresponding Java classes that define the user interface (Login, HomeAdmin, ChangePassword, Student, etc.).
- /service: Contains service classes (e.g., UserService, TeacherService, ClassService, GradenService, ResultService) which hold business logic and orchestrate operations between views and the database.
- /dto: Contains Data Transfer Objects (like StudentModel, GradeModel, StudyResultModel) that represent the data structures used across the system.
- /config: Contains configuration classes for connecting to MySQL including MySQLConnection.java and testConnectDB.java.
- /utils: Includes utility classes for common tasks such as password handling, date conversion, PDF exporting (ExportToFilePDF), and session management.
- /assets: Houses static resources such as fonts and images used by the UI.
- Additionally, there’s an SQL file (init_sql.sql) to initialize the database schema and provided libraries within the /libs folders.

##### README for additional insights
- The README clearly outlines the project’s features, required technologies, and the intended use cases.
- It briefly explains the user flows (login, change password, manage scores, view student grade details) and emphasizes the use of Java Swing for the frontend and MySQL for database backend.
- The provided README also mentions the inclusion of PDF generation via itextpdf, which is critical for the reporting functionality.

##### Defining the main components
a. Main Components:
- User Interface / Presentation Layer: Represented by the various Swing forms in the "views" directory.
- Business Logic / Service Layer: The "service" directory which encapsulates all business rules and data processing logic.
- Data Model / DTO Layer: Represented by the DTOs that carry data between layers.
- Configuration / Database Layer: Includes database connection classes from "config" and the MySQL database setup itself, shown through the SQL initialization script.
- Utility Components: Such as PDF export functionality and session management.
- External Libraries: itextpdf for PDF rendering and mysql-connector for MySQL connectivity.

b. Relationships and Interactions:
- The GUI layer (views) interacts with the service layer to trigger business operations.
- Services use DTOs to pass data between the UI layer and the database.
- The config components (MySQLConnection) manage the connection to the MySQL database where data is stored.
- Utility classes are used by both the service layer and the views to perform common operations (e.g., formatting dates, handling passwords).
- External libraries are integrated into the application wherever needed (e.g., PDF exporting in the ExportToFilePDF utility).

c. Architectural Patterns and Design Principles:
- Layered Architecture: Separates UI, business logic, data transfer, and configuration.
- Separation of Concerns: Each module (views, service, dto, utils, config) is responsible for a distinct aspect of the application.
- Dependency Management: Clearly outlines dependencies such as libraries and external database services.

##### Final Advice
- Think in terms of layers: Start from the UI layer (views), move to the service (business logic), then to data transfer (DTOs), and finally to database connectivity and external libraries.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% UI Layer
  subgraph "User Interface / Presentation Layer"
    VIEWS["Views/GUI (Swing Forms)"]:::views
  end

  %% Service Layer
  subgraph "Business Logic / Service Layer"
    SERVICES["Business Logic / Service Layer"]:::services
  end

  %% Data Model / DTO Layer
  subgraph "Data Model / DTO Layer"
    DTOS["Data Models (DTOs)"]:::dtos
  end

  %% Configuration / Database Layer
  subgraph "Configuration / Database"
    CONFIG["Database Configuration"]:::config
    MYSQL["MySQL Database"]:::db
    SQLINIT["SQL Database Initialization Script"]:::config
  end

  %% Utility Components
  subgraph "Utility Components"
    UTIL["Utility Components"]:::util
  end

  %% Static Assets
  subgraph "Static Resources"
    ASSETS["Static Resources/Assets"]:::assets
  end

  %% External Libraries
  subgraph "External Libraries"
    LIBS["External Libraries (itextpdf, mysql-connector)"]:::libs
  end
  
  %% Relationships
  VIEWS -->|"triggers"| SERVICES
  SERVICES -->|"passes_data"| DTOS
  SERVICES -->|"persists_data"| MYSQL
  SERVICES -->|"uses"| UTIL
  VIEWS -->|"uses"| UTIL
  
  CONFIG -->|"connects_to"| MYSQL
  MYSQL -->|"initialized_by"| SQLINIT
  
  SERVICES -->|"integrates"| LIBS
  VIEWS -->|"integrates"| LIBS
  UTIL -->|"uses"| LIBS

  %% Click Events
  click VIEWS "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/views"
  click SERVICES "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/service"
  click DTOS "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/dto"
  click CONFIG "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/config"
  click UTIL "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/utils"
  click ASSETS "https://github.com/int710/managestudentgrade/tree/main/src/studentmanagementpoint/assets"
  click SQLINIT "https://github.com/int710/managestudentgrade/blob/main/src/sql/init_sql.sql"
  click LIBS "https://github.com/int710/managestudentgrade/tree/main/src/libs"

  %% Styles
  classDef views fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
  classDef services fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
  classDef dtos fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
  classDef config fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
  classDef db fill:#F5CBA7,stroke:#873600,stroke-width:2px;
  classDef util fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
  classDef assets fill:#FAD7A0,stroke:#B9770E,stroke-width:2px;
  classDef libs fill:#CCD1D1,stroke:#566573,stroke-width:2px;
```
