# eitan-wajsberg/tp-anual-dds-2024 architecture

> Architecture diagram of the GitHub repository eitan-wajsberg/tp-anual-dds-2024, 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/eitan-wajsberg/tp-anual-dds-2024
- Repository: https://github.com/eitan-wajsberg/tp-anual-dds-2024

## Overview

##### Main Components
- User Interface (Frontend):
- Represented by the Handlebars templates (located in src/main/resources/templates), CSS, JavaScript files, and public resources.
- This layer handles web pages for account creation, login, donation management, heladera maps, and report views.
- API / Controller Layer:
- The controllers found under src/main/java/ar/edu/utn/frba/dds/controllers handle routing and business requests (e.g., ControladorHeladera, ControladorOferta, ControladorRegistroUsuario, etc.).
- They act as the entry points for the HTTP requests coming from the UI.
- Domain Layer:
- The domain is extensively modeled (look under src/main/java/ar/edu/utn/frba/dds/domain). It contains the business logic, entities (such as Heladera, PersonaHumana, PersonaJuridica, DonacionDinero, SolicitudApertura, etc.), domain events (incidentes, solicitudes, suscripciones), and adapters for external interactions.
- This layer includes DTOs and converters to translate between different representations.
- Persistence / Repository Layer:
- Under src/main/java/ar/edu/utn/frba/dds/domain/repositories and its implementation packages, the system defines repositories and persistence mechanisms (backed by Hibernate, with configuration resources in src/test/resources and the SQL scripts in the sql folder).
- External Communication / Adapters:
- In the adapters directory, you see implementations for sending notifications (e.g., via mail, Telegram, WhatsApp and JavaXMail). These serve as integration points for external services.
- Infrastructure and Utilities:
- Middleware for authentication (AuthMiddleware), permission checking, and other utility classes grouped under src/main/java/ar/edu/utn/frba/dds/utils. This layer supports the application’s overall stability and security.
- Testing:
- The project also contains a comprehensive test suite (JUnit tests under src/test) ensuring that each component behaves as expected.
- Deployment:

##### Relationships and Interactions Between Components
- How a client HTTP request flows from the User Interface (Browser) to the Javalin-based Server.
- The Router (defined in src/main/java/ar/edu/utn/frba/dds/server/Router.java) directs incoming calls to the appropriate Controller.
- Controllers then interact with the Domain layer – invoking business logic on entity objects, handling DTO mappings, and executing validation routines.
- Domain objects interact with Repository implementations to perform database operations (SQL scripts and Hibernate ORM).
- When needed, the domain layer invokes external adapters (for emailing, messaging, or even external REST services) to complete tasks such as notifications.
- The middleware (authentication and permissions) is applied in the request pipeline to validate user actions.

##### Architectural Patterns and Design Principles
- The project follows a layered (or hexagonal) architecture:
- Presentation Layer (UI & Templates)
- Application / Controller Layer (HTTP request routing, using Javalin)
- Domain Layer (business logic with clearly defined entities and services)
- Infrastructure Layer (persistence with Hibernate, external integrations with adapters)
- MVC is evident in the separation between UI (views), controllers, and domain models.
- The use of DTOs, converters, and adapters emphasizes clean separation and loose coupling between layers.

##### Technologies, Frameworks, and Libraries
- Java 17, Maven, Javalin, Handlebars, Hibernate, and JUnit 5.
- AWS is mentioned for deployment purposes.
- Additionally, some utility packages for handling dates, distances, and permissions further support the application’s infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    UBrowser("User Browser"):::frontend

    %% Frontend Layer
    subgraph "Frontend Layer"
        UI_Templates("UI Templates"):::frontend
        UI_Public("Public Assets"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        %% Server & Routing
        subgraph "Server & Routing"
            Server("Server (Routing & Helpers)"):::backend
            Router("Router"):::backend
        end

        %% Middleware
        Middleware("AuthMiddleware"):::infra

        %% Controller Layer
        subgraph "Controller Layer"
            Controllers("Controllers"):::backend
        end

        %% Domain Layer
        subgraph "Domain Layer"
            DomainLogic("Business Logic & Entities"):::domain
            DomainMain("Domain Main"):::domain
        end

        %% Persistence / Repository Layer
        subgraph "Persistence Layer"
            RepoInterface("Repository Interfaces"):::persistence
            RepoImpl("Repository Implementations"):::persistence
            SQLScripts("SQL Scripts"):::persistence
        end

        %% External Communication / Adapters
        subgraph "External Adapters"
            Adapters("Adapters"):::adapter
        end

        %% Infrastructure & Utilities
        subgraph "Infrastructure & Utilities"
            Utilities("Utilities"):::infra
        end
    end

    %% Testing Layer
    subgraph "Testing"
        Tests("Test Suite"):::test
    end

    %% Deployment & Configuration
    subgraph "Deployment & Configuration"
        Maven("Build & Dependencies (pom.xml)"):::deployment
        DeployConfig("Deployment Configs & Workflows"):::deployment
        Properties("Properties & Configs"):::deployment
    end

    %% Connections
    UBrowser -->|"HTTP Request/Response"| UI_Templates
    UBrowser -->|"HTTP Request/Response"| UI_Public
    UI_Templates -->|"Serves" | Server
    UI_Public -->|"Serves" | Server
    Server -->|"Routes to"| Router
    Router -->|"Applies"| Middleware
    Middleware -->|"Validates request"| Controllers
    Controllers -->|"Invokes business logic"| DomainLogic
    DomainLogic -->|"Executes Processes"| DomainMain
    DomainLogic -->|"Queries/Updates"| RepoInterface
    RepoInterface -->|"Implemented By"| RepoImpl
    RepoImpl -->|"Executes SQL"| SQLScripts
    DomainLogic -->|"Triggers notifications"| Adapters
    Utilities ---|"Supports"| Controllers
    Utilities ---|"Supports"| DomainLogic
    Maven ---|"Manages build"| Server
    DeployConfig ---|"Deploys"| Server
    Properties ---|"Configures"| Server
    Tests ---|"Validates All Layers"| DomainLogic

    %% Click Events
    click UI_Templates "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/resources/templates"
    click UI_Public "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/resources/public"
    click Controllers "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/controllers"
    click DomainLogic "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/domain"
    click DomainMain "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/domain/main"
    click RepoInterface "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/domain/repositories"
    click RepoImpl "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/domain/repositories/imp"
    click SQLScripts "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/sql"
    click Adapters "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/domain/adapters"
    click Middleware "https://github.com/eitan-wajsberg/tp-anual-dds-2024/blob/main/src/main/java/ar/edu/utn/frba/dds/middlewares/AuthMiddleware.java"
    click Utilities "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/utils"
    click Server "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/java/ar/edu/utn/frba/dds/server"
    click Router "https://github.com/eitan-wajsberg/tp-anual-dds-2024/blob/main/src/main/java/ar/edu/utn/frba/dds/server/Router.java"
    click Tests "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/test"
    click Maven "https://github.com/eitan-wajsberg/tp-anual-dds-2024/blob/main/pom.xml"
    click DeployConfig "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/.github/workflows"
    click Properties "https://github.com/eitan-wajsberg/tp-anual-dds-2024/tree/main/src/main/resources/properties"

    %% Styles
    classDef frontend fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef backend fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef domain fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef persistence fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef adapter fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef infra fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef test fill:#f6e3b4,stroke:#d35400,stroke-width:2px;
    classDef deployment fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
```
