# maayanlab/playbook-workflow-builder architecture

> Architecture diagram of the GitHub repository maayanlab/playbook-workflow-builder, 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/maayanlab/playbook-workflow-builder
- Repository: https://github.com/maayanlab/playbook-workflow-builder

## Overview

Based on our analysis, the Playbook Workflow Builder is a full‐stack application built to assemble and orchestrate playbook components used in bioinformatics and workflow publishing (including generating BioCompute objects). The solution is built with Next.js and TypeScript for the main application and API endpoints, and it integrates various specialized components such as data visualizations, file APIs, and microservice connectors (for example, integrations with CAVATICA and Next‐auth). The repository is also rich with CLI utilities and analysis notebooks that support batch processing and experimentation.

##### Main Components
- Frontend Application: Represent the “app” directory which houses the Next.js frontend. This includes:
- Page components and layouts (located in app/pages).
- Reusable UI components (in app/components and the separate components/ directory).
- Extensions for authentication (Next-auth), websockets, and other integrations.
- Backend/API Layer: Show the API endpoints (found under app/api & app/pages/api) that expose REST endpoints. Also include the server side (app/server) which may include plugins (e.g., CAVATICA proxy, websocket handling) that mediate backend logic.
- Database: Include the database abstraction layer from the “db” directory (schema.sql, ORMs, and various SQL files) as well as utilities (found under utils/orm) responsible for persistence and queries.
- External and Integrated Services: Identify external integrations like CAVATICA, Next-Auth, and other bioinformatics-specific services (via the “app/extensions”, “components/service”, and “spec” directories). These indicate how the system integrates with external or third-party resources.
- Data and Analysis: Note the “analysis” folder (containing Jupyter notebooks) that supports exploratory analysis and data examination.

##### Relationships and Interactions
- Backend API layers interact with the database and ORM modules (illustrate the connection between backend and DB).
- CLI scripts may trigger batch processes or maintenance functions that update the database, generate reports, or adjust configurations.
- The “core” and “components” libraries facilitate importing shared functionality (plotting, file handling, analytics, error handling, etc.) and thus should be depicted as common modules that support both frontend and backend components.

##### Architectural Patterns & Design Principles
- Modularization and Separation of Concerns: Highlight the separation between UI, API, business logic, and infrastructure (DB, external integrations).
- Microservices/Plugin-based Architecture: Illustrate how specialized functionality (authentication, sockets, data processing) is encapsulated in distinct modules (e.g., the “extensions”, “service”, or “cli” directories).
- Reusability: Emphasize the role of shared components and libraries (each component in “components/” and “core/”) that can be reused throughout the system.
- Use of Next.js Routing: Clearly differentiate between the server-side rendered pages and API routes within the same codebase.

##### Relevant Technologies & Frameworks
- Next.js for full-stack development.
- React and TypeScript for UI development.
- Node.js for server-side operations.
- Docker (Dockerfile, docker-compose.yaml) indicating containerization support.
- Integration with various bioinformatics services (e.g., CAVATICA, BioCompute standards).
- Supporting CLI tools written in TypeScript, Python, and shell scripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    Client["Client (Browser)"]:::client
    UI["Next.js Frontend"]:::frontend
    API["API Endpoints"]:::backend
    Server["Server Logic"]:::backend
    ORM["ORM Utilities"]:::database
    DB["Database"]:::database
    CLI["CLI & Batch Utilities"]:::cli
    CAV["External: CAVATICA"]:::external
    NA["External: Next-auth"]:::external
    EXT["External: Integrations"]:::external
    Analysis["Data & Analysis Notebooks"]:::analysis

    %% Subgraph - Presentation Tier
    subgraph "Presentation Tier"
        UI
    end

    %% Subgraph - Application Tier
    subgraph "Application Tier"
        API
        Server
    end

    %% Subgraph - Data Tier
    subgraph "Data Tier"
        ORM
        DB
    end

    %% Subgraph - External Services
    subgraph "External Services"
        CAV
        NA
        EXT
    end

    %% Subgraph - Utilities & Analysis
    subgraph "Utilities & Analysis"
        CLI
        Analysis
    end

    %% Connections
    Client -->|"HTTPRequest"| UI
    UI -->|"calls_API"| API
    API -->|"delegates_to"| Server
    Server -->|"queries_via"| ORM
    ORM -->|"persists_data_to"| DB
    CLI -->|"batch_updates"| DB
    UI -->|"authenticates_via"| NA
    Server -->|"proxies_to"| CAV
    API -->|"fetches_from"| EXT
    Analysis -->|"analyzes"| DB

    %% Click Events
    click UI "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/"
    click API "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/api"
    click Server "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/server"
    click ORM "https://github.com/maayanlab/playbook-workflow-builder/tree/main/utils/orm"
    click DB "https://github.com/maayanlab/playbook-workflow-builder/tree/main/db/"
    click CLI "https://github.com/maayanlab/playbook-workflow-builder/tree/main/cli/"
    click CAV "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/extensions/cavatica"
    click NA "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/extensions/next-auth"
    click EXT "https://github.com/maayanlab/playbook-workflow-builder/tree/main/app/api/v1/user/integrations"
    click Analysis "https://github.com/maayanlab/playbook-workflow-builder/tree/main/analysis/"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef cli fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef analysis fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef client fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
```
