Skip to content

Component Diagrams

1. Deployment topology (docker-compose.yml)

The browser reaches ONLY nginx (web, host port 4173), which injects the operator bearer server-side; the API container publishes no host port. Providers-mock and Postgres publish ports for host-run tooling (demo driver, tests). The Langfuse stack is self-hosted and internal except its UI.

flowchart LR
    subgraph host["Host (browser / make demo / tests)"]
        B[Browser]
        CLI[demo driver + demo-verify<br/>host process]
    end
    subgraph compose["Docker Compose network"]
        W["web · nginx :4173→8080<br/>injects Authorization bearer<br/>serves the React build"]
        A["api · FastAPI :8000<br/>COMPOSE-PRIVATE<br/>bearer-auth on mutations"]
        P[("postgres:16 :15432<br/>app schema + langgraph schema")]
        M["providers-mock :8001<br/>ExactFlow · BudgetFlow · LegacyBatch<br/>x402 v2 paid endpoints"]
        subgraph lf["Langfuse stack (self-hosted)"]
            LW["langfuse-web :13000"]
            LK["langfuse-worker"]
            CH[("clickhouse")]
            R[("redis")]
            MIO[("minio")]
            LP[("langfuse-postgres :15433")]
        end
    end
    B -->|"HTTP (tokenless)"| W
    CLI -->|"/api via nginx :4173"| W
    W -->|"proxy + bearer"| A
    A --> P
    A -->|"paid audition HTTP"| M
    M -->|"payment-identifier replay store"| P
    M -->|"POST /mock-rain/authorize<br/>(merchant checkout, mock mode)"| A
    A -.->|"OTel spans"| LW
    LW --- LK --- CH
    LK --- R
    LK --- MIO
    LW --- LP

2. Backend layers and capabilities (matches the 7 import-linter contracts)

Arrows are real import directions. interfaces and infrastructure are independent siblings over application/domain; graph nodes import application only; domain imports stdlib only; sibling aggregates are independent (shared kernel via domain/shared).

flowchart TD
    subgraph interfaces["interfaces/"]
        API["api/ · routers + schemas + SSE + webhooks"]
        CLI2["cli/ · demo.py + verify.py"]
    end
    subgraph application["application/ (capabilities)"]
        PROC["procurement/<br/>compile_mandate · discover_providers<br/>plan_evidence · run_audition<br/>assess_quorum · select_provider<br/>create_mission"]
        PAY["payment/<br/>propose_payment · authorize_and_reserve<br/>prepare_rail · execute_payment<br/>confirm_settlement · reconcile_rail_status<br/>compensate · rail_strategies<br/>operation_leases · process_rain_webhook"]
        VER["verification/<br/>verify_outcome · remediate_outcome<br/>reconcile · record_injection_flags"]
        AG["agents/<br/>create_agent · generate_prompt_version<br/>activate_prompt_version · freeze_agent<br/>evaluation_job"]
        PORTS["ports/ · 50+ consumer-driven protocols<br/>(repositories per aggregate, query ports,<br/>rail/card/LLM ports, UnitOfWork views)"]
    end
    subgraph domain["domain/ (stdlib only)"]
        DM["mandate · budget · payment<br/>policy(+rules/) · evidence<br/>scoring · agents · shared"]
    end
    subgraph infrastructure["infrastructure/"]
        GR["graph/ · 21 thin nodes +<br/>routers · single_flight · savers"]
        DB["db/ · repositories · UoW · queries<br/>mission_idempotency · webhook_inbox<br/>reconciliation_jobs"]
        RX["rails/x402/ · exact-scheme engine<br/>facilitator ladder · payload store"]
        RR["rails/rain/ · mock issuer +<br/>live/ (Api-Key client · conformance-gated)"]
        LLM["llm/ · StructuredLLM · prompt_store<br/>evalrunner"]
        EV["events/ · LISTEN/NOTIFY broadcaster<br/>public projections"]
        JB["jobs/ · payment_recovery worker<br/>asyncio job runner"]
        TEL["telemetry/ · OTel + Langfuse + structlog"]
    end
    COMP["composition/ · settings · assembly · rails<br/>graph · queries · routes · lifecycle · demo"]

    API --> application
    CLI2 --> application
    application --> DM
    GR --> application
    DB --> application
    RX --> application
    RR --> application
    LLM --> application
    EV --> application
    JB --> application
    COMP --> interfaces
    COMP --> infrastructure
    COMP --> application