# juliuscavalcante/gerenciamento-alunos-crud-springboot architecture

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

- Interactive diagram: https://gitdiagram.com/juliuscavalcante/gerenciamento-alunos-crud-springboot
- Repository: https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot

## Overview

##### Main Components
- Frontend/UI:
- Consists of static resources (HTML, CSS, JS) in the src/main/resources/static and Thymeleaf templates in src/main/resources/templates.
- Includes pages for login, registration, student management (both active and inactive lists, editing, filters, etc.).
- Backend – Application Core:
- Main Application: GerenciamentoAlunosApplication.java (entry point).
- Controllers: AlunoController and UsuarioController handle HTTP requests, map endpoints, and interact with the service layer.
- Service Layer: ServiceUsuario and possibly other service components that encapsulate business logic.
- Repository Layer: AlunoRepository and UsuarioRepository which extend JPA repositories to interact with the data persistence layer.
- Models/Entities: Aluno and Usuario classes representing the domain data.
- Exceptions: Custom exceptions like CriptoExistsException, EmailExistsException, and ServiceExc, which define error management.
- Utility Classes: Util.java to support common functionalities.
- Enums: Define fixed categorizations for Curso, Status, Turno for domain consistency.
- Database:
- MySQL Database accessed through the Spring Boot data source configuration in application.properties.

##### Relationships and Flow
- Controllers receive HTTP requests, call the respective services, which in turn interact with the repositories to perform CRUD operations on the MySQL database.
- Secure aspects like the encryption in user data and business rule validations done via JavaScript.

##### Architectural Patterns and Key Technologies
- MVC Pattern: Separate layers for presentation (Thymeleaf templates/static resources), business logic (service layer), and data management (repository/DAO).
- RESTful Design (implied by CRUD operations) with clear separation between UI and backend.
- Use of Spring Boot for dependency injection, configuration, and rapid development.
- Integration of JPA/Hibernate for ORM and persistence.
- Maven build system for dependency management and project build automation.

##### Details for the Principal Software Engineer
- Clearly detail the separation of concerns: the front-end (MVC view layer) is entirely separated from back-end logic; this is critical for understanding the system.
- Dependency injection and ORM aspects provided by Spring Boot & JPA.
- Error-handling branches, demonstrating that exceptions have their own designated part in the architecture when business rules (like duplicate email or encryption issues) are violated.
- Provide enough granularity (e.g., separate blocks for Controller, Service, Repository, etc.) so that you not only show functional dependencies but also technical avenues.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Client Side (Frontend)"
        Browser("Browser"):::frontend
        StaticAssets("Static Assets"):::frontend
        Templates("Thymeleaf Templates"):::frontend
    end
    Browser -->|"view renders"| StaticAssets
    Browser -->|"view renders"| Templates

    %% Backend Layer
    subgraph "Backend Layer"
        %% Main Application
        MainApp("GerenciamentoAlunosApplication"):::main

        %% Controllers
        subgraph "Controllers"
            AlunoController("AlunoController"):::controller
            UsuarioController("UsuarioController"):::controller
        end
        MainApp -->|"initiates"| AlunoController
        MainApp -->|"initiates"| UsuarioController

        %% Services
        subgraph "Services"
            ServiceUsuario("ServiceUsuario"):::service
        end
        AlunoController -->|"calls"| ServiceUsuario
        UsuarioController -->|"calls"| ServiceUsuario

        %% Repositories
        subgraph "Repositories"
            AlunoRepo("AlunoRepository"):::repository
            UsuarioRepo("UsuarioRepository"):::repository
        end
        ServiceUsuario -->|"invokes"| AlunoRepo
        ServiceUsuario -->|"invokes"| UsuarioRepo

        %% Domain Entities
        subgraph "Domain Entities"
            Aluno("Aluno"):::model
            Usuario("Usuario"):::model
        end
        AlunoRepo -->|"manages"| Aluno
        UsuarioRepo -->|"manages"| Usuario

        %% Support Components
        subgraph "Support Components"
            %% Exception Handling
            Cripto("CriptoExistsException"):::exception
            Email("EmailExistsException"):::exception
            ServExc("ServiceExc"):::exception

            Util("Util"):::utility

            Curso("Curso"):::enums
            Status("Status"):::enums
            Turno("Turno"):::enums

            Config("application.properties"):::utility
        end
        ServiceUsuario -->|"handles-errors"| Cripto
        ServiceUsuario -->|"handles-errors"| Email
        ServiceUsuario -->|"handles-errors"| ServExc

        ServiceUsuario -->|"uses"| Util
        ServiceUsuario -->|"uses"| Curso
        ServiceUsuario -->|"uses"| Status
        ServiceUsuario -->|"uses"| Turno

        %% Database Layer
        subgraph "Database Layer"
            MySQLDB("MySQL Database"):::database
        end
        AlunoRepo -->|"persists"| MySQLDB
        UsuarioRepo -->|"persists"| MySQLDB
        Config -->|"DB-config"| MySQLDB
    end

    %% Request Flow from Client to Backend
    Browser -->|"HTTP Request"| MainApp

    %% Styling Classes
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef main fill:#d6d8d9,stroke:#1b1e21,stroke-width:2px;
    classDef controller fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef service fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef repository fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef model fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef exception fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
    classDef utility fill:#ffeeba,stroke:#856404,stroke-width:2px;
    classDef enums fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef database fill:#c3e6cb,stroke:#155724,stroke-width:2px;

    %% Click Events
    click StaticAssets "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/tree/master/src/main/resources/static"
    click Templates "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/tree/master/src/main/resources/templates"
    click MainApp "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/GerenciamentoAlunosApplication.java"
    click AlunoController "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/controller/AlunoController.java"
    click UsuarioController "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/controller/UsuarioController.java"
    click ServiceUsuario "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/service/ServiceUsuario.java"
    click AlunoRepo "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/repository/AlunoRepository.java"
    click UsuarioRepo "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/repository/UsuarioRepository.java"
    click Aluno "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/model/Aluno.java"
    click Usuario "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/model/Usuario.java"
    click Cripto "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/exception/CriptoExistsException.java"
    click Email "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/exception/EmailExistsException.java"
    click ServExc "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/exception/ServiceExc.java"
    click Util "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/util/Util.java"
    click Curso "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/enums/Curso.java"
    click Status "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/enums/Status.java"
    click Turno "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/java/br/com/gerenciamento/enums/Turno.java"
    click Config "https://github.com/juliuscavalcante/gerenciamento-alunos-crud-springboot/blob/master/src/main/resources/application.properties"
```
