# albertoortizortega/practica-ems architecture

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

- Interactive diagram: https://gitdiagram.com/albertoortizortega/practica-ems
- Repository: https://github.com/albertoortizortega/practica-ems

## Overview

##### Main Components
- Spring Boot Application: Represented by the Application.java class, it is the entry-point containing the main() method. This component bootstraps the application and uses an embedded Tomcat servlet container.
- Web Controller: The GreetingController.java class is annotated with @Controller. It handles HTTP GET requests (mapped to /greeting) and processes the “name” parameter to render a response.
- View Templates: Thymeleaf-based HTML templates (greeting.html under “src/main/resources/templates”) are used to render dynamic HTML content.
- Static Resources: Files under “src/main/resources/static” (including index.html and CSS files) serve as static content, with the index.html acting as the home page.
- Build/Configuration: The pom.xml defines project dependencies and build configuration (using Maven), while resource directories are organized to support Spring Boot’s auto-configuration.

##### Relationships and Interactions
- The Application component initializes the Spring Boot runtime; upon startup, it registers the DispatcherServlet.
- The DispatcherServlet routes incoming HTTP requests to the appropriate controller (GreetingController in this case) based on URL mapping.
- Within GreetingController, the incoming request’s “name” parameter is bound via @RequestParam and the model is populated.
- The controller returns the name of the view (“greeting”), which is handled by Thymeleaf to merge the model data into greeting.html.
- For the root URL ("/"), the static index.html is automatically served from the /static directory.
- Data flow flows from the HTTP request → DispatcherServlet → Controller → Model → View Renderer → HTTP response.

##### Architectural Patterns and Design Principles
- MVC Pattern: The separation of concerns is evident with controllers handling user input, models carrying data, and views handling presentation.
- Embedded Server Concept: Utilization of an embedded Tomcat server is a key aspect of Spring Boot’s design.
- Convention over Configuration: Spring Boot auto-configures components (e.g., static resource handling, view resolution) based on directory structures and annotations.

##### Technologies, Frameworks, and Libraries
- Spring Boot and Spring MVC for application structure and web handling.
- Thymeleaf as the server-side templating engine.
- Maven for project build and dependency management.
- Annotations like @Controller, @GetMapping, and @RequestParam are central to the design.

- Use clear labels for each component:
- “Spring Boot Application (Application.java)”
- “DispatcherServlet” (as a middleware component handling routing)
- “GreetingController” (handling /greeting requests)
- “Thymeleaf Template Engine / greeting.html”
- “Static Resources (index.html, CSS)”
- Optionally, note “Maven Build (pom.xml)” as the build and dependency management component.
- From “HTTP Request” to “Embedded Tomcat / DispatcherServlet”.
- From “DispatcherServlet” to “GreetingController”.
- From “GreetingController” to “Thymeleaf Template (greeting.html)” or to the “Static Resource” if it's the welcome page.
- Finally, indicate the HTTP response going back to the client.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    HTTPReq["HTTP Request"]:::client
    HTTPRes["HTTP Response"]:::client

    %% Application Layer
    App["Spring Boot Application (Application.java)"]:::app
    Maven["Maven Build (pom.xml)"]:::build

    %% Web Layer
    Dispatcher["Embedded Tomcat / DispatcherServlet"]:::servlet
    Controller["GreetingController"]:::controller
    Thymeleaf["Thymeleaf Template Engine (greeting.html)"]:::view

    %% Static Content
    StaticIndex["Static Resource (index.html)"]:::static
    CSS["Static Resource (CSS: style.css)"]:::static

    %% Relationships and Data Flow
    HTTPReq -->|"routes"| Dispatcher
    Dispatcher -->|"if_/greeting"| Controller
    Controller -->|"returns_'greeting'_view"| Thymeleaf
    Thymeleaf --> HTTPRes

    %% Static content path for root URL "/"
    HTTPReq -->|"if_/"| StaticIndex
    StaticIndex --> HTTPRes

    %% Application initialization relationships
    App -->|"bootstraps"| Dispatcher
    Maven -->|"build_configures"| App

    %% Click Events
    click App "https://github.com/albertoortizortega/practica-ems/blob/main/src/main/java/hello/Application.java"
    click Controller "https://github.com/albertoortizortega/practica-ems/blob/main/src/main/java/hello/GreetingController.java"
    click Thymeleaf "https://github.com/albertoortizortega/practica-ems/blob/main/src/main/resources/templates/greeting.html"
    click StaticIndex "https://github.com/albertoortizortega/practica-ems/blob/main/src/main/resources/static/index.html"
    click CSS "https://github.com/albertoortizortega/practica-ems/blob/main/src/main/resources/static/css/style.css"
    click Maven "https://github.com/albertoortizortega/practica-ems/blob/main/pom.xml"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef app fill:#bbf,stroke:#333,stroke-width:2px;
    classDef build fill:#ddd,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
    classDef servlet fill:#dff,stroke:#333,stroke-width:2px;
    classDef controller fill:#dfd,stroke:#333,stroke-width:2px;
    classDef view fill:#ffd,stroke:#333,stroke-width:2px;
    classDef static fill:#fdd,stroke:#333,stroke-width:2px;
```
