# openmined/syft architecture

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

- Interactive diagram: https://gitdiagram.com/openmined/syft
- Repository: https://github.com/openmined/syft

## Overview

##### Project type and purpose
- This is a Python-based distributed application (“SyftBox”) that ships as a CLI/TUI client plus a server backend.
- The client side manages “apps” (user computations), data synchronization, benchmarking, and an interactive text UI.
- The server side exposes a REST API (versioned under /api/v1), persists metadata (SQL DB + file_store), sends email/telemetry, and hosts simple web templates.

##### File structure
- Top-level directories:
- syftbox/app  – core entry points and CLI/manager logic
- syftbox/client – client SDK: API wrappers, plugin manager, benchmark modules, sync plugins, routers
- syftbox/lib  – shared utilities, constants, workspace, permission logic
- syftbox/server – HTTP server: routers, middleware, DB layer, templates, emails, telemetry
- syftbox/tui  – text UI widgets & driver
- Other folders:
- default_apps / projects / fetchers – example or user-supplied workloads that the client can schedule and sync
- config, docker, scripts, docs – deployment configs, Dockerfile, CI/CD pipelines, documentation.

##### README for additional insights
- Describes installation (uv, virtualenv), one-liner “install.sh” and “syftbox client” invocation.
- Mentions server deployment scripts and local dev mode for server+clients.

##### Detail
- Sub-components (e.g., benchmark/netstats_http, sync/producer, server/emails/router).
- Configuration points (config/prod, config/stage) and deployment artifacts (Dockerfile, uv.lock, workflows).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external

    subgraph "Client Side"
        subgraph "CLI/TUI Layer"
            CLI["CLI Entry"]:::client
            Manager["CLI Manager"]:::client
            TUI_driver["TUI Driver"]:::client
            TUI_app["TUI App"]:::client
            TUI_widgets["TUI Widgets"]:::client
        end
        subgraph "Client Core"
            PluginMgr["Plugin Manager"]:::client
            subgraph "Apps"
                AppSched["App Scheduler"]:::client
                AppsPlugin["Apps Plugin"]:::client
            end
            SyncPlugins["Sync Plugins"]:::client
            Benchmark["Benchmark Modules"]:::client
            subgraph "Local Storage"
                FileMgr["File Manager"]:::client
                Workspace["Workspace"]:::client
            end
        end
        subgraph "Network/API"
            HTTP1["HTTP Client API"]:::client
            HTTP2["Server Client"]:::client
        end
    end

    subgraph "Server Side"
        subgraph "API Layer"
            API_main["Main Router"]:::server
            API_sync["Sync Router"]:::server
            Middleware["Middleware"]:::server
        end
        subgraph "Business Logic"
            Analytics["Analytics"]:::server
            Telemetry["Telemetry"]:::server
            EmailRouter["Email Router"]:::server
        end
        subgraph "Persistence"
            DB_schema["SQL DB"]:::persistence
            FileStore["File Store"]:::persistence
        end
        subgraph "Web UI"
            Templates["Jinja2 Templates"]:::server
        end
        subgraph "External Services"
            EmailProvider["Email Provider"]:::external
            TelemetryExt["Telemetry Endpoint"]:::external
            EmailModels["Email Models"]:::external
        end
    end

    User --> CLI
    CLI --> Manager
    CLI --> TUI_driver
    TUI_driver --> TUI_app
    TUI_app --> TUI_widgets
    Manager --> PluginMgr
    TUI_widgets --> PluginMgr
    PluginMgr --> AppSched
    PluginMgr --> AppsPlugin
    PluginMgr --> SyncPlugins
    PluginMgr --> Benchmark
    PluginMgr --> FileMgr
    PluginMgr --> Workspace
    Benchmark --> HTTP1
    SyncPlugins --> HTTP1
    HTTP1 --> API_main
    HTTP2 --> API_main
    API_main --> Middleware
    API_sync --> Middleware
    Middleware --> Analytics
    Middleware --> Telemetry
    Middleware --> EmailRouter
    Analytics --> DB_schema
    Telemetry --> FileStore
    EmailRouter --> EmailModels
    EmailModels --> EmailProvider
    Telemetry --> TelemetryExt

    click CLI "https://github.com/openmined/syft/blob/main/syftbox/app/cli.py"
    click Manager "https://github.com/openmined/syft/blob/main/syftbox/app/manager.py"
    click TUI_driver "https://github.com/openmined/syft/blob/main/syftbox/tui/cli.py"
    click TUI_app "https://github.com/openmined/syft/blob/main/syftbox/tui/app.py"
    click TUI_widgets "https://github.com/openmined/syft/tree/main/syftbox/tui/widgets/"
    click PluginMgr "https://github.com/openmined/syft/blob/main/syftbox/client/plugin_manager.py"
    click AppSched "https://github.com/openmined/syft/blob/main/syftbox/client/plugins/app_scheduler.py"
    click AppsPlugin "https://github.com/openmined/syft/blob/main/syftbox/client/plugins/apps.py"
    click SyncPlugins "https://github.com/openmined/syft/tree/main/syftbox/client/plugins/sync/"
    click Benchmark "https://github.com/openmined/syft/tree/main/syftbox/client/benchmark/"
    click FileMgr "https://github.com/openmined/syft/blob/main/syftbox/client/utils/file_manager.py"
    click Workspace "https://github.com/openmined/syft/blob/main/syftbox/lib/workspace.py"
    click HTTP1 "https://github.com/openmined/syft/blob/main/syftbox/client/api.py"
    click HTTP2 "https://github.com/openmined/syft/blob/main/syftbox/client/server_client.py"
    click API_main "https://github.com/openmined/syft/blob/main/syftbox/server/api/v1/main_router.py"
    click API_sync "https://github.com/openmined/syft/blob/main/syftbox/server/api/v1/sync_router.py"
    click Middleware "https://github.com/openmined/syft/blob/main/syftbox/server/middleware.py"
    click Analytics "https://github.com/openmined/syft/blob/main/syftbox/server/analytics.py"
    click Telemetry "https://github.com/openmined/syft/blob/main/syftbox/server/telemetry.py"
    click EmailRouter "https://github.com/openmined/syft/blob/main/syftbox/server/emails/router.py"
    click DB_schema "https://github.com/openmined/syft/blob/main/syftbox/server/db/schema.py"
    click FileStore "https://github.com/openmined/syft/blob/main/syftbox/server/db/file_store.py"
    click Templates "https://github.com/openmined/syft/tree/main/syftbox/server/templates/"
    click EmailModels "https://github.com/openmined/syft/blob/main/syftbox/server/emails/models.py"

    classDef client fill:#ccf,stroke:#333,stroke-width:1px;
    classDef server fill:#cfc,stroke:#333,stroke-width:1px;
    classDef persistence fill:#ddd,stroke:#333,stroke-width:1px;
    classDef external fill:#fc9,stroke:#333,stroke-width:1px;
```
