# marbello1973/evalart architecture

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

- Interactive diagram: https://gitdiagram.com/marbello1973/evalart
- Repository: https://github.com/marbello1973/evalart

## Overview

##### Identifying the Project Type and Purpose
- The project's purpose is to expose a RESTful API to manage three core entities (franquicias, sucursales, productos).
- The README shows instructions for local deployment with Java, Maven, and MySQL, as well as with Docker. Thus, it is a backend full-stack service (with API and database interaction) that is easily containerized and deployed.

##### Analyzing the File Structure
- The top-level files include build and configuration files (pom.xml, Dockerfile, docker-compose.yml, application.yml).
- Controllers: FranquisiaController, ProductoController, SucursalController for handling API endpoints.
- Models and Repositories: Domain entities under model/franquicia, model/producto, model/sucursal with their respective repository (persistence) interfaces.
- Service layer: Contains classes to configure CORS and manage exceptions.
- Test folders contain tests for major controllers.

##### Examining the README for Additional Insight
- The README extensively explains how to deploy the API (both locally and via Docker), how to configure the MySQL datasource, and includes detailed endpoint documentation.

a. Main Components:
- API Gateway/Entry Point: Highlight the main Spring Boot application (EvalartApplication) running on an embedded server (Tomcat by default).
- Service Layer: Include components like CORS configuration and exception handling.
- Persistence Layer: Show the model and repository classes interacting with MySQL.
- Database: Represent MySQL as an external component, with configurations defined in application.yml.
- External Tools: Represent Docker containerization and Postman for API testing, as well as Swagger for API documentation.

b. Relationships and Interactions:
- Data flow from the Spring Boot API to the MySQL database (using JPA/Hibernate).
- A secondary connection from Swagger UI (as part of the system) to the API endpoints.
- Demonstrate interaction with external systems for testing/deployment (e.g., Docker can encapsulate the entire API, and Postman is used for invoking the API endpoints).

c. Architectural Patterns and Design Principles:
- The MVC pattern is evident: the controllers serve as the “C” (handling HTTP requests), and the services/models represent "M" (business logic and data).
- The layered architecture segregates presentation (controllers), business logic (potentially in service classes), and data access (repositories, models).
- REST API design principles are followed with well-defined endpoints.
- Containerization with Docker shows a micro-deployment strategy.

d. Relevant Technologies and Frameworks:
- Java 17+ and Spring Boot framework.
- Maven for building and dependency management.
- MySQL for the database.
- Docker for containerization and docker-compose for service orchestration.
- Swagger for API documentation.
- Testing using JUnit (implied from test directories).

##### Elements
- Spring Boot Application (EvalartApplication)
- Controllers (FranquisiaController, ProductoController, SucursalController)
- Service Layer (CORS Configuration, Exception Handler)
- Persistence Layer (FranquiciaRepository, Productos, SucursalesRepository, etc.)
- MySQL Database (data source configured via application.yml)
- External Tools/Services (Swagger UI, Docker container, Postman)
- Client requests travel to the API controller layer.
- Controllers interact with the datastore via repositories.
- Data/configuration flows from application.yml (or environment variable configuration) into the Spring Boot application.
- Another for business logic and services.
- Another for data access and database.
- Annotations or notes to indicate key technologies (e.g., "Spring Boot", "Maven", "MySQL", "Docker").

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Client("External Clients\n(Swagger UI,Postman)"):::external

    %% Deployment/Containerization
    Docker("Docker Container"):::external
    DockerCompose("Docker Compose Setup"):::external

    %% API Application and Controllers
    SpringBoot("Spring Boot Application\n(EvalartApplication)"):::appLayer
    subgraph "REST Controllers"
        FranquisiaCtrl("FranquisiaController"):::controller
        ProductoCtrl("ProductoController"):::controller
        SucursalCtrl("SucursalController"):::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        CorsConfig("CORS Configuration"):::service
        ExcepHandler("Exception Handler"):::service
    end

    %% Persistence Layer: Models and Repositories
    subgraph "Persistence Layer"
        subgraph "Franquicia"
            FranquisiaModel("Franquicia Model"):::persistence
            FranquisiaRepo("Franquicia Repository"):::persistence
        end
        subgraph "Producto"
            ProductoModel("Producto Model"):::persistence
            ProductoRepo("Producto Repository"):::persistence
        end
        subgraph "Sucursal"
            SucursalModel("Sucursal Model"):::persistence
            SucursalRepo("Sucursal Repository"):::persistence
        end
    end

    %% Database and Application Configuration
    MySQLDB("MySQL Database"):::db
    AppConfig("Application Config"):::db

    %% API Documentation
    Swagger("Swagger UI"):::external

    %% Connections
    Client -->|"invokes"| SpringBoot
    Client -->|"accesses"| Swagger

    Swagger -->|"documents"| SpringBoot

    DockerCompose -->|"orchestrates"| Docker
    Docker -->|"runs"| SpringBoot

    AppConfig -->|"configures"| SpringBoot

    SpringBoot -->|"routes"| FranquisiaCtrl
    SpringBoot -->|"routes"| ProductoCtrl
    SpringBoot -->|"routes"| SucursalCtrl

    FranquisiaCtrl -->|"manages"| FranquisiaRepo
    ProductoCtrl -->|"manages"| ProductoRepo
    SucursalCtrl -->|"manages"| SucursalRepo

    FranquisiaRepo -->|"handles"| FranquisiaModel
    ProductoRepo -->|"handles"| ProductoModel
    SucursalRepo -->|"handles"| SucursalModel

    FranquisiaRepo -->|"reads/writes"| MySQLDB
    ProductoRepo -->|"reads/writes"| MySQLDB
    SucursalRepo -->|"reads/writes"| MySQLDB

    FranquisiaCtrl -->|"utilizes"| CorsConfig
    FranquisiaCtrl -->|"utilizes"| ExcepHandler
    ProductoCtrl -->|"utilizes"| CorsConfig
    ProductoCtrl -->|"utilizes"| ExcepHandler
    SucursalCtrl -->|"utilizes"| CorsConfig
    SucursalCtrl -->|"utilizes"| ExcepHandler

    %% Styles
    classDef appLayer fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef service fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef persistence fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef db fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef external fill:#d1ecf1,stroke:#333,stroke-width:2px;
    
click SpringBoot "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/EvalartApplication.java"
click FranquisiaCtrl "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/controller/FranquisiaController.java"
click ProductoCtrl "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/controller/ProductoController.java"
click SucursalCtrl "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/controller/SucursalController.java"
click CorsConfig "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/servicio/cors/CorsConfiguracion.java"
click ExcepHandler "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/servicio/excepcion/ExcepcionHandler.java"
click FranquisiaModel "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/franquicia/Franquicia.java"
click FranquisiaRepo "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/franquicia/FranquiciaRepository.java"
click ProductoModel "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/producto/Productos.java"
click ProductoRepo "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/producto/ProductoRepository.java"
click SucursalModel "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/sucursal/Sucursales.java"
click SucursalRepo "https://github.com/marbello1973/evalart/blob/main/src/main/java/com/evalart/model/sucursal/SucursalesRepository.java"
click AppConfig "https://github.com/marbello1973/evalart/blob/main/src/main/resources/application.yml"
click Docker "https://github.com/marbello1973/evalart/tree/main/Dockerfile"
click DockerCompose "https://github.com/marbello1973/evalart/blob/main/docker-compose.yml"
```
