# unipat-ai/saas-bench architecture

> Architecture diagram of the GitHub repository unipat-ai/saas-bench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unipat-ai/saas-bench
- Repository: https://github.com/unipat-ai/saas-bench

## Overview

1. **What this repository is**
   SaaS-Bench is an evaluation harness for computer-use agents. It is not a product application itself; it orchestrates real self-hosted SaaS stacks, runs an agent through browser-based workflows, and then scores the outcome with task-specific verifiers.

2. **Core execution pipeline**
   The main flow is: load a task definition → start the required Dockerized SaaS apps → launch a browser and agent → execute a bounded task trajectory → persist the agent trace → run `verify.py` against the live app state → aggregate results and tear down the environment.

3. **Python harness package**
   The `saas_bench/` package is the central control plane. `run.py` is the CLI entrypoint, `loader.py` discovers tasks and builds prompts, `slot.py` manages per-worker container/port isolation, `agent.py` contains the reference browser-use agent, `verify_runner.py` executes verifiers, and `reporting.py` writes summaries and logs.

4. **Task model and repository boundary**
   The benchmark content lives under `tasks/`, split into `uni-m` and `multi-m` tracks. Each task instance is a self-contained directory with `description.md`, `meta.json`, and `verify.py`. This is the key architectural boundary: the harness is generic, while task logic and scoring are embedded per task.

5. **Task metadata and app registry**
   `saas_bench/apps.yaml` acts as the app catalog for all supported SaaS systems. It encodes what the harness needs to bring up environments: service names, ports, startup commands, and health checks. The task metadata points the harness to the relevant apps/sites for each instance.

6. **Multi-app and slot-based isolation**
   The evaluator supports parallel workers. `slot.py` assigns each worker a slot and derives deterministic port ranges so multiple SaaS stacks can run concurrently without collision. This makes isolation a first-class architectural concern.

7. **Containerized environment layer**
   The `docker/` directory contains Compose templates for specific apps such as Mattermost, OnlyOffice, ownCloud, and Pretix, plus image-loading support. The README indicates that the benchmark depends on prebuilt SaaS images and Docker Compose on a Linux host, so the environment is intentionally heavy-weight and reproducible.

8. **Agent layer**
   The default agent is a browser automation layer built on `browser-use` and a headless Chromium browser. It talks to an OpenAI-compatible chat-completions endpoint, so the agent boundary is “language model + browser actions” rather than any app-specific integration.

9. **Verification layer**
   Scoring is performed by task-local `verify.py` scripts, executed via `verify_runner.py`. Verifiers inspect the live application state inside the running containers, which means the benchmark result depends on the actual SaaS side effects rather than on the agent’s intermediate reasoning.

10. **Multimodal inputs**
   The `multi-m` track includes supporting assets such as PDFs, images, or audio under `tasks/multi-m/inputs/`. The README notes that these are resolved by relative paths from `verify.py`, so input assets are part of the task contract and must be present for verification to succeed.

11. **Operational scripts**
   `scripts/run.sh` is the main entry for running evaluations, while `scripts/load_images.sh` loads the required Docker images and `scripts/stop_all.sh` cleans up stale environments. These scripts are operational wrappers around the Python harness and Docker layer.

12. **Result and error handling**
   Each task produces an agent trajectory JSON and a separate verification JSON in a result directory, with a run-level `summary.json` and `errors.log`. This creates a clean separation between execution traces, scoring, and aggregate reporting.

13. **Documentation as interface spec**
   `docs/task_format.md` and `docs/verify_protocol.md` define the expected task and verifier contracts. For architecture purposes, these docs are important because they specify the stable interfaces between task authors, the harness, and the per-task verifier logic.

14. **External dependencies that shape the system**
   The benchmark relies materially on Docker, browser automation via Playwright/Chromium, and an OpenAI-compatible model endpoint. Those dependencies define the major runtime boundaries: environment orchestration, browser control, and model inference are all external to the task code itself.

