# danilomeneghel/java-spring-boot architecture

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

- Interactive diagram: https://gitdiagram.com/danilomeneghel/java-spring-boot
- Repository: https://github.com/danilomeneghel/java-spring-boot

## Overview

##### Project type and purpose
- Monolithic, full-stack Java web application built with Spring Boot (embedded Tomcat).
- Purpose: CRUD-based course registration system with ACL, validation, login, responsive UI.

##### File structure
- src/main/java/course: core Java packages
- controller – Spring MVC controllers handling HTTP requests
- service – business logic implementations
- repository – Spring Data JPA interfaces for persistence
- entity – JPA-annotated domain models (Course, Student, User)
- WebSecurityConfig – Spring Security setup
- CrudbootApplication – Spring Boot entry point
- src/main/resources:
- application.properties – DB connection, server settings
- static – CSS, fonts, JS (front-end assets served as static content)
- templates – Thymeleaf HTML templates for each view
- pom.xml: Maven build and dependency management
- spring_course.sql: initial MySQL schema and data
- Tests: one integration test for application context

##### README
- Stack: Java, JPA/Hibernate, Spring MVC/Spring Data/Spring Security, MySQL, Bootstrap, Thymeleaf
- Run instructions: embedded Tomcat, local MySQL database
- Features: CRUD, ACL, login, validation, responsive front end

##### Main components and their interactions
a. Frontend (Browser/UI)
– HTML templates (Thymeleaf) + CSS/Bootstrap served from /static & /templates
b. Spring Boot application
– Embedded Tomcat + DispatcherServlet
– Controllers (REST-style or server-rendered endpoints)
– Service layer (business rules, ACL checks, validation)
– Repository layer (Spring Data JPA)
– JPA/Hibernate managing Entity ↔ DB mapping
c. Database
– MySQL instance (“spring_course” schema)
d. External/deployment
– Maven plugin (mvn spring-boot:run)
– GitHub repo, optional Heroku deployment

Data‐flow example:
1. User submits HTTP request in browser →
2. DispatcherServlet routes to a Controller →
3. Controller calls Service methods →
4. Service invokes Repository (CRUD operations) →
5. JPA/Hibernate issues SQL to MySQL →
6. Data returns up through layers →
7. Controller returns Model + View (Thymeleaf template) →
8. Browser renders HTML/CSS/JS

##### Architectural patterns and design principles
- Layered architecture (Presentation → Service → Data)
- MVC (Model = Entities, View = Thymeleaf templates, Controller = Spring MVC)
- Dependency Injection (Spring Framework)
- Repository pattern (Spring Data JPA)
- Security layer (WebSecurityConfig using Spring Security)

##### Essential elements to capture
- Embedded Tomcat / DispatcherServlet entry point
- WebSecurityConfig filter chain
- Controllers → Services → Repositories flow
- JPA/Hibernate managing Entity ↔ MySQL persistence
- Static resources and template rendering
- External dependencies: MySQL database, Maven build lifecycle

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Browser UI"]:::ui
        Static["Static Resources\n(CSS/JS/Fonts)"]:::ui
        Templates["Thymeleaf Templates"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Tomcat["Embedded Tomcat /\nDispatcherServlet"]:::app
        Security["WebSecurityConfig"]:::app

        subgraph "Controllers"
            direction TB
            CourseController["CourseController"]:::app
            StudentController["StudentController"]:::app
            UserController["UserController"]:::app
            SignupController["SignupController"]:::app
            IndexController["IndexController"]:::app
        end

        subgraph "Services"
            direction TB
            CourseService["CourseServiceImpl"]:::app
            StudentService["StudentServiceImpl"]:::app
            UserService["UserServiceImpl"]:::app
        end

        subgraph "Repositories"
            direction TB
            CourseRepo["CourseRepository"]:::app
            StudentRepo["StudentRepository"]:::app
            UserRepo["UserRepository"]:::app
        end

        subgraph "Entities"
            direction TB
            CourseEntity["Course Entity"]:::app
            StudentEntity["Student Entity"]:::app
            UserEntity["User Entity"]:::app
        end
    end

    %% Persistence Layer
    DB["MySQL Database\n(spring_course schema)"]:::data

    %% Configuration & Build
    subgraph "Configuration & Build"
        direction TB
        Pom["pom.xml"]:::config
        Config["application.properties"]:::config
        SQL["spring_course.sql"]:::config
    end

    %% Data Flows
    Browser -->|"HTTP Request"| Tomcat
    Tomcat -->|filters| Security
    Security -->|routes to| CourseController
    Security --> StudentController
    Security --> UserController
    Security --> SignupController
    Security --> IndexController

    CourseController -->|calls| CourseService
    StudentController --> StudentService
    UserController --> UserService
    SignupController --> UserService
    IndexController -->|view| Templates

    CourseService -->|CRUD ops| CourseRepo
    StudentService --> StudentRepo
    UserService --> UserRepo

    CourseRepo -->|JPA/Hibernate| CourseEntity
    StudentRepo --> StudentEntity
    UserRepo --> UserEntity

    CourseEntity -->|SQL| DB
    StudentEntity --> DB
    UserEntity --> DB

    DB -->|results| CourseEntity
    DB --> StudentEntity
    DB --> UserEntity

    CourseController -->|renders| Templates
    Static -->|served to| Browser
    Templates --> Browser

    Pom -->|build/run| Tomcat
    Config --> Tomcat
    SQL --> DB

    %% Click Events
    click Tomcat "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/CrudbootApplication.java"
    click Security "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/WebSecurityConfig.java"
    click CourseController "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/controller/CourseController.java"
    click StudentController "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/controller/StudentController.java"
    click UserController "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/controller/UserController.java"
    click SignupController "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/controller/SignupController.java"
    click IndexController "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/controller/IndexController.java"
    click CourseService "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/service/CourseServiceImpl.java"
    click StudentService "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/service/StudentServiceImpl.java"
    click UserService "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/service/UserServiceImpl.java"
    click CourseRepo "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/repository/CourseRepository.java"
    click StudentRepo "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/repository/StudentRepository.java"
    click UserRepo "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/repository/UserRepository.java"
    click CourseEntity "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/entity/Course.java"
    click StudentEntity "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/entity/Student.java"
    click UserEntity "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/java/course/entity/User.java"
    click Config "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/resources/application.properties"
    click SQL "https://github.com/danilomeneghel/java-spring-boot/blob/master/spring_course.sql"
    click Pom "https://github.com/danilomeneghel/java-spring-boot/blob/master/pom.xml"
    click Static "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/resources/static/css/style.css"
    click Templates "https://github.com/danilomeneghel/java-spring-boot/blob/master/src/main/resources/templates/courses.html"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef app fill:#d4edda,stroke:#155724,color:#155724;
    classDef data fill:#fff3cd,stroke:#856404,color:#856404;
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
