# alpha-unito/swirlc architecture

> Architecture diagram of the GitHub repository alpha-unito/swirlc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alpha-unito/swirlc
- Repository: https://github.com/alpha-unito/swirlc

## Overview

SWIRL is a compiler toolchain for distributed scientific workflows. Users can translate Pegasus DAX workflows into SWIRL plus metadata, then compile a SWIRL workflow and validated metadata into a target executable bundle. Compilation parses SWIRL, builds a distributed workflow model, and delegates generation to the default target, whose generated programs execute commands and communicate across locations. The graph follows the README and indexed references; some implementation details are unsampled, so uncertain internal links are omitted.

Main entry points: [`swirlc/main.py`](https://github.com/alpha-unito/swirlc/blob/master/swirlc/main.py) (swirlc CLI), [`swirlc/translator/dax_translator.py`](https://github.com/alpha-unito/swirlc/blob/master/swirlc/translator/dax_translator.py) (DAX translator), [`swirlc/core/compiler.py`](https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/compiler.py) (Compile visitor), [`swirlc/compiler/default.py`](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py) (Location programs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and inputs"]
  node_cli["swirlc CLI<br/>[main.py]"]
  node_arguments["Command arguments<br/>[parser.py]"]
  node_config["Metadata validation<br/>[validator.py]"]
end

subgraph group_translation["Workflow translation"]
  node_dax["DAX translator<br/>[dax_translator.py]"]
  node_translator_api["Translator interface<br/>[translator.py]"]
end

subgraph group_compile["SWIRL compilation"]
  node_swirl_input["SWIRL workflow input<br/>[SWIRLParser.py]"]
  node_lexer["SWIRL lexer<br/>[SWIRLLexer.py]"]
  node_visitor["Parse-tree visitor<br/>[SWIRLVisitor.py]"]
  node_compile_visitor["Compile visitor<br/>[compiler.py]"]
  node_workflow_model["Workflow model<br/>[entity.py]"]
  node_target["Default target generator<br/>[default.py]"]
end

subgraph group_runtime["Generated runtime"]
  node_bundle["Executable bundle<br/>[default.py]"]
  node_distributed_programs["Location programs<br/>[default.py]"]
  node_command_execution["Command execution<br/>[default.py]"]
  node_data_transport["Send/receive transport<br/>[default.py]"]
end

node_user(("Workflow author"))
node_locations(("Distributed locations"))

node_user -->|"provides inputs"| node_arguments
node_arguments -->|"selects command"| node_cli
node_cli -->|"validates metadata"| node_config
node_cli -->|"dispatches translation"| node_dax
node_dax -->|"implements"| node_translator_api
node_dax -->|"builds model"| node_workflow_model
node_dax -->|"writes SWIRL and metadata"| node_user
node_cli -->|"creates lexer"| node_lexer
node_lexer -->|"tokenizes workflow"| node_swirl_input
node_cli -->|"parses workflow"| node_swirl_input
node_cli -->|"visits parse tree"| node_compile_visitor
node_compile_visitor -->|"extends visitor"| node_visitor
node_compile_visitor -->|"builds model"| node_workflow_model
node_compile_visitor -->|"dispatches generation"| node_target
node_cli -->|"selects target"| node_target
node_target -->|"generates bundle"| node_bundle
node_bundle -->|"contains"| node_distributed_programs
node_distributed_programs -->|"runs steps"| node_command_execution
node_distributed_programs -->|"exchanges data"| node_data_transport
node_data_transport -->|"connects locations"| node_locations

click node_cli "https://github.com/alpha-unito/swirlc/blob/master/swirlc/main.py"
click node_arguments "https://github.com/alpha-unito/swirlc/blob/master/swirlc/parser.py"
click node_config "https://github.com/alpha-unito/swirlc/blob/master/swirlc/config/validator.py"
click node_dax "https://github.com/alpha-unito/swirlc/blob/master/swirlc/translator/dax_translator.py"
click node_translator_api "https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/translator.py"
click node_swirl_input "https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLParser.py"
click node_lexer "https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLLexer.py"
click node_visitor "https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLVisitor.py"
click node_compile_visitor "https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/compiler.py"
click node_workflow_model "https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/entity.py"
click node_target "https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py"
click node_bundle "https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py"
click node_distributed_programs "https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py"
click node_command_execution "https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py"
click node_data_transport "https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_arguments,node_config toneBlue
class node_dax,node_translator_api toneAmber
class node_swirl_input,node_lexer,node_visitor,node_compile_visitor,node_workflow_model,node_target toneMint
class node_bundle,node_distributed_programs,node_command_execution,node_data_transport toneRose
class node_user,node_locations toneIndigo
```

## Components

### CLI and inputs

- [swirlc CLI](https://github.com/alpha-unito/swirlc/blob/master/swirlc/main.py): `swirlc/main.py`
- [Command arguments](https://github.com/alpha-unito/swirlc/blob/master/swirlc/parser.py): `swirlc/parser.py`
- [Metadata validation](https://github.com/alpha-unito/swirlc/blob/master/swirlc/config/validator.py): `swirlc/config/validator.py`

### Workflow translation

- [DAX translator](https://github.com/alpha-unito/swirlc/blob/master/swirlc/translator/dax_translator.py): `swirlc/translator/dax_translator.py`
- [Translator interface](https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/translator.py): `swirlc/core/translator.py`

### SWIRL compilation

- [SWIRL workflow input](https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLParser.py): `swirlc/antlr/SWIRLParser.py`
- [SWIRL lexer](https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLLexer.py): `swirlc/antlr/SWIRLLexer.py`
- [Parse-tree visitor](https://github.com/alpha-unito/swirlc/blob/master/swirlc/antlr/SWIRLVisitor.py): `swirlc/antlr/SWIRLVisitor.py`
- [Compile visitor](https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/compiler.py): `swirlc/core/compiler.py`
- [Workflow model](https://github.com/alpha-unito/swirlc/blob/master/swirlc/core/entity.py): `swirlc/core/entity.py`
- [Default target generator](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py): `swirlc/compiler/default.py`

### Generated runtime

- [Executable bundle](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py): `swirlc/compiler/default.py`
- [Location programs](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py): `swirlc/compiler/default.py`
- [Command execution](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py): `swirlc/compiler/default.py`
- [Send/receive transport](https://github.com/alpha-unito/swirlc/blob/master/swirlc/compiler/default.py): `swirlc/compiler/default.py`

### Other components

- **Workflow author**
- **Distributed locations**

## Connections

- Workflow author → Command arguments: provides inputs (evidence: `swirlc/parser.py`)
- Command arguments → swirlc CLI: selects command (evidence: `swirlc/main.py`)
- swirlc CLI → Metadata validation: validates metadata (evidence: `swirlc/main.py`)
- swirlc CLI → DAX translator: dispatches translation (evidence: `swirlc/main.py`)
- DAX translator → Translator interface: implements (evidence: `swirlc/translator/dax_translator.py`)
- DAX translator → Workflow model: builds model (evidence: `swirlc/translator/dax_translator.py`)
- DAX translator → Workflow author: writes SWIRL and metadata (evidence: `README.md`)
- swirlc CLI → SWIRL lexer: creates lexer (evidence: `swirlc/main.py`)
- SWIRL lexer → SWIRL workflow input: tokenizes workflow (evidence: `swirlc/main.py`)
- swirlc CLI → SWIRL workflow input: parses workflow (evidence: `swirlc/main.py`)
- swirlc CLI → Compile visitor: visits parse tree (evidence: `swirlc/main.py`)
- Compile visitor → Parse-tree visitor: extends visitor (evidence: `swirlc/core/compiler.py`)
- Compile visitor → Workflow model: builds model (evidence: `swirlc/core/compiler.py`)
- Compile visitor → Default target generator: dispatches generation (evidence: `swirlc/core/compiler.py`)
- swirlc CLI → Default target generator: selects target (evidence: `swirlc/main.py`)
- Default target generator → Executable bundle: generates bundle (evidence: `README.md`)
- Executable bundle → Location programs: contains (evidence: `swirlc/compiler/default.py`)
- Location programs → Command execution: runs steps (evidence: `swirlc/compiler/default.py`)
- Location programs → Send/receive transport: exchanges data (evidence: `swirlc/compiler/default.py`)
- Send/receive transport → Distributed locations: connects locations (evidence: `swirlc/compiler/default.py`)
