/

CrowdVision · source-available, not open source · © 2026 Nicolò Ghignatti

Chat Service Architecture

Bounded context: Knowledge & Assistance (shared with agent) · Stack: Rust / Axum / MongoDB · Code-level walkthrough: Chat Service

The chat owns conversations: it persists message history, enforces per-conversation limits, and forwards each question to agent for an answer. It holds no assistant logic itself — agent is stateless per request and never sees a conversation until chat sends it one.


Architectural Style

Ports & Adapters, the same shape as digital-twin and notification, enforced by tests/architecture_fitness.rs. The service has exactly two things outside itself — the conversation store and the agent — so it has exactly two driven ports. domain/ is pure; service/conversations.rs holds the use cases and depends only on ConversationStore and AgentClient; the adapters supply Mongo and the agent’s SSE stream.

graph TD
    subgraph "Driving adapter — adapters/driving/http_api"
        C["controllers · claims · exceptions\nSSE frame encoding"]
    end
    subgraph "Service — service/conversations.rs"
        UC["use cases: create · list · open · rename · delete · send_message"]
        P["ports: ConversationStore · AgentClient"]
    end
    subgraph "Domain — domain/"
        M["conversation · identity · error\nvalidation, history window, titling"]
    end
    subgraph "Driven adapters — adapters/driven"
        MONGO["persistence/conversations.rs"]
        AG["agent.rs — SSE client"]
    end
    C --> UC
    UC --> M
    UC --> P
    P -.->|"implemented by"| MONGO
    P -.->|"implemented by"| AG
    MONGO --> DB[(chat-db)]
    AG -->|"POST /ask stream=true, x-gateway-claims forwarded"| AGENT[agent]

Components & Connectors diagram

Chat Service C&C diagram

Key Architectural Decisions


Integration

For the conversation schema, the citation format, and the API, see the Chat Service internals page.