Markdown Editor

LLM Chat Assistant System Design Template

Chat assistant app layer: resumable SSE streaming, conversation store, context budget and summaries, uploads, tools, moderation, rate limits, residency

सिस्टम डिज़ाइनपूर्णWHATWG SSE; RFC 9457; GDPR Ch. V, Art. 17, 25; EU AI Act Art. 50designllmchatassistant
एडिटर में खोलें.md डाउनलोड करें

उपयोग कैसे करें: Use it when you design the product layer of a ChatGPT-style assistant on top of an existing model platform. Fill the user, message and context-length estimates (3.1 to 3.3) and the home-region rule first. The main pitfall is tying generation to the client connection: decouple them and resume streams by event ID.

प्रीव्यू

System Design: [Chat assistant name]

Reference design for the application layer of a consumer or workplace chat assistant in the style of the well-known general-purpose AI chat products: token streaming over server-sent events or WebSocket, the conversation store, context window management and summarisation, file uploads, tool use, moderation, rate limits and abuse prevention, opt-in memory and regional data residency. Model serving is out of scope and covered by the LLM Inference Serving and Vector Search Platform Design Template (system-design/design-llm-inference-serving); provider routing by the LLM Gateway System Design Template (system-design/design-llm-gateway). It follows the 12-section structure of the System Design Document Template (system-design/system-design-document) and is pre-filled with a worked design to adapt. Replace every [bracketed] value and every row marked Example; all numbers are illustrative, not benchmarks. Where it mentions laws, this is a documentation format, not legal advice.

Document control

FieldValue
Document ID[SDD-CAS-001]
System / feature[Chat assistant application layer]
Version[0.1]
Status[Draft / In review / Approved / Implemented / Superseded]
Owner[@owner]
Approvers / reviewers[@reviewer-1], [@reviewer-2]
Last updatedYYYY-MM-DD
Classification[Internal]
Markets and data regions[EU, US, other]
Model access[LLM gateway aliases used]
Related[LLM gateway design], [Guardrails spec], [DPIA], [Observability spec]

Approvals

