# block/ftl architecture

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

- Interactive diagram: https://gitdiagram.com/block/ftl
- Repository: https://github.com/block/ftl

## Overview

##### Core System Layers
- User/Client Interface layer:
– This is the CLI (e.g. the “ftl” binary and related commands in cmd/ftl) which the user interacts with to run commands like “ftl init” or “ftl call”. It initiates projects and modules.
- Module and Verb Layer:
– Once initiated, the system creates and manages “modules” (e.g. “alice” in the sample) that expose verbs (actions to call, such as “alice.hello”) for user interaction.
- Runtime and Build Engine Layer:
– This layer contains engines responsible for building, orchestrating, and testing modules. It is composed of the build engine, language-specific runtime plugins (Go, Java, Kotlin, Python), and module configuration components. Many directories (backend, go-runtime, jvm-runtime, python-runtime) reflect these responsibilities.
- Provisioner/Deployment Layer:
– This layer manages deploying built modules (via provisioners) and interfaces with external systems (databases, cloud providers, container orchestration). The “internal/provisioner” and “deployment” directories capture these functions.

##### Relationships and Interactions
- The User Interface layer (CLI) sends commands to the Module/Verb layer.
- The Module layer forwards execution requests to the Build Engine, which compiles and runs the code.
- The Runtime plugins (in various language-specific directories) are called upon to perform language-specific tasks.
- The Provisioner layer then handles deployments and configurations for running environments.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Layers

    %% Layer 1: User/Client Interface (CLI)
    A["CLI: Command parsing and user interaction."]:::cli

    %% Layer 2: Module and Verb Layer
    B["Module/Verb: Module creation and verb dispatching."]:::module

    %% Layer 3: Runtime and Build Engine Layer
    subgraph "Runtime and Build Engine Layer"
        C["Build Engine: Compilation, orchestration and testing."]:::engine
        subgraph "Runtime Plugins"
            D1["Go Runtime: Language-specific operations."]:::runtime
            D2["JVM Runtime: Language-specific operations."]:::runtime
            D3["Python Runtime: Language-specific operations."]:::runtime
        end
    end

    %% Layer 4: Provisioner/Deployment Layer
    subgraph "Provisioner/Deployment Layer"
        E["Provisioner: Deployment and configuration."]:::provisioner
        F["Deployment: Configuration files and assets."]:::provisioner
    end

    %% Connections
    A -->|"sends_commands"| B
    B -->|"forwards_requests"| C
    C -->|"invokes"| D1
    C -->|"invokes"| D2
    C -->|"invokes"| D3
    C -->|"triggers_deployment"| E
    D1 -->|"sends_deployment_data"| E
    D2 -->|"sends_deployment_data"| E
    D3 -->|"sends_deployment_data"| E
    E -->|"uses_config"| F

    %% Click Events
    click A "https://github.com/block/ftl/tree/main/cmd/ftl"
    click B "https://github.com/block/ftl/blob/main/cmd/ftl/cmd_module.go"
    click C "https://github.com/block/ftl/tree/main/internal/buildengine"
    click D1 "https://github.com/block/ftl/tree/main/go-runtime"
    click D2 "https://github.com/block/ftl/tree/main/jvm-runtime"
    click D3 "https://github.com/block/ftl/tree/main/python-runtime"
    click E "https://github.com/block/ftl/tree/main/internal/provisioner"
    click F "https://github.com/block/ftl/tree/main/deployment"

    %% Styles
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef module fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef engine fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef runtime fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef provisioner fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
