# theanh994/kiemdinh architecture

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

- Interactive diagram: https://gitdiagram.com/theanh994/kiemdinh
- Repository: https://github.com/theanh994/kiemdinh

## Overview

##### Project type and purpose
- This is a full-stack Spring Boot web application (“EduMana”) for managing educational data (courses, teachers, departments, semesters, teaching rates/payments, statistics).
- Key features from the README: Spring Boot 3.1.0, Spring Data JPA, in-memory H2 database, Thymeleaf templates for server-side rendering, RESTful API support.

##### Analysis of the file structure
- Top-level artifacts:
- pom.xml (Maven build)
- src/main/java/com/edumana:
– controller/  (MVC controllers, routing HTTP requests)
– service/     (business logic)
– repository/  (Spring Data JPA data-access interfaces)
– model/       (JPA entities)
– dto/         (data transfer objects for reports/statistics)
– EduManaApplication.java (Spring Boot bootstrap)
- src/main/resources:
– application.properties (App configuration, H2 settings)
– db/migration (SQL scripts for Flyway or similar migrations)
– static/css (styles.css)
– templates/  (Thymeleaf HTML views, organized per domain)
- Build/deployment:
- Maven: pom.xml declares Spring Boot, JPA, H2 dependencies.
- Flyway migrations in resources/db/migration.
- The app produces an executable JAR with embedded Tomcat.

##### Examining the README
- Confirms H2 in-memory DB, console on /h2-console.
- Notes RESTful API support (controllers return views and possibly JSON).

a. Main components
1. Client (Web browser)
2. Static asset server (styles.css, JS if any)
3. Spring Boot Embedded Server (Tomcat)
– Controllers (ClassCoefficientController, CourseController, …, StatisticsController)
– Service Layer (ClassCoefficientService, CourseService, etc.)
– Repository Layer (Spring Data JPA repositories)
4. Database
– H2 in-memory
– Flyway migration scripts
5. DTO layer (for aggregating statistics)
b. Relationships and interactions
- Client → HTTP request → Controllers
- Controllers ↔ Services (invoke business logic)
- Services ↔ Repositories (CRUD operations)
- Repositories → JDBC → H2 Database
- Flyway migrations run on startup to initialize tables
- Controllers render Thymeleaf templates (views) mixed with data from DTOs/entities
- Static resources served from /static by Spring’s ResourceHandler
c. Architectural patterns and principles
- Layered (onion) architecture: Presentation (MVC Controllers + View), Business (Services), Data Access (Repositories)
- MVC design: Controllers + Thymeleaf Templates
- Dependency Injection via Spring
- Data Migration (Flyway)
- RESTful API capabilities coexisting with server-side rendering
d. Key technologies/frameworks
- Spring Boot (auto-configuration, embedded Tomcat)
- Spring MVC (controllers + Thymeleaf view resolver)
- Spring Data JPA (repositories)
- H2 Database (in-memory)
- Flyway (db/migration)
- Maven (build)
- Thymeleaf (templates)

##### Essential elements
- Component labels (e.g., “CourseController”, “TeacherService”, “CourseRepository”)