RoleNameDecisionDate
Tech lead, assistant[@name][Approved / Changes requested]YYYY-MM-DD
Staff / principal engineer[@name][Decision]YYYY-MM-DD
Privacy / data protection officer[@name][Decision]YYYY-MM-DD
Trust and safety[@name][Decision]YYYY-MM-DD
SRE / operations[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft for design review
0.2YYYY-MM-DD[@name]Example: Made streams resumable after disconnect
0.3YYYY-MM-DD[@name]Example: Added EU data region and per-region conversation stores
1.0YYYY-MM-DD[@name]Example: Approved

Contents

1. Overview

1.1 Problem statement

[Example: The current assistant is a prototype: each message opens a WebSocket, the server calls the model and forwards tokens. When a phone switches networks the answer is lost and the user is charged a message against their limit. Conversations are sent whole to the model, so long threads hit the context limit and fail. Uploaded files sit in one bucket in one region. Business customers in the EU require their data to stay in the EU, and the product has no way to honour deletion requests across logs and caches.]

1.2 Proposed solution

[Example: A regional chat service that owns conversations and the turn loop. Each user turn becomes a generation job; the generator streams tokens into a short-lived per-turn stream buffer, and clients read it over server-sent events, reconnecting with the last event ID. A context builder assembles each prompt within a token budget: system instructions, a rolling summary of older turns, the most recent turns verbatim, retrieved memory (only if the user turned memory on) and file excerpts. Moderation runs on input and on streamed output. Rate limits apply per user, per plan and per abuse signal. Every user is homed in one data region; conversations, files, memory and logs stay in that region.]

1.3 Decisions requested from reviewers

IDQuestionRecommended optionSection
Q-01Example: Streaming transport?SSE over HTTP/2 with resumable per-turn buffers; WebSocket only for voice7.2
Q-02Example: Long conversations?Rolling summary plus recent turns within a token budget7.3
Q-03Example: Memory?Off by default; user-visible and editable; per-region store7.5
Q-04Example: Output moderation?Classify every 200 tokens (Example) and at the end; stop the stream on a block7.4
Q-05Example: Residency?Home region per user or workspace; no cross-region replication of content7.5
[Q-nn][Question][Option][Section]

1.4 45-minute interview path

MinutesTopicWhat to show
0 to 5ScopeApplication layer only; model serving below the line
5 to 10RequirementsCore list (2.1), time to first token and availability (2.2), below the line (2.3)
10 to 15EstimatesConcurrent streams, tokens per day, storage (3.2 to 3.5) with consequences
15 to 20APISend a message, stream events, resume (4)
20 to 28Data and high-level designAccess patterns (5.2), diagram (6)
28 to 40One deep diveResumable streaming (7.2) or context management (7.3); moderation and abuse (7.4) for trust and safety interviews
40 to 45Wrap-upFailure modes (9.1), 10x row (10)

2. Requirements

2.1 Core functional requirements

IDRequirementPriority
FR-01Example: Send a message and receive the answer as a token streamMust
FR-02Example: Resume an interrupted stream without regenerating the answerMust
FR-03Example: List, open, rename, search and delete conversationsMust
FR-04Example: Regenerate and edit a previous message, keeping branchesShould
FR-05Example: Upload files (documents, images) and ask about themMust
FR-06Example: Tool use: web search, code execution, and workspace connectorsShould
FR-07Example: Moderation of input and output with user-facing explanationsMust
FR-08Example: Rate limits per plan with clear messages and reset timesMust
FR-09Example: Opt-in memory that the user can view, edit and clearShould
FR-10Example: Data export and deletion per user and per workspaceMust
FR-11Example: Tell users they are interacting with an AI system where that is not obviousMust
[FR-nn][Requirement][Must / Should / Could]

2.2 Non-functional requirements

IDQualityTargetMeasured as
NFR-01Time to first tokenExample: p95 at or below 1.5 s from send to first token on screen, excluding tool callsClient timing
NFR-02Stream continuityExample: 99.9% of streams complete or resume after a disconnectClient telemetry
NFR-03AvailabilityExample: 99.9% monthly for send and streamSLO on turn completion
NFR-04Conversation loadExample: p95 at or below 300 ms to open a conversation of 200 messagesServer timing
NFR-05DeletionExample: User deletion completed across stores, caches and logs within 30 daysDeletion audit
NFR-06ResidencyExample: No user content stored or processed outside the home region, except with explicit transfer basisData-flow audit
NFR-07Moderation latencyExample: Input check p95 at or below 150 msSpan timing
[NFR-nn][Quality][Target][Measurement]

2.3 Below the line (out of scope)

  • [Example: Model serving, batching and GPUs (see LLM Inference Serving and Vector Search Platform Design Template (system-design/design-llm-inference-serving))]
  • [Example: Provider routing, quotas towards providers and redaction (see LLM Gateway System Design Template (system-design/design-llm-gateway))]
  • [Example: Running user or model code (see Agent Code Execution Sandbox System Design Template (system-design/design-agent-sandbox-execution))]
  • [Example: Long-running autonomous agents (see Agent Orchestration Platform System Design Template (system-design/design-agent-orchestration-platform))]
  • [Example: Billing and subscription management]
  • [Item deferred, with the release that will take it]

3. Capacity estimation

3.1 Assumptions

All values are Example planning inputs.

InputValueSource
Daily active users5 millionGrowth plan
Messages per user per day6Beta cohort
Peak-to-average ratio3Hourly pattern
Mean answer length400 tokensBeta cohort
Mean stream duration12 sBeta cohort
Mean prompt assembled per turn6,000 tokens (system 1,500; history 3,500; memory and files 1,000)Context builder logs
Stored size per exchange (message and answer)3 KBSchema
Messages with a file3%, mean 2 MBBeta cohort
Streams per edge node2,500Load test
Internal cost, inputUSD 0.50 per million tokensGateway metering
Internal cost, outputUSD 2 per million tokensGateway metering

3.2 Traffic and streams

QuantityCalculationResultConsequence
Messages per day5 million x 630 million
Average messages per second30,000,000 / 86,400about 347
Peak messages per second347 x 3about 1,042Turn admission, moderation and rate-limit checks must handle about 1,050 per second
Peak concurrent streams1,042 x 12 sabout 12,500Edge sized for open streams, not requests
Edge nodes12,500 / 2,500 = 5 at full load; 9 across 3 zones9 nodesLosing one zone leaves 6 nodes (15,000 streams), about 83% load

3.3 Tokens and model cost

QuantityCalculationResultConsequence
Input tokens per day30 million x 6,000180 billion
Input cost per day180,000 x USD 0.50USD 90,000Input dominates; context size is the first cost lever
Output tokens per day30 million x 40012 billion
Output cost per day12,000 x USD 2USD 24,000
Saving from summarising history (3,500 to 2,000 tokens)1,500 x 30 million = 45 billion tokensUSD 22,500 per daySummarisation pays for itself if it costs well under that; run it every 10 turns, not every turn

Keep the system prompt and tool definitions at the start of the prompt and unchanged between turns, so provider or engine prefix caching can reuse them.

3.4 Storage

QuantityCalculationResultConsequence
Conversation data per day30 million x 3 KB90 GB
Conversation data per year90 GB x 365about 32.9 TBPartition by user ID; move conversations untouched for 90 days to a cheaper tier
Files per day30 million x 3%900,000
File bytes per day900,000 x 2 MB1.8 TBUploads go straight to object storage with pre-signed URLs, never through the chat service
File bytes, 90-day retention1.8 TB x 90162 TBFile retention shorter than conversation retention, with clear notice to users

3.5 Moderation and summarisation calls

QuantityCalculationResultConsequence
Input moderation per day30 million30 millionFast classifier, not a large model
Output moderation checks per day30 million x (400 / 200)60 millionBatched per stream chunk; budget in 8
Summarisation calls per dayOne per 10 turns: 30 million / 103 millionAsynchronous, off the turn path

3.6 Summary

QuantityEstimateDesign consequence
Peak streamsabout 12,5009 edge nodes across 3 zones; scale on open streams
Input tokens180 billion per dayToken budget per turn; rolling summary; stable prefix
Conversationsabout 33 TB per yearUser-partitioned store with tiering
Files1.8 TB per dayDirect-to-storage upload, async processing, 90-day retention
Moderationabout 90 million checks per dayDedicated classifier pool

4. API design

4.1 Endpoints

Method and pathPurpose
POST /v1/conversationsCreate a conversation
GET /v1/conversations?cursor=List conversations, newest first
GET /v1/conversations/{id}/messages?cursor=Page through messages, including branches
POST /v1/conversations/{id}/turnsSend a user message; returns turn_id and stream URL; Idempotency-Key required
GET /v1/turns/{turn_id}/streamSSE stream of the answer; honours Last-Event-ID
POST /v1/turns/{turn_id}/stopStop generation
POST /v1/uploadsGet a pre-signed upload URL and a file ID
GET /v1/memory, DELETE /v1/memory/{item}View and remove memory items
POST /v1/export, DELETE /v1/account/dataData export and deletion

4.2 Stream format

The stream uses text/event-stream (WHATWG HTML Living Standard section 9.2). Each event has an id equal to its sequence number in the turn, so a client that reconnects with Last-Event-ID: 41 receives events from 42 onward.

id: 1
event: turn.started
data: {"turn_id": "t_9f2", "model_alias": "chat-default"}

id: 2
event: token
data: {"text": "Here is"}

id: 3
event: tool.call
data: {"tool": "web_search", "status": "running"}

id: 58
event: turn.completed
data: {"finish_reason": "stop", "output_tokens": 412}

4.3 Errors

StatusProblem typeMeaning
400message-too-longMessage above the plan's input limit
409turn-in-progressAnother turn is generating in this conversation
413file-too-largeUpload above the plan's limit
422content-blockedInput blocked by moderation; category given
429rate-limitedPlan or abuse limit reached; reset time given
451region-unavailableFeature not offered in the user's region

Errors use RFC 9457 problem details. A retried POST /turns with the same Idempotency-Key returns the existing turn, so a flaky network does not create two answers or count twice against the limit.

5. Data model

5.1 Entities

A conversation is a tree of messages (edits and regenerations create branches); the client shows one path through it.

5.2 Access patterns

IDQueryKey or index that serves itPartition key and rationale
AP-01 (Example)List a user's conversations, newest first(user_id, updated_at desc)user_id: one user's data together; also the unit of deletion and residency
AP-02 (Example)Load the last 50 messages of a conversation(conversation_id, created_at desc)Clustered under the user partition
AP-03 (Example)Build the context for a turnSummary by conversation_id plus messages after covers_until_messageTwo reads, both on the same partition
AP-04 (Example)Resume a streamTurn stream buffer by turn_id, entries after Last-Event-IDIn-memory store with TTL of 10 min
AP-05 (Example)Search a user's conversationsPer-region search index filtered by user_idIndex never shared across regions
AP-06 (Example)Retrieve relevant memoryVector index per region, filter user_idOnly if memory_enabled
AP-07 (Example)Delete everything for a userPartition drop by user_id plus deletion jobs for index, files, logsDeletion follows the partition key

5.3 Storage choices

DataStoreNotes
Users, plans, settingsRelational database per regionSmall
Conversations and messagesWide-column or document store per region, partitioned by userTiering after 90 days
Turn stream buffersIn-memory store per region, TTL 10 minLost buffers fall back to the stored message
FilesObject storage per region, encryptedExtracted text stored next to the file
Search and memory indexesPer-region search and vector indexesRebuildable from the source stores
Abuse signalsPer-region store with short retentionFeeds rate limits

6. High-level design

ComponentResponsibilityScales by
EdgeAuth, home-region routing, SSE delivery from buffersOpen streams
Chat serviceTurn admission, idempotency, conversation CRUDRequests per second
Context builderToken-budgeted prompt assemblyTurns per second
Generator workersCall the gateway, run tools, write tokens to the buffer, store the answerConcurrent generations
Moderation serviceInput and output classifiersChecks per second
File processorMalware scan, type checks, text extraction, chunkingUploads per second
SummariserRolling summaries off the turn pathBackground queue

7. Detailed design

7.1 Turn flow

The send request returns as soon as the turn is admitted; the answer arrives on a separate stream that the client can reopen at any time.

7.2 Deep dive 1: resumable token streaming

OptionStrengthsWeaknesses
A. Generation tied to the client connectionSimpleA dropped connection loses the answer and its cost
B. SSE over HTTP/2, generation decoupled, per-turn buffer, resume by Last-Event-IDWorks through proxies and CDNs; built-in reconnection semantics; one-way fits the use caseNeeds a buffer store; client sends input over separate requests
C. WebSocket for everythingTwo-way; good for voice and live collaborationHarder through some proxies; resumption must be designed from scratch; sticky connections

Choice: B for text chat; C only for voice sessions.

Reason: the answer is a one-way stream and the main failure is mobile disconnects. SSE carries an event ID per event, and browsers resend the last one on reconnection, so resumption needs only a buffer keyed by turn and sequence. Stopping generation is a separate POST /stop.

Rules:

  • The buffer keeps a turn's events for 10 minutes (Example) after completion; later reconnects read the stored message instead.
  • If the user does not reconnect, generation still completes and the answer is stored; it counts against the plan once.
  • Send a comment line every 15 s (Example) to keep idle proxies from closing the stream during tool calls.

7.3 Deep dive 2: context window management

OptionStrengthsWeaknesses
A. Send the whole conversationExactFails past the context limit; cost grows with every turn
B. Last N turns onlyCheap, predictableForgets early facts the user still refers to
C. Rolling summary of older turns plus recent turns verbatim, within a token budgetBounded cost; keeps key factsSummaries can drop or distort details
D. Retrieval over the conversation historyFinds old details on demandRetrieval misses; extra latency

Choice: C by default, with D added for conversations longer than the summary horizon.

Reason: input tokens dominate cost (3.3), and the context limit is a hard failure. A budget allocator assigns each part a maximum and fills in order of priority. The Example budgets below total 4,500 input tokens: the 6,000 of 3.1 minus the 1,500 that summarisation saves in 3.3 (history 3,500 down to 2,000 as summary plus recent turns; memory and files stay at 1,000).

PartExample budgetRule
System prompt and tool definitions1,500 tokensFixed, first, unchanged between turns (prefix caching)
Rolling summary600 tokensRegenerated every 10 turns by the summariser
Recent turns1,400 tokensNewest first until the budget is used
Memory items300 tokensOnly if memory is on; most relevant first
File excerpts700 tokensChunks retrieved for this question
Reserved for the answermax_tokensNever squeezed by the parts above

The summariser keeps names, numbers, decisions and open questions, and marks which message it covers up to, so it can be rebuilt after an edit.

How real systems do it: MemGPT virtual context management (paraphrased)

The MemGPT paper treats the model's context window like the main memory of an operating system. A small, fixed working context holds the system instructions and the most relevant facts; older conversation and documents sit in external storage, and the model is given functions to search that storage and to move information in and out of its working context, much like paging. The authors evaluate the approach on analysis of documents larger than the context window and on multi-session chat where the agent must remember earlier sessions. Source: Packer et al., "MemGPT: Towards LLMs as Operating Systems", arXiv:2310.08560 (2023, revised 2024). This box summarises the idea; read the paper for details.

7.4 Deep dive 3: moderation, rate limits and abuse

OptionStrengthsWeaknesses
A. Moderate input onlyCheap, adds no output latencyMisses harmful outputs from benign-looking prompts
B. Input plus output checked every N tokens while streaming, with a final checkCatches problems early; stops the streamAdds cost; must retract text already shown
C. Output checked only after completionSimpleUser sees the content before the block

Choice: B. Input is checked before the turn is queued; output is checked every 200 tokens (Example) and at the end; a block stops generation, replaces the shown text with a notice and records the category.

Rate limits are layered:

LayerExample rulePurpose
PlanFree: 40 messages per 3 h; paid: higherCost control and fairness
Burst5 turns per 10 s per userScripts and accidental loops
Abuse scoreLower limits for new accounts, failed payment, repeated blocksAbuse at scale
Account creationProof of work or challenge after signalsSign-up fraud
Tool useSeparate limits for expensive toolsCost per tool

Limits use the counters described in Rate Limiter System Design Template (system-design/design-rate-limiter). Moderation categories and thresholds belong in the Guardrails and Safety Filter Specification Template (ai-data/guardrails-spec).

7.5 Deep dive 4: memory opt-in and regional data residency

OptionStrengthsWeaknesses
A. One global store, replicatedSimple operationsContent leaves the user's region
B. Home region per user or workspace; all content stores regional; only routing metadata globalResidency by design; deletion by partitionCross-region features (shared links across regions) need explicit design
C. Encrypt globally replicated data with regional keysSome residency argumentsData still stored abroad; key management complexity

Choice: B. The global directory maps user ID to home region and holds no content. Model calls go to gateway routes approved for that region.

Reason: NFR-06 and deletion (NFR-05) are both easiest when the partition key, the region and the deletion unit are the same thing: the user or workspace.

Memory rules:

  • Off by default; when on, the assistant shows what it saved and the user can edit or delete each item, or clear all.
  • Memory items keep a link to the source message; deleting the conversation offers to delete derived memory.
  • Memory is never used to train models unless the user separately agreed.
  • Text that came from files, web results or tool output is never saved to memory without the user confirming it, so an injected instruction cannot persist into later conversations.

Legal pointers (this is a documentation format, not legal advice; check the consolidated texts): under the EU GDPR (Regulation (EU) 2016/679), Chapter V (Articles 44 to 50) governs transfers of personal data to third countries, Article 17 covers erasure and Article 25 covers data protection by design and by default. Under the EU AI Act (Regulation (EU) 2024/1689, as amended), Article 50(1) requires providers to design systems that interact directly with people so that people are informed they are dealing with an AI system unless that is obvious; check the consolidated text for application dates. Record the analysis with the Data Protection Impact Assessment (DPIA) Template (compliance/dpia).

7.6 File uploads and tool use

  • Uploads go directly to regional object storage with a pre-signed URL; the file processor scans for malware, checks the declared type against the content, extracts text and chunks it. The turn waits until the file is ready or fails with a clear message.
  • File content is untrusted input to the model: instructions inside files are treated as data, and the guardrail input checks run on extracted text.
  • Tools run through a tool runner with per-plan limits; code execution goes to the sandbox service described in Agent Code Execution Sandbox System Design Template (system-design/design-agent-sandbox-execution).
  • Tool progress is streamed as tool.call events so users see why the answer is waiting.

8. Scalability and performance

ConcernApproachLimit before redesign
Open streamsEdge reads from buffers; scale on open streamsBuffer store throughput per region
Hot conversationsPartition by user; conversations are per userShared workspace conversations with many readers
Context buildingTwo partition-local reads plus optional retrievalRetrieval latency for long histories
ModerationDedicated classifier pool, batched output checksClassifier throughput at peak
Model capacityGateway quotas per regionProvider capacity in a region

Time to first token budget (NFR-01, p95 1.5 s):

StepBudget
Admission, rate limit, idempotency30 ms
Input moderation150 ms
Context building120 ms
Gateway and model time to first token1,000 ms
Buffer and edge delivery50 ms
Headroom150 ms

9. Reliability, security and operations

9.1 Failure modes

IDComponentFailureDetectionBlast radiusMitigationRTO
FM-01Edge nodeCrashHealth checksStreams on that nodeClients reconnect to another node and resume from the bufferUnder 10 s
FM-02Stream bufferData lostMissing sequence on resumeIn-flight turnsFall back to the stored message when complete; otherwise offer regenerate without charge1 min
FM-03GeneratorCrash mid-answerTurn heartbeat timeoutTurns on that workerMark turn failed, no charge, offer regenerate30 s
FM-04LLM gateway or providerOutageError rateAll turns in regionGateway fallback chain; degraded-mode bannerGateway RTO
FM-05Moderation poolDownError rateAll turnsFail closed for input on free plans; fall back to a smaller local classifier5 min
FM-06Conversation storePartition unavailableRead errorsUsers on that partitionReplicas within region; read-only mode15 min
[FM-nn][Component][Failure][Signal][Scope][Mitigation][Time]

9.2 Security and privacy

IDThreatControl
SEC-01Prompt injection through files, web results, connector or other tool outputTreat all of it as untrusted data, never as instructions; no memory writes from it without user confirmation; guardrail checks; tool permissions per plan
SEC-02Cross-user data exposureUser ID in every key and index filter; tests for authorisation on every endpoint
SEC-03Hidden instructions or system prompt revealedKeep secrets out of prompts; output checks for canary strings
SEC-04Abuse at scale (spam, scraping, fraud)Layered limits (7.4), challenges, abuse scoring
SEC-05Malicious uploadsMalware scan, type checks, no execution of uploads outside the sandbox
SEC-06Insider access to conversationsAccess only through audited support tooling with user consent
[SEC-nn][Threat][Control]

Map the application threats to the OWASP Top 10 for LLM Applications (2026 edition) with the Threat Model Template (security/threat-model) and the Privacy Threat Model Template (security/privacy-threat-model).

9.3 Observability

SignalMetricAlert threshold
Time to first tokenp95 by region and model aliasAbove 1.5 s for 10 min
Stream completionCompleted or resumed over startedBelow 99.9%
Resume rateReconnects per 100 turnsSudden rise (network or edge issue)
Moderation blocksRate by categorySpike after a model change
Rate-limit hitsPer planRise after a pricing change
Deletion backlogPending deletion jobs by ageAny older than 25 days

Model call spans follow the LLM and Agent Observability Specification Template (ai-data/llm-observability-spec); do not record message content on spans by default.

9.4 Cost estimate

ItemUnit costQuantityMonthly cost
Model input tokensUSD 0.50 per million (Example)180 billion per day x 30about USD 2.7 million
Model output tokensUSD 2 per million (Example)12 billion per day x 30about USD 720,000
Edge and chat services[USD per node-month][Nodes][USD]
Conversation and file storage[USD per TB-month]about 33 TB per year plus 162 TB of files[USD]
Moderation pool[USD per node-month][Nodes][USD]
Total[USD]

10. Trade-offs and alternatives

DecisionOptionsChosenWhyWhat we give up
StreamingSSE; WebSocketSSE with resumable buffersOne-way stream, standard reconnectionSeparate requests for input
ContextFull; last N; summary; retrievalSummary plus recent, retrieval for long threadsBounded cost and latencySummary errors
Output moderationNone; streaming; after completionStreaming checksStop harm earlyCost and occasional retraction
ResidencyGlobal; regional; encrypted globalRegional by home regionResidency and deletion by designCross-region features
MemoryAlways on; opt-inOpt-in, visible, editableUser trust and privacyPersonalisation for users who do not opt in
What changes at 10x (50 million daily users, about 125,000 peak streams)Edge per region in more locations; buffer store sharded by turn ID; summarisation and retrieval mandatory for all long conversations; per-region model capacity contractsInput tokens (about 1.8 trillion per day) and open streams set the limitsHigher fixed cost and more regions to operate
What changes at 0.1x (500,000 daily users, about 1,250 peak streams)One region per market; managed SSE edge; last-N context may be enough; moderation through the provider's endpointFixed cost of own buffers and classifier pool is not justifiedLess control over moderation and stream resumption
[Decision][Options][Chosen][Why][Cost]

11. Delivery plan and risks

11.1 Milestones

MilestoneScopeExit criterionTarget date
M1Turn loop, SSE with resumable buffers, conversation storeNFR-01 and NFR-02 in load test with simulated disconnectsYYYY-MM-DD
M2Context builder and summariserLong-conversation evaluation shows no loss of key facts above the agreed rateYYYY-MM-DD
M3Moderation and layered rate limitsRed-team run passes; abuse simulation stays within limitsYYYY-MM-DD
M4Files and toolsMalware and type checks on a test corpusYYYY-MM-DD
M5EU region, memory opt-in, export and deletionResidency and deletion audits pass (NFR-05, NFR-06)YYYY-MM-DD

11.2 Rollout and rollback

[Example: New stack behind a flag for 1%, 10%, 50% and 100% of users; the prototype path stays for 2 weeks. Model alias changes roll out by region with evaluation gates and instant rollback.]

11.3 Risks

IDRiskLikelihoodImpactMitigationOwner
R-01Example: Summaries lose facts users rely onMediumMediumEvaluation set of long conversations; retrieval fallback[@name]
R-02Example: Regional model capacity insufficientMediumHighContracts per region; graceful queueing[@name]
R-03Example: Deletion misses derived data (indexes, logs)MediumHighDeletion inventory per store; audits[@name]
R-04Example: Abuse waves on free planHighMediumAbuse scoring, challenges, rapid limit changes[@name]
[R-nn][Risk][L / M / H][L / M / H][Mitigation][@name]

12. Appendices

12.1 Traceability

RequirementDesign elementVerification
FR-01, FR-02, NFR-027.2 resumable streamingDisconnect simulation
NFR-018 latency budgetClient timing
FR-077.4 moderationRed-team and category tests
FR-087.4 layered limitsAbuse simulation
FR-09, FR-10, NFR-05, NFR-067.5 memory and residencyDeletion and data-flow audits
[ID][Element][Test]

12.2 Open questions

IDQuestionOwnerDue
OQ-01Example: Do shared conversation links work across regions?[@name]YYYY-MM-DD
OQ-02Example: Retention for files versus conversations for business plans?[@name]YYYY-MM-DD
[OQ-nn][Question][@name]YYYY-MM-DD

12.3 Glossary

TermMeaning
TurnOne user message and the assistant's answer to it
Stream bufferShort-lived store of a turn's events, used for resumption
Rolling summaryPeriodically regenerated summary of older turns
Token budgetMaximum tokens assigned to each part of the prompt
Home regionRegion where a user's or workspace's content is stored and processed
MemoryFacts the assistant keeps across conversations, with user consent

12.4 References

ReferenceUse
WHATWG HTML Living Standard, section 9.2 Server-sent events, https://html.spec.whatwg.org/multipage/server-sent-events.htmlStreaming in 4.2 and 7.2
RFC 6455, The WebSocket Protocol (2011)Voice sessions in 7.2
RFC 9457, Problem Details for HTTP APIs (2023)Errors in 4.3
Packer et al., "MemGPT: Towards LLMs as Operating Systems", arXiv:2310.08560Box in 7.3 (paraphrased)
Regulation (EU) 2016/679 (GDPR), Chapter V, Articles 17 and 25, https://eur-lex.europa.eu/eli/reg/2016/679/ojResidency and deletion pointers in 7.5
Regulation (EU) 2024/1689 (AI Act), Article 50, consolidated text on EUR-LexAI interaction notice (FR-11)
OWASP Top 10 for LLM Applications, 2026 edition, https://genai.owasp.org/ (CC BY-SA 4.0)Threat mapping in 9.2
LLM Gateway System Design Template (system-design/design-llm-gateway)Model access
Chat System Design Template (system-design/design-chat-system)Messaging patterns for human-to-human chat
Guardrails and Safety Filter Specification Template (ai-data/guardrails-spec)Moderation policy

Standard and licence note

Based on the WHATWG HTML Living Standard (server-sent events), RFC 6455, RFC 9457 and public EU law (Regulation (EU) 2016/679 and Regulation (EU) 2024/1689), cited by article and paraphrased; this is a documentation format, not legal advice. OWASP list names are attributed to the OWASP GenAI Security Project under CC BY-SA 4.0, and any adapted OWASP material you redistribute must carry the same licence under its ShareAlike term. The research in 7.3 is paraphrased and cited as inspiration only. The text is original; check the current official version of each source, and the consolidated legal texts, before approval. Template licence: MIT.

संबंधित टेम्पलेट