flowchart LR
    cli[CLI
    src/bin/cli.ts
    src/bin/cli-core.ts]
    browser[Browser Clients
    Svelte SPA + WebSocket client]

    subgraph relay[conduit daemon]
        daemon[Daemon
        src/lib/daemon/daemon.ts]
        server[Shared HTTP and WS edge
        src/lib/server/*]
        persistence[SQLite event store
        src/lib/persistence/*]
        providers[Provider adapters
        src/lib/provider/*]

        subgraph projects[Per-project mounts under /p/<slug>]
            relayA[Project Relay A]
            relayB[Project Relay B]
        end
    end

    opencode[OpenCode server]
    state[Daemon config dir
    PID, socket, config, push settings]

    cli -->|foreground or IPC control| daemon
    browser -->|HTTP for SPA and APIs| server
    browser <-->|WebSocket messages| server
    daemon --> server
    server --> relayA
    server --> relayB
    relayA --> providers
    relayB --> providers
    providers <-->|REST, SSE, PTY upstream| opencode
    providers -->|stream events| persistence
    persistence --> server
    daemon <--> state