# arthurmascaro/pipegene-back-end architecture

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

- Interactive diagram: https://gitdiagram.com/arthurmascaro/pipegene-back-end
- Repository: https://github.com/arthurmascaro/pipegene-back-end

## Overview

Based on your provided file tree and README, this project is a backend application built with Java (using Maven) that orchestrates genomic data processing pipelines. Its main purpose is to manage and trigger external Python provider services that execute specific pipeline steps (such as pre-processing a MAF file into a PNG, further pre-processing output, and variant classification). The backend ties together user management, pipeline configuration, execution management, and external integrations (via REST or similar calls) while persisting domain data (using PostgreSQL via Docker).

##### Main components
- Backend Application Layer: Represented by your Spring Boot “PipegeneApplication”, the REST controllers (in the “web/controller” packages), and the security configuration components. These manage API endpoints, handle user and pipeline requests, and secure communications (using JWT, CORS, etc.).
- Business Logic / Use Cases: Capture the “usecases” packages (account, execution, group, pipeline, project, provider, etc.). These components orchestrate calls to the persistence layer and external services.
- Domain and Persistence Layer: Include the “domain” models and the “external/persistence” DAOs and Entity classes. This layer maps business objects and handles read/write operations with the database.
- Configuration and Infrastructure: Include the configuration components (security, Jackson, scheduling, properties) that set up dependencies and behavior, and the Docker configuration for Postgres.

##### Relationships and Data Flow
- Clients (or users via a potential frontend or API consumers) send requests that hit the Backend’s REST Controllers.
- Controllers delegate processing to the corresponding Use Case classes which implement business logic.
- Use Cases interact with the Persistence Layer (DAOs) to read/write domain data (e.g., project, pipeline, execution information) and update records in the PostgreSQL database.
- Use Cases also call External Provider Clients. For example:
- The “Grafico pré processamento” provider receives a MAF file and returns a PNG.
- The “Pré processamento - Rodrigo” provider receives a MAF and returns a processed MAF.
- The “Classificação de variante - Rodrigo” provider receives a processed MAF and returns a classification PNG.
- The local storage service (LocalStorageService) is used for managing file uploads/downloads by the web layer.

##### Important Architectural Patterns and Principles
- Layered Architecture: Clearly separate the presentation layer (web controllers) from the business logic layer (use cases/service layer) and data access layer (persistence/DAOs).
- External API Integration: Use dedicated client components (in “external/client”) for communication with Python services.
- Configuration & Security: Emphasize the use of properties configuration (via YAML and dedicated properties classes), JWT and CORS for securing access.
- Use of Docker for infrastructure: The Docker Compose setup for PostgreSQL clearly encapsulates your database environment.

##### Instructing the Principal Software Engineer
- Start from the top with client interactions hitting the Web layer (REST controllers). Label these clearly.
- Branch out to illustrate two major interactions:
1. To the Persistence Layer/Database: show CRUD operations via DAOs and Entities.
- Dockerized PostgreSQL instance.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Interaction
    Client["API Client"]:::client

    %% Backend Application Layer
    subgraph "Backend Application Layer"
        PA["PipegeneApplication"]:::backend
        RC["REST Controllers"]:::backend
        LSS["LocalStorageService"]:::backend
    end

    %% Business Logic / Use Cases
    BL["Business Logic / Use Cases"]:::business

    %% Domain and Persistence Layer
    subgraph "Domain and Persistence Layer"
        DM["Domain Models"]:::domain
        PDAO["Persistence (DAOs)"]:::domain
        PENT["Persistence (Entities)"]:::domain
    end

    %% External Integration Services
    subgraph "External Integration Services"
        PC["Provider Clients"]:::external
        EXT1["Grafico pré processamento (Python:Port5011)"]:::external
        EXT2["Pré processamento - Rodrigo (Python:Port5001)"]:::external
        EXT3["Classificação de variante - Rodrigo (Python:Port5002)"]:::external
    end

    %% Database and Infrastructure
    subgraph "Database & Infrastructure"
        PG["PostgreSQL (Docker)"]:::database
        DC["Docker Compose Configuration"]:::database
    end

    %% Configuration and Security
    CONF["Configuration & Security"]:::config

    %% Flow Connections
    Client -->|"APIRequest"| RC
    PA -->|"Initializes"| RC
    RC -->|"HandlesRequest"| BL
    RC -->|"HandlesFiles"| LSS
    RC -->|"LoadsConfig"| CONF
    LSS -->|"UsesConfig"| CONF

    BL -->|"ExecutesLogic"| DM
    BL -->|"ExecutesLogic"| PDAO
    BL -->|"ExecutesLogic"| PENT
    PDAO -->|"CRUDOperations"| PG
    PENT -->|"CRUDOperations"| PG

    BL -->|"Triggers"| PC
    PC -->|"CallsProvider"| EXT1
    PC -->|"CallsProvider"| EXT2
    PC -->|"CallsProvider"| EXT3

    %% Class Definitions for styling
    classDef client fill:#C3F0CA,stroke:#2D6A4F,stroke-width:2px;
    classDef backend fill:#BBE1FA,stroke:#1B4965,stroke-width:2px;
    classDef business fill:#F6BD60,stroke:#E8A87C,stroke-width:2px;
    classDef domain fill:#F7D794,stroke:#FF793F,stroke-width:2px;
    classDef external fill:#FAF3DD,stroke:#F3A712,stroke-width:2px;
    classDef database fill:#B8E994,stroke:#78E08F,stroke-width:2px;
    classDef config fill:#F8A5C2,stroke:#F78DA7,stroke-width:2px;

    %% Click Events
    click PA "https://github.com/arthurmascaro/pipegene-back-end/blob/main/src/main/java/br/edu/ifsp/scl/pipegene/PipegeneApplication.java"
    click RC "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/web/controller/"
    click BL "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/usecases/"
    click DM "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/domain/"
    click PDAO "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/external/persistence/"
    click PENT "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/external/persistence/entities/"
    click PC "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/external/client/"
    click LSS "https://github.com/arthurmascaro/pipegene-back-end/blob/main/src/main/java/br/edu/ifsp/scl/pipegene/external/storage/localstorage/LocalStorageService.java"
    click PG "https://github.com/arthurmascaro/pipegene-back-end/tree/main/docker/postgres/"
    click DC "https://github.com/arthurmascaro/pipegene-back-end/blob/main/docker/docker-compose.yml"
    click CONF "https://github.com/arthurmascaro/pipegene-back-end/tree/main/src/main/java/br/edu/ifsp/scl/pipegene/configuration/"
```
