NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior2 views

Design an architecture for an enterprise GPT (a chat with an LLM and document uploads for RAG) for 5,000 users per week.

Practice

AI answer

For 5,000 users per week, I wouldn’t choose capacity based only on the number of accounts: first, I’d estimate peak concurrency, requests per minute, document sizes, SLAs, and data residency requirements. The architecture can be divided into the following components:

  • Web client and API gateway: authentication through corporate SSO, rate limiting, request routing, and access-control checks.
  • Chat service: a stateless application behind a load balancer; conversation history and settings stored in a relational database. Stream responses using SSE or WebSocket.
  • Document upload service: accepts files, validates their type and size, stores the originals in object storage, and enqueues a processing task. Asynchronous workers extract text, perform OCR if needed, clean and split the text into chunks, and generate embeddings.
  • RAG search: a vector store with metadata and filtering by tenant, user, and ACL; hybrid vector and full-text search if needed. Permissions must be applied when retrieving candidates, not only afterward.
  • Response orchestration: context and limit checks, retrieval, prompt assembly with the retrieved chunks, a call to a corporate or external LLM, and returning the response with citations. Use a queue for long-running tasks; regular chat is better handled synchronously with streaming output.
  • Storage and operations: object storage for files, a database for users and metadata, a queue for background tasks, secrets in a secrets manager, metrics/logs/traces, and an audit trail of actions.

Services should run in Kubernetes with horizontal scaling based on CPU, memory, and application metrics such as queue length and the number of active requests. The external LLM and vector store should be treated as dependencies with timeouts, bounded retries, and a circuit breaker. Limits are needed for file size and count, along with token cost controls, encryption, retention policies, and data deletion. Load testing against expected peaks should be conducted before choosing the number of replicas and the database.