##### Final recommendations
- Do not omit Flyway scripts—show migrations initializing the schema.
- How DTOs feed into the statistics views.
- Use an iterative approach: start with three layers, then expand to show individual subcomponents.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Web Browser"]:::presentation
    end

    %% Static Resources
    subgraph "Static Resources"
        Styles["styles.css"]:::presentation
    end

    Browser -->|GET /static/css/styles.css| Styles

    Browser -->|HTTP GET/POST| Controllers

    %% Controllers
    subgraph "Controller Layer" 
        CCoefCtrl["ClassCoefficientController"]:::presentation
        CourseClassCtrl["CourseClassController"]:::presentation
        CourseCtrl["CourseController"]:::presentation
        DegreeCtrl["DegreeController"]:::presentation
        DeptCtrl["DepartmentController"]:::presentation
        SemCtrl["SemesterController"]:::presentation
        StatsCtrl["StatisticsController"]:::presentation
        TeacherCtrl["TeacherController"]:::presentation
        TeachAssignCtrl["TeachingAssignmentController"]:::presentation
        TeachPayCtrl["TeachingPaymentController"]:::presentation
        TeachRateCtrl["TeachingRateController"]:::presentation
    end

    Controllers -->|routes to| CCoefCtrl
    Controllers -->|routes to| CourseClassCtrl
    Controllers -->|routes to| CourseCtrl
    Controllers -->|routes to| DegreeCtrl
    Controllers -->|routes to| DeptCtrl
    Controllers -->|routes to| SemCtrl
    Controllers -->|routes to| StatsCtrl
    Controllers -->|routes to| TeacherCtrl
    Controllers -->|routes to| TeachAssignCtrl
    Controllers -->|routes to| TeachPayCtrl
    Controllers -->|routes to| TeachRateCtrl

    %% Services
    subgraph "Business Logic - Service Layer"
        CCoefSvc["ClassCoefficientService"]:::business
        CourseClassSvc["CourseClassService"]:::business
        CourseSvc["CourseService"]:::business
        DegreeSvc["DegreeService"]:::business
        DeptSvc["DepartmentService"]:::business
        SemSvc["SemesterService"]:::business
        TeacherSvc["TeacherService"]:::business
        TeachPaySvc["TeachingPaymentService"]:::business
        TeachRateSvc["TeachingRateService"]:::business
    end

    CCoefCtrl -->|invokes| CCoefSvc
    CourseClassCtrl -->|invokes| CourseClassSvc
    CourseCtrl -->|invokes| CourseSvc
    DegreeCtrl -->|invokes| DegreeSvc
    DeptCtrl -->|invokes| DeptSvc
    SemCtrl -->|invokes| SemSvc
    TeacherCtrl -->|invokes| TeacherSvc
    TeachPayCtrl -->|invokes| TeachPaySvc
    TeachRateCtrl -->|invokes| TeachRateSvc
    StatsCtrl -->|invokes| TeachPaySvc

    %% Repositories
    subgraph "Data Access - Repository Layer"
        CCoefRepo["ClassCoefficientRepository"]:::dataaccess
        CourseClassRepo["CourseClassRepository"]:::dataaccess
        CourseRepo["CourseRepository"]:::dataaccess
        DegreeRepo["DegreeRepository"]:::dataaccess
        DeptRepo["DepartmentRepository"]:::dataaccess
        SemRepo["SemesterRepository"]:::dataaccess
        TeacherRepo["TeacherRepository"]:::dataaccess
        TeachRateRepo["TeachingRateRepository"]:::dataaccess
    end

    CCoefSvc -->|uses| CCoefRepo
    CourseClassSvc -->|uses| CourseClassRepo
    CourseSvc -->|uses| CourseRepo
    DegreeSvc -->|uses| DegreeRepo
    DeptSvc -->|uses| DeptRepo
    SemSvc -->|uses| SemRepo
    TeacherSvc -->|uses| TeacherRepo
    TeachRateSvc -->|uses| TeachRateRepo
    TeachPaySvc -->|uses| TeachRateRepo

    %% Database and Migrations
    subgraph "Database & Migrations"
        Migrations["Flyway Migrations"]:::db
        H2DB["H2 In-Memory Database"]:::db
    end

    Migrations -->|initialize schema| H2DB
    CCoefRepo -->|JDBC| H2DB
    CourseClassRepo -->|JDBC| H2DB
    CourseRepo -->|JDBC| H2DB
    DegreeRepo -->|JDBC| H2DB
    DeptRepo -->|JDBC| H2DB
    SemRepo -->|JDBC| H2DB
    TeacherRepo -->|JDBC| H2DB
    TeachRateRepo -->|JDBC| H2DB

    %% Configuration & Boot
    subgraph "Application Configuration & Boot"
        Pom["pom.xml"]:::config
        App["EduManaApplication"]:::config
        Props["application.properties"]:::config
    end

    Pom --> App
    Props --> App
    App --> Controllers
    App --> Migrations
    App --> Styles

    %% Click Events
    click App "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/EduManaApplication.java"
    click Pom "https://github.com/theanh994/kiemdinh/blob/master/pom.xml"
    click Props "https://github.com/theanh994/kiemdinh/blob/master/src/main/resources/application.properties"
    click Migrations "https://github.com/theanh994/kiemdinh/tree/master/src/main/resources/db/migration/"
    click Styles "https://github.com/theanh994/kiemdinh/blob/master/src/main/resources/static/css/styles.css"
    click CCoefCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/ClassCoefficientController.java"
    click CourseClassCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/CourseClassController.java"
    click CourseCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/CourseController.java"
    click DegreeCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/DegreeController.java"
    click DeptCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/DepartmentController.java"
    click SemCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/SemesterController.java"
    click StatsCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/StatisticsController.java"
    click TeacherCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/TeacherController.java"
    click TeachAssignCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/TeachingAssignmentController.java"
    click TeachPayCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/TeachingPaymentController.java"
    click TeachRateCtrl "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/controller/TeachingRateController.java"
    click CCoefSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/ClassCoefficientService.java"
    click CourseClassSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/CourseClassService.java"
    click CourseSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/CourseService.java"
    click DegreeSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/DegreeService.java"
    click DeptSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/DepartmentService.java"
    click SemSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/SemesterService.java"
    click TeacherSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/TeacherService.java"
    click TeachPaySvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/TeachingPaymentService.java"
    click TeachRateSvc "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/service/TeachingRateService.java"
    click CCoefRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/ClassCoefficientRepository.java"
    click CourseClassRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/CourseClassRepository.java"
    click CourseRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/CourseRepository.java"
    click DegreeRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/DegreeRepository.java"
    click DeptRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/DepartmentRepository.java"
    click SemRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/SemesterRepository.java"
    click TeacherRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/TeacherRepository.java"
    click TeachRateRepo "https://github.com/theanh994/kiemdinh/blob/master/src/main/java/com/edumana/repository/TeachingRateRepository.java"

    %% Styles
    classDef presentation fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
    classDef business fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20;
    classDef dataaccess fill:#FFE0B2,stroke:#E65100,color:#E65100;
    classDef db fill:#ECEFF1,stroke:#455A64,color:#455A64;
    classDef config fill:#E1BEE7,stroke:#4A148C,color:#4A148C;
```
