# tuxekro/test-pringboot-caixatech architecture

> Architecture diagram of the GitHub repository tuxekro/test-pringboot-caixatech, 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/tuxekro/test-pringboot-caixatech
- Repository: https://github.com/tuxekro/test-pringboot-caixatech

## Overview

##### Project Type and Purpose
- The project is a Java backend application built with Spring Boot and Maven. Its purpose is to support a real estate auction system and related functionalities (authentication via JWT, property data scraping from Idealista, mortgage applications, and an asynchronous bidding/auction process using RabbitMQ). The README clearly details tasks such as Docker configuration, secure endpoints, external data extraction, and asynchronous message processing.

##### File Structure
- The file tree shows clear separation of responsibilities:
- The “src/main/java/com/round3/realestate” package contains subdirectories for configuration (with classes for Spring Security and RabbitMQ), controllers (defining REST endpoints for auth, mortgage, auctions, etc.), entities (JPA mappings), payload (DTOs for requests/responses), repositories (Spring Data JPA), security (JWT utilities and filters), messaging (for RabbitMQ producers and consumers), services (business logic implementations), and utilities.
- A separate “src/main/resources” folder contains configurations (application.properties).
- In addition to code packages, the project has Docker-related files (Dockerfile, docker-compose.yml) which indicate that the application runs inside containerized environments.

##### README for Additional Insights
- The README details the endpoints, tasks, and business rules, clearly stating integration with RabbitMQ (bid.queue, bid.exchange, bid.routingkey), JWT for security, and even web scraping using libraries like Jsoup.
- Functional areas include authentication, property data processing, mortgage calculations, and auction activities – each forming a key component in the architecture.

##### Main Components
- Frontend/Client (even if not integrated directly, external users or testing clients will call the API endpoints)
- API Layer (Controllers handling HTTP requests)
- Service Layer (business logic including processing of auctions, bid management, employment and mortgage handling)
- Data Access Layer (Repositories interfacing with the database)
- Domain Layer (Entities representing Auctions, Bids, Users, Properties, Mortgages, etc.)
- Messaging Component (RabbitMQ configuration, Message Producer [BidPublisher], and Consumer [BidConsumer], handling asynchronous bid processing)
- Security Layer (Spring Security, JWT configuration, and filters such as JwtRequestFilter)
- External Interfaces:
- Idealista (for scraping property data)
- Database (for persistent storage of entities)
- RabbitMQ broker (for asynchronous messaging)
- Infrastructure Tools:
- Docker container setup (using Dockerfile and docker-compose.yml)

##### Relationships and Interactions
- Clients interact with the API endpoints (controllers) that invoke services.
- Services process business logic and call repositories to persist or fetch data.
- The messaging layer (RabbitMQ) is used especially in the auction module – bids are published to and consumed from a RabbitMQ queue to avoid concurrency issues.
- Security is enforced via JWT tokens through the authentication flow and filters.
- The Idealista scraper is a separate endpoint that uses an external library (Jsoup) to extract property details and may optionally persist the results in the database.
- Docker is used to containerize the entire backend, with the Dockerfile, and docker-compose coordinates the container start-up (possibly linking the containerized DB and message broker).

##### Architectural Patterns and Design Principles
- Layered architecture: clear separation between controllers, services, repositories, DTOs, and entities.
- Asynchronous processing: use of RabbitMQ in the bidding system.
- Security best practices: JWT-based authentication and Spring Security integration.
- Dependency inversion: using interfaces for services and repositories.
- Configuration management: centralized application.properties and profile management.

- A node representing "Clients" (e.g., web/mobile/test tools) invoking the API.
- A container for the “API Layer/Controllers” with endpoints like /api/auth, /api/scrape, /api/mortgage, /api/auction, etc.
- A block for “Service Layer” showing business logic components for auctions, authentication, mortgages, employment, and scraping.
- A “Data Access/Repository” component communicating with the “Database” entity.
- A “Messaging” component that includes both the producer (BidPublisher) and consumer (BidConsumer) interacting with RabbitMQ.
- A “Security” component including JWT token management, authentication, and filter layers.
- External dependency blocks: one for Idealista (web scraping), one for RabbitMQ, and one for the Database.
- Docker and container orchestration (Dockerfile and docker-compose) as the deployment environment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Clients
    Clients["Clients (Web/Mobile/Test Tools)"]:::clients

    %% Backend System Subgraph
    subgraph "Backend System"
        API["API Layer / Controllers"]:::api
        SEC1["WebSecurityConfig"]:::security
        SEC2["Security Utils"]:::security
        SRV["Service Layer"]:::service
        REPO["Data Access / Repository"]:::repository
        DOMAIN["Domain Layer (Entities)"]:::domain
        MSG["Messaging Component"]:::messaging
    end

    %% External Systems
    EXT_IDEALISTA["Idealista Scraping"]:::external
    EXT_RABBITMQ["RabbitMQ Broker"]:::external
    EXT_DB["Database"]:::database

    %% Containerization Subgraph
    subgraph "Containerization"
        DOCKERFILE["Dockerfile"]:::infra
        DOCKER_COMPOSE["docker-compose.yml"]:::infra
    end

    %% Relationships and Data Flows
    Clients -->|"HTTPRequests"| API
    API -->|"JWTAuth"| SEC1
    API -->|"JWTAuth"| SEC2
    API -->|"APICalls"| SRV
    SRV -->|"DataOps"| REPO
    REPO -->|"CRUD"| EXT_DB
    SRV -->|"DomainLogic"| DOMAIN
    SRV -->|"AsyncMsgs"| MSG
    MSG -->|"Queueing"| EXT_RABBITMQ
    API -->|"DataScrape"| EXT_IDEALISTA
    DOCKERFILE -->|"Deploys"| EXT_DB
    DOCKER_COMPOSE -->|"Orchestrates"| EXT_RABBITMQ

    %% Click Events
    click API "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/controller"
    click SRV "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/service"
    click REPO "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/repository"
    click DOMAIN "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/entity"
    click MSG "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/messaging"
    click SEC1 "https://github.com/tuxekro/test-pringboot-caixatech/blob/main/src/main/java/com/round3/realestate/config/WebSecurityConfig.java"
    click SEC2 "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/src/main/java/com/round3/realestate/security"
    click EXT_IDEALISTA "https://github.com/tuxekro/test-pringboot-caixatech/blob/main/src/main/java/com/round3/realestate/util/IdealistaUtils.java"
    click DOCKERFILE "https://github.com/tuxekro/test-pringboot-caixatech/tree/main/Dockerfile"
    click DOCKER_COMPOSE "https://github.com/tuxekro/test-pringboot-caixatech/blob/main/docker-compose.yml"

    %% Styles
    classDef clients fill:#fef,stroke:#333,stroke-width:2px;
    classDef api fill:#bbf,stroke:#333,stroke-width:2px;
    classDef security fill:#f9c,stroke:#333,stroke-width:2px;
    classDef service fill:#ffddaa,stroke:#333,stroke-width:2px;
    classDef repository fill:#faa,stroke:#333,stroke-width:2px;
    classDef domain fill:#ddd,stroke:#333,stroke-width:2px;
    classDef messaging fill:#d4a5a5,stroke:#333,stroke-width:2px;
    classDef external fill:#afa,stroke:#333,stroke-width:2px;
    classDef database fill:#cfc,stroke:#333,stroke-width:2px;
    classDef infra fill:#eef,stroke:#333,stroke-width:2px;
```