Main entry points: [`docker`](https://github.com/unipat-ai/saas-bench/tree/main/docker) (docker/), [`saas_bench/run.py`](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/run.py) (run.py), [`tasks/uni-m`](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m) (uni-m), [`tasks`](https://github.com/unipat-ai/saas-bench/tree/main/tasks) (tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_harness["Harness"]
  node_node_run["run.py<br/>CLI entrypoint<br/>[run.py]"]
  node_node_loader["loader.py<br/>task loader<br/>[loader.py]"]
  node_node_slot["slot.py<br/>worker isolation<br/>[slot.py]"]
  node_node_agent["agent.py<br/>browser agent<br/>[agent.py]"]
  node_node_verify_runner["verify_runner.py<br/>verifier runner<br/>[verify_runner.py]"]
  node_node_reporting["reporting.py<br/>results reporting<br/>[reporting.py]"]
  node_node_apps_yaml["apps.yaml<br/>app registry<br/>[apps.yaml]"]
end

subgraph group_group_tasks["Tasks"]
  node_node_tasks_root[("tasks<br/>benchmark corpus")]
  node_node_uni_m[("uni-m<br/>single-modal track")]
  node_node_multi_m[("multi-m<br/>multimodal track")]
  node_node_business["Business<br/>task family"]
  node_node_healthcare["Healthcare<br/>task family"]
  node_node_software["Software<br/>task family"]
  node_node_teamwork["Teamwork<br/>task family"]
  node_node_agriculture["Agriculture<br/>task family"]
  node_node_media["Media<br/>task family"]
  node_node_multi_inputs["Inputs<br/>multimodal assets"]
end

subgraph group_group_env["Environment"]
  node_node_docker[("docker/<br/>compose templates")]
  node_node_mattermost_tpl["Mattermost<br/>compose template<br/>[mattermost.yml.tpl]"]
  node_node_onlyoffice_tpl["OnlyOffice<br/>compose template<br/>[onlyoffice.yml.tpl]"]
  node_node_owncloud_tpl["ownCloud<br/>compose template<br/>[owncloud.yml.tpl]"]
  node_node_pretix_tpl["Pretix<br/>compose template<br/>[pretix.yml.tpl]"]
  node_node_code_server["code-server deps<br/>image build"]
end

subgraph group_group_ops["Ops & docs"]
  node_node_task_contract["Task format<br/>contract doc<br/>[task_format.md]"]
  node_node_verify_protocol["Verify protocol<br/>contract doc<br/>[verify_protocol.md]"]
  node_node_run_script["run.sh<br/>eval wrapper<br/>[run.sh]"]
  node_node_load_images["load_images.sh<br/>image loader<br/>[load_images.sh]"]
  node_node_stop_all["stop_all.sh<br/>cleanup wrapper<br/>[stop_all.sh]"]
end

node_node_run -->|"loads tasks"| node_node_loader
node_node_run -->|"assigns slots"| node_node_slot
node_node_run -->|"launches agent"| node_node_agent
node_node_run -->|"verifies"| node_node_verify_runner
node_node_run -->|"writes results"| node_node_reporting
node_node_loader -->|"resolves apps"| node_node_apps_yaml
node_node_loader -->|"reads tasks"| node_node_tasks_root
node_node_slot -->|"isolates ports"| node_node_docker
node_node_agent -->|"follows prompt"| node_node_task_contract
node_node_verify_runner -->|"executes by spec"| node_node_verify_protocol
node_node_verify_runner -->|"runs verify.py"| node_node_tasks_root
node_node_reporting -->|"stores traces"| node_node_tasks_root
node_node_tasks_root -->|"contains"| node_node_uni_m
node_node_tasks_root -->|"contains"| node_node_multi_m
node_node_uni_m -->|"family"| node_node_business
node_node_uni_m -->|"family"| node_node_healthcare
node_node_uni_m -->|"family"| node_node_software
node_node_uni_m -->|"family"| node_node_teamwork
node_node_multi_m -->|"family"| node_node_agriculture
node_node_multi_m -->|"family"| node_node_media
node_node_multi_m -->|"shares assets"| node_node_multi_inputs
node_node_run_script -->|"wraps"| node_node_run
node_node_load_images -->|"preloads"| node_node_docker
node_node_stop_all -->|"cleans up"| node_node_docker
node_node_docker -->|"defines"| node_node_mattermost_tpl
node_node_docker -->|"defines"| node_node_onlyoffice_tpl
node_node_docker -->|"defines"| node_node_owncloud_tpl
node_node_docker -->|"defines"| node_node_pretix_tpl
node_node_docker -->|"builds on"| node_node_code_server

click node_node_run "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/run.py"
click node_node_loader "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/loader.py"
click node_node_slot "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/slot.py"
click node_node_agent "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/agent.py"
click node_node_verify_runner "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/verify_runner.py"
click node_node_reporting "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/reporting.py"
click node_node_apps_yaml "https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/apps.yaml"
click node_node_tasks_root "https://github.com/unipat-ai/saas-bench/tree/main/tasks"
click node_node_uni_m "https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m"
click node_node_multi_m "https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m"
click node_node_business "https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Business"
click node_node_healthcare "https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Healthcare"
click node_node_software "https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Software"
click node_node_teamwork "https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Teamwork"
click node_node_agriculture "https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/Agriculture"
click node_node_media "https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/Media"
click node_node_multi_inputs "https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/inputs"
click node_node_task_contract "https://github.com/unipat-ai/saas-bench/blob/main/docs/task_format.md"
click node_node_verify_protocol "https://github.com/unipat-ai/saas-bench/blob/main/docs/verify_protocol.md"
click node_node_run_script "https://github.com/unipat-ai/saas-bench/blob/main/scripts/run.sh"
click node_node_load_images "https://github.com/unipat-ai/saas-bench/blob/main/scripts/load_images.sh"
click node_node_stop_all "https://github.com/unipat-ai/saas-bench/blob/main/scripts/stop_all.sh"
click node_node_docker "https://github.com/unipat-ai/saas-bench/tree/main/docker"
click node_node_mattermost_tpl "https://github.com/unipat-ai/saas-bench/blob/main/docker/mattermost.yml.tpl"
click node_node_onlyoffice_tpl "https://github.com/unipat-ai/saas-bench/blob/main/docker/onlyoffice.yml.tpl"
click node_node_owncloud_tpl "https://github.com/unipat-ai/saas-bench/blob/main/docker/owncloud.yml.tpl"
click node_node_pretix_tpl "https://github.com/unipat-ai/saas-bench/blob/main/docker/pretix.yml.tpl"
click node_node_code_server "https://github.com/unipat-ai/saas-bench/blob/main/docker/code-server-deps.Dockerfile"

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_node_run,node_node_loader,node_node_slot,node_node_agent,node_node_verify_runner,node_node_reporting,node_node_apps_yaml toneBlue
class node_node_tasks_root,node_node_uni_m,node_node_multi_m,node_node_business,node_node_healthcare,node_node_software,node_node_teamwork,node_node_agriculture,node_node_media,node_node_multi_inputs toneAmber
class node_node_docker,node_node_mattermost_tpl,node_node_onlyoffice_tpl,node_node_owncloud_tpl,node_node_pretix_tpl,node_node_code_server toneMint
class node_node_task_contract,node_node_verify_protocol,node_node_run_script,node_node_load_images,node_node_stop_all toneRose
```

## Components

### Harness

Python control plane that loads tasks, runs agents, verifies outcomes, and reports results.

- [run.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/run.py): CLI entrypoint · Main evaluation command that orchestrates a benchmark run. · `saas_bench/run.py`
- [loader.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/loader.py): task loader · Discovers tasks and constructs prompts / task state. · `saas_bench/loader.py`
- [slot.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/slot.py): worker isolation · Assigns worker slots and deterministic port ranges for concurrent runs. · `saas_bench/slot.py`
- [agent.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/agent.py): browser agent · Reference browser-use agent driven by an LLM and Chromium. · `saas_bench/agent.py`
- [verify_runner.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/verify_runner.py): verifier runner · Executes task-local verify.py scripts against live app state. · `saas_bench/verify_runner.py`
- [reporting.py](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/reporting.py): results reporting · Writes summaries, traces, and run logs. · `saas_bench/reporting.py`
- [apps.yaml](https://github.com/unipat-ai/saas-bench/blob/main/saas_bench/apps.yaml): app registry · Catalog of SaaS services, ports, startup commands, and health checks. · `saas_bench/apps.yaml`

### Tasks

Benchmark task corpus and per-task scoring logic.

- [tasks](https://github.com/unipat-ai/saas-bench/tree/main/tasks): benchmark corpus · Root of the benchmark task tree. · `tasks`
- [uni-m](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m): single-modal track · Single-input task track with task-specific verify scripts. · `tasks/uni-m`
- [multi-m](https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m): multimodal track · Tasks that include external assets such as PDFs, images, or audio. · `tasks/multi-m`
- [Business](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Business): task family · Representative uni-m task family with many task instances. · `tasks/uni-m/Business`
- [Healthcare](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Healthcare): task family · Representative uni-m task family with many task instances. · `tasks/uni-m/Healthcare`
- [Software](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Software): task family · Representative uni-m task family with many task instances. · `tasks/uni-m/Software`
- [Teamwork](https://github.com/unipat-ai/saas-bench/tree/main/tasks/uni-m/Teamwork): task family · Representative uni-m task family with many task instances. · `tasks/uni-m/Teamwork`
- [Agriculture](https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/Agriculture): task family · Representative multi-m task family with many task instances. · `tasks/multi-m/Agriculture`
- [Media](https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/Media): task family · Representative multi-m task family with many task instances. · `tasks/multi-m/Media`
- [Inputs](https://github.com/unipat-ai/saas-bench/tree/main/tasks/multi-m/inputs): multimodal assets · Shared multi-m supporting assets resolved by verify.py relative paths. · `tasks/multi-m/inputs`

### Environment

Containerized SaaS apps and Docker Compose templates used during evaluation.

- [docker/](https://github.com/unipat-ai/saas-bench/tree/main/docker): compose templates · Docker Compose templates and image-loading support for supported SaaS apps. · `docker`
- [Mattermost](https://github.com/unipat-ai/saas-bench/blob/main/docker/mattermost.yml.tpl): compose template · Docker Compose template for a supported SaaS app. · `docker/mattermost.yml.tpl`
- [OnlyOffice](https://github.com/unipat-ai/saas-bench/blob/main/docker/onlyoffice.yml.tpl): compose template · Docker Compose template for a supported SaaS app. · `docker/onlyoffice.yml.tpl`
- [ownCloud](https://github.com/unipat-ai/saas-bench/blob/main/docker/owncloud.yml.tpl): compose template · Docker Compose template for a supported SaaS app. · `docker/owncloud.yml.tpl`
- [Pretix](https://github.com/unipat-ai/saas-bench/blob/main/docker/pretix.yml.tpl): compose template · Docker Compose template for a supported SaaS app. · `docker/pretix.yml.tpl`
- [code-server deps](https://github.com/unipat-ai/saas-bench/blob/main/docker/code-server-deps.Dockerfile): image build · Base Dockerfile for image dependencies used by the environment layer. · `docker/code-server-deps.Dockerfile`

### Ops & docs

Scripts and documentation that define and operate the benchmark contract.

- [Task format](https://github.com/unipat-ai/saas-bench/blob/main/docs/task_format.md): contract doc · Specifies the task instance structure and authoring contract. · `docs/task_format.md`
- [Verify protocol](https://github.com/unipat-ai/saas-bench/blob/main/docs/verify_protocol.md): contract doc · Defines how task verifiers interact with the live benchmark environment. · `docs/verify_protocol.md`
- [run.sh](https://github.com/unipat-ai/saas-bench/blob/main/scripts/run.sh): eval wrapper · Shell entrypoint for running evaluations. · `scripts/run.sh`
- [load_images.sh](https://github.com/unipat-ai/saas-bench/blob/main/scripts/load_images.sh): image loader · Loads required Docker images before benchmark execution. · `scripts/load_images.sh`
- [stop_all.sh](https://github.com/unipat-ai/saas-bench/blob/main/scripts/stop_all.sh): cleanup wrapper · Stops stale environments and tears down running services. · `scripts/stop_all.sh`

## Connections

- run.py → loader.py: loads tasks · Run entrypoint discovers tasks and builds task context.
- run.py → slot.py: assigns slots · Run entrypoint uses slot isolation for parallel workers.
- run.py → agent.py: launches agent · Run entrypoint starts the browser-based agent.
- run.py → verify_runner.py: verifies · Run entrypoint triggers task verification after execution.
- run.py → reporting.py: writes results · Run entrypoint persists traces and summaries.
- loader.py → apps.yaml: resolves apps · Task loading maps benchmark tasks to required SaaS services.
- loader.py → tasks: reads tasks · Task loader discovers task instances under the benchmark corpus.
- slot.py → docker/: isolates ports · Slot allocation ensures concurrent stacks do not collide.
- agent.py → Task format: follows prompt · Agent behavior is constrained by task instructions and format.
- verify_runner.py → Verify protocol: executes by spec · Verifier runner invokes per-task verification according to protocol.
- verify_runner.py → tasks: runs verify.py · Verification is delegated to task-local scripts inside each instance.
- reporting.py → tasks: stores traces · Per-task artifacts are grouped under task results.
- tasks → uni-m: contains · Top-level split for single-modal tasks.
- tasks → multi-m: contains · Top-level split for multimodal tasks.
- uni-m → Business: family · Business is a representative uni-m task family.
- uni-m → Healthcare: family · Healthcare is a representative uni-m task family.
- uni-m → Software: family · Software is a representative uni-m task family.
- uni-m → Teamwork: family · Teamwork is a representative uni-m task family.
- multi-m → Agriculture: family · Agriculture is a representative multi-m task family.
- multi-m → Media: family · Media is a representative multi-m task family.
- multi-m → Inputs: shares assets · Multimodal tasks rely on shared supporting inputs.
- run.sh → run.py: wraps · Shell wrapper invokes the Python evaluation CLI.
- load_images.sh → docker/: preloads · Loads the benchmark's required container images.
- stop_all.sh → docker/: cleans up · Stops containers and removes stale environments.
- docker/ → Mattermost: defines · Compose template for Mattermost.
- docker/ → OnlyOffice: defines · Compose template for OnlyOffice.
- docker/ → ownCloud: defines · Compose template for ownCloud.
- docker/ → Pretix: defines · Compose template for Pretix.
- docker/ → code-server deps: builds on · Docker environment layer includes base image support.
