Language and servicesPython 3.12, fully asynchronous. Two services: the gateway on FastAPI, the Telegram bot on aiogram 3. A monorepo with a shared deploy.
DataPostgreSQL 16 (Supabase), accessed via asyncpg, pgvector for semantic search. Schema and migrations by hand, no ORM: all SQL is written explicitly.
LLM layerLangGraph (the dialogue graph plus state persistence), LangChain (the model client), langmem (rolling summary and long-term memory), trustcall + Pydantic (structured output with validation).
ModelsOpenRouter as the single access point: switching models is a setting, not code. Separate models for replies, for the internal compression, and for embeddings.
BillingA custom Reserve & Settle on Postgres transactions: holds, idempotency by a unique key, two-level balances, a spend log labelled by call type.
InterfaceAn admin panel on Jinja2 + HTMX — no separate frontend project. Sessions, CSRF, invitations, separation of the superadmin from the clients.
ObservabilityLangSmith (EU instance): the full chain of every model call, including the background memory passes. Metrics and alerts are planned.
Testspytest + testcontainers (a real Postgres per run), respx for intercepting HTTP, canary tests on third-party library behaviour, a live bot run in Telegram after the rollout.
OperationsDocker + docker compose, GitLab CI (lint → secret scan → deploy), automatic migrations before the code, a healthcheck with rollback, verification of the commit stamp in the image.