API layer
REST and server functions expose tickets, drafts, knowledge, analytics, health, and demo reset. Errors use a stable envelope with code, message, and request_id. Pagination is limit/offset on list endpoints in the production FastAPI service.
Background workers
Celery + Redis run extraction, chunking, embedding, reindex, draft generation, and retryable simulated delivery. The live preview runs the same stages in-process with explicit job states so a failed ingest keeps its reason.
PostgreSQL + pgvector
Tickets, documents, drafts, and audit events live in Postgres. Production stores chunk embeddings in pgvector; this preview uses a deterministic hash embedding stored as JSON so it runs without extensions.
Redis
Queue broker, rate-limit counters, and short-lived job state. Preview rate limits are an in-memory sliding window with the same error code.
Document storage
An object-storage abstraction accepts PDF, DOCX, TXT, Markdown, and HTML. Filename sanitization, MIME checks, and an 8 MB cap happen before extraction. Binary PDF/DOCX extractors are interfaces; the demo indexes text formats and records failed encrypted PDFs.
Model-provider abstraction
EmbeddingProvider and GenerationProvider sit behind sandbox implementations (hash embeddings + extractive drafting). Hosted adapters exist as types only and throw if constructed without credentials. Preview never calls a paid model.
Observability
Structured JSON logs, request IDs, audit events, document processing events, and safety events for prompt injection. Secrets and obvious credential patterns are redacted before log write.
Security controls
Untrusted customer text and indexed documents. Prompt-injection detection, HTML escaping, workspace isolation, role checks in the FastAPI artifact, citation validation, confidence thresholds, and a human approval gate before any send. Send is simulated in this workspace.