/

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

Chat

Keywords on this page
WordMeaningExample
ConversationOne person’s thread of questions and answers“Library heating”
ExchangeOne question and its answer“Is room 2 hot?” and the reply
History windowThe last messages sent along with a new questionLast 10
SSEServer-Sent Events: the answer arrives word by word on one open responseText appearing as it is written
FrameOne piece of that streamA word, or “done”

Realises the Knowledge & Assistance domain, with agent. Rust, MongoDB. Code-level page: Chat Service.

chat remembers conversations. agent answers one question at a time and remembers nothing. Together they make a conversation.


Who talks to it

flowchart LR
    C["client"] -- "conversations, questions" --> Ch["chat"]
    Ch -- "question, history, same claims" --> A["agent"]
    Ch --> DB[("MongoDB")]

Inside

flowchart LR
    H["HTTP, and the stream"] --> UC["Use cases: create, list, open, rename, delete, ask"]
    UC --> D["Rules: limits, history, titles"]
    UC --> P["Ports: store, assistant"]
    P -.-> M["MongoDB"]
    P -.-> AG["agent, streamed"]

Two things outside, so two ports. A test fails the build if a layer imports the wrong way.


Asking a question

sequenceDiagram
    participant C as client
    participant Ch as chat
    participant A as agent
    C->>Ch: question
    Note over Ch: owner? limits? room left?
    Ch->>A: question and last 10 messages
    A-->>Ch: words, as written
    Ch-->>C: words, as written
    A-->>Ch: done, final answer
    Note over Ch: save the exchange now
    Ch-->>C: done, with the saved message
RuleWhy
Only the last 10 messages go alongA long conversation does not grow the cost of each question
Stream, do not waitThe first words show in milliseconds, not seconds
Save only at the endA broken answer leaves no half message behind
Forward the same claimsagent acts with the person’s own rights, no more

Errors depend on timing. Before the first word: a normal error status, like 404. After: the status line is already sent as 200, so the error comes as a last frame.


Limits

WhatLimit
Messages per conversation100
Characters per message8000
Characters per title120

Checked before anything is saved.