# pauliusmilmantas/colabfoldwebserver architecture

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

- Interactive diagram: https://gitdiagram.com/pauliusmilmantas/colabfoldwebserver
- Repository: https://github.com/pauliusmilmantas/colabfoldwebserver

## Overview

##### Main Components

a. API Service Layer:
- Subcomponents:
- App Controller
- Ticket Service
- RabbitMQ Service
- Bearer Guard (Authentication)

b. Message Queue:
- Bidirectional connections between API and Worker

c. Worker Service:
- Subcomponents:
- RabbitMQ Controller
- Results Logger Service
- Converters (BLAST Converter)
- Engine Services:
- DIAMOND Service
- SWIPE Service
- Download Service

d. Analysis Engines:
- Two sub-containers:
- DIAMOND Engine
- SWIPE Engine

##### Connection and Data Flow

- Client → API Service (REST requests)
- API Service → RabbitMQ (Job submission)
- RabbitMQ → Worker Service (Job consumption)
- Worker Service → Analysis Engines (Processing)
- Analysis Engines → Worker Service (Results)
- Worker Service → Results Logger (Storage)

##### Additional Elements

a. Configuration:
- .env files and configuration components
- Environment-specific settings

b. Infrastructure:
- Docker containers (shown by Dockerfile presence)
- Docker-compose orchestration

##### Notes

Important notes about:
- Scalability of workers
- Engine independence
- Configuration requirements
- Authentication flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CL[Client Application]
    end

    subgraph "API Service Layer"
        API[API Service]:::service
        RC["REST Controller"]:::component
        AG["Authentication Guard"]:::component
        TS["Ticket Service"]:::component
        RMQS["RabbitMQ Service"]:::component
        APIC["API Config"]:::config

        API --> RC
        API --> AG
        API --> TS
        API --> RMQS
        API --> APIC
    end

    subgraph "Message Queue"
        RMQ[("RabbitMQ")]:::queue
    end

    subgraph "Worker Service"
        WS[Worker Service]:::service
        RMQC["RabbitMQ Controller"]:::component
        RL["Results Logger"]:::component
        BC["BLAST Converter"]:::component
        EI["Engine Interface"]:::component
        DS["Download Service"]:::component
        WCON["Worker Config"]:::config

        WS --> RMQC
        WS --> RL
        WS --> BC
        WS --> EI
        WS --> DS
        WS --> WCON
    end

    subgraph "Engine Services"
        DES["DIAMOND Engine Service"]:::engine
        SES["SWIPE Engine Service"]:::engine
    end

    subgraph "Analysis Engines"
        DE["DIAMOND Engine"]:::engine
        SE["SWIPE Engine"]:::engine
    end

    subgraph "Docker Configuration"
        DCA["API Dockerfile"]:::docker
        DCW["Worker Dockerfile"]:::docker
        DCC["Docker Compose"]:::docker
    end

    CL --> API
    API --> RMQ
    RMQ --> WS
    WS --> DES
    WS --> SES
    DES --> DE
    SES --> SE

    classDef service fill:#4a90e2,stroke:#2c3e50,color:white
    classDef component fill:#95a5a6,stroke:#2c3e50,color:white
    classDef queue fill:#27ae60,stroke:#2c3e50,color:white
    classDef engine fill:#e67e22,stroke:#2c3e50,color:white
    classDef config fill:#8e44ad,stroke:#2c3e50,color:white
    classDef docker fill:#34495e,stroke:#2c3e50,color:white

    click API "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/API/src"
    click RC "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/API/src/app.controller.ts"
    click AG "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/API/src/bearer.guard.ts"
    click TS "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/API/src/ticket.service.ts"
    click RMQS "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/API/src/rabbitmq.service.ts"
    click APIC "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/API/src/config/app.config.ts"
    click WS "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/Worker/src"
    click RMQC "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/rabbitmq.controller.ts"
    click RL "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/resultsLogger.service.ts"
    click BC "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/converters/blast-converter.service.ts"
    click EI "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/services/engine.interface.ts"
    click DS "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/services/download.service.ts"
    click DES "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/services/diamond.service.ts"
    click SES "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/Worker/src/services/swipe.service.ts"
    click DE "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/Engines/DIAMOND"
    click SE "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/Engines/SWIPE"
    click DCA "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/Dockerfile-API"
    click DCW "https://github.com/PauliusMilmantas/ColabFoldWebServer/tree/master/Dockerfile-Worker"
    click DCC "https://github.com/PauliusMilmantas/ColabFoldWebServer/blob/master/docker-compose.yml"
```
