# jhonnatanhhm/envifo-java-backend-api-rest architecture

> Architecture diagram of the GitHub repository jhonnatanhhm/envifo-java-backend-api-rest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jhonnatanhhm/envifo-java-backend-api-rest
- Repository: https://github.com/jhonnatanhhm/envifo-java-backend-api-rest

## Overview

##### Project type and purpose
- This is a single-service Java Spring Boot REST API backend.
- Purpose: expose HTTP endpoints to manage customers, projects, materials, textures, 3D designs, etc.; enforce security via JWT; persist data in PostgreSQL; handle migrations with Flyway; process asynchronous messages via RabbitMQ; and send recovery emails.

##### File structure
- layers/hexagonal approach under src/main/java/com/envifo_backend_java/Envifo_backend_java:
- interfaces/controller – REST controllers (API layer)
- application/dto & application/service – DTOs and orchestration services (use-case layer)
- domain/model & domain/service & domain/repository – entities, business interfaces, repository interfaces (domain layer)
- infrastructure/config – Spring configs (DB, Flyway, RabbitMQ, security, Swagger)
- infrastructure/persistence/repository – JPA repository implementations (data access)
- infrastructure/messaging – RabbitMQ listeners (event handling)
- infrastructure/security – JWT filters, token factory, entry point (security infra)
- infrastructure/exceptions – global exception handling
- Dockerfile, pom.xml, Maven wrapper, .mvn indicate containerized, Maven-driven build and deployment.
- src/main/resources/db/migration holds Flyway scripts.
- src/main/resources/templates holds email template.

##### README
- Confirms tech stack: Spring Boot, Spring Security, JWT, JPA, PostgreSQL.
- Mentions API REST, token generation/validation, DB management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["HTTP Client"]:::external

    %% Application Entry Point
    subgraph "Application Entry"
        AppEntry["EnvifoBackendJavaApplication\n& ServletInitializer"]:::infra
    end

    %% API Layer
    subgraph "API Layer" 
        Controllers["REST Controllers"]:::frontend
    end

    %% Security Layer
    subgraph "Security Layer"
        JwtFilter["JwtAuthenticationFilter"]:::infra
        JwtEntry["JwtAuthEntryPoint"]:::infra
        JwtFactory["JwtTokenFactory"]:::infra
        JwtUtils["JwtUtils"]:::infra
        SecConsts["SecurityConstants"]:::infra
        SecConfig["SecurityConfig"]:::infra
    end

    %% Application Layer
    subgraph "Application Layer"
        AppServices["Application Services"]:::service
        CustomUserDetails["CustomUserDetailsService"]:::service
        EmailService["EmailServiceImple"]:::service
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Entities["Entities"]:::domain
        DomainServices["Service Interfaces"]:::domain
    end

    %% Persistence Layer
    subgraph "Persistence Adapters"
        RepoPorts["Repository Interfaces"]:::persistence
        JPARepos["JPA Repository Implementations"]:::persistence
    end

    %% Infrastructure Config
    subgraph "Infra Config"
        FlywayCfg["FlywayConfig"]:::infra
        R2Cfg["R2Config"]:::infra
        MQCfg["RabbitMQConfig"]:::infra
    end

    %% Messaging
    subgraph "Messaging"
        MQ["RabbitMQ"]:::external
        MsgListener["MaterialMessageListener"]:::infra
    end

    %% Database & External Systems
    subgraph "External Systems"
        DB["PostgreSQL"]:::external
        SMTP["SMTP Server"]:::external
        FlywayScripts["Flyway Scripts"]:::external
    end

    %% Exception Handling
    subgraph "Cross-Cutting"
        ExceptionHandler["GlobalExceptionHandler"]:::infra
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        Pom["pom.xml"]:::external
        Dockerfile["Dockerfile"]:::external
    end

    %% Data Flows
    Client -->|HTTP Request| Controllers
    Controllers -->|passes through| JwtFilter
    JwtFilter --> SecConfig
    SecConfig --> JwtEntry
    SecConfig --> JwtFactory
    JwtFactory --> JwtUtils
    Controllers -->|delegates| AppServices
    AppServices -->|uses| DomainServices
    DomainServices -->|persist via| RepoPorts
    RepoPorts -->|implemented by| JPARepos
    JPARepos -->|CRUD| DB

    MQ -->|publishes| MsgListener
    MsgListener -->|delegates| AppServices

    AppServices -->|send email via| EmailService
    EmailService --> SMTP

    FlywayScripts --> FlywayCfg
    FlywayCfg --> DB
    R2Cfg --> DB
    MQCfg --> MQ

    Controllers --> ExceptionHandler
    AppServices --> ExceptionHandler

    AppEntry --> Controllers

    Pom --> AppEntry
    Dockerfile --> AppEntry

    %% Click Events
    click Controllers "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/interfaces/controller"
    click JwtFilter "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/security/JwtAuthenticationFilter.java"
    click JwtEntry "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/security/JwtAuthEntryPoint.java"
    click JwtFactory "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/security/JwtTokenFactory.java"
    click JwtUtils "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/security/JwtUtils.java"
    click SecConsts "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/security/SecurityConstants.java"
    click SecConfig "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/config/SecurityConfig.java"
    click AppServices "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/application/service"
    click CustomUserDetails "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/application/service/CustomUserDetailsService.java"
    click EmailService "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/application/service/EmailServiceImple.java"
    click Entities "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/domain/model/entity"
    click DomainServices "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/domain/service"
    click RepoPorts "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/domain/repository"
    click JPARepos "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/persistence/repository"
    click FlywayScripts "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/src/main/resources/db/migration"
    click FlywayCfg "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/config/FlywayConfig.java"
    click R2Cfg "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/config/R2Config.java"
    click MQCfg "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/config/RabbitMQConfig.java"
    click MsgListener "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/messaging/MaterialMessageListener.java"
    click ExceptionHandler "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/infrastructure/exceptions/GlobalExceptionHandler.java"
    click AppEntry "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/EnvifoBackendJavaApplication.java"
    click AppEntry "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/src/main/java/com/envifo_backend_java/Envifo_backend_java/ServletInitializer.java"
    click Pom "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/blob/dev/pom.xml"
    click Dockerfile "https://github.com/jhonnatanhhm/envifo-java-backend-api-rest/tree/dev/Dockerfile"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#E2F7E1,stroke:#2e8b57,color:#2e8b57;
    classDef persistence fill:#FFF4D9,stroke:#daa520,color:#a569bd;
    classDef infra fill:#FFE6CC,stroke:#ff8c00,color:#ff4500;
    classDef domain fill:#E8E8E8,stroke:#808080,color:#555555;
    classDef external fill:#F2F2F2,stroke:#a9a9a9,color:#333333;
```
