Skip to main content

Example: an AI document desk

Worked stack
Two applications, two models, one event stream

This is a stack the Stacktic team runs to test the platform and the MCP. A web application answers questions about the documents it stores, publishes an event for every document it ingests, and a nightly job writes a digest with the same self-hosted model. Every connection below is a link on its diagram; nothing was wired by hand.

WHO REACHES ITroute desklogin at the gatewaysignal-desk-clientKeycloak client7 more routesMCP · agent · Grafana · UIsAPPLICATIONSsignal-deskFastAPI · port 8080signal-digestPython · nightly jobDATA · EVENTS · AI ROUTESsignal-dbCloudNativePGdoc-ingestedKafka topicdocsQdrant collectionvalkeycacheai-chatAI gateway routeai-embedAI gateway routeMODELS · vLLMqwen3-8bchatbge-m3embeddingsOpen WebUI, Langflowuse qwen3-8b tooAROUND ITDELIVERYArgo CD21 ApplicationsReloaderOBSERVABILITYPrometheus12 scrape linksGrafana · Loki ← AlloySTORAGESeaweedFScnpg-backupsloki-logsOPERATIONSMCP serverstack agent · Argo CDLangflow · Valkey
The design of the AI document desk, read from the gateway to the models. Solid lines are signal-desk's links, dashed lines signal-digest's. Everything in the bottom band is generated around the same components from their own links.

The design​

22 components. Names are the ones on the diagram.

LayerCells
Applicationssignal-desk (external source code, FastAPI, port 8080) · signal-digest (external source code, Python, port 8080)
Who reaches themapisix with 8 routes · keycloak-operator with 3 clients: signal-desk-client, openwebui-client, and client for the MCP server
Data and eventscnpg with the databases signal-db and dagster-db · kafka with the topic doc-ingested · qdrant with the collection docs · valkey
Modelsvllm with two model sub-components, qwen3-8b and bge-m3 · two AI gateway sub-components on apisix, ai-chat and ai-embed · open-webui · langflow
Jobsdagster with the sensor doc-ingested-sensor and the job nightly-digest
Storageseaweedfs with the buckets cnpg-backups and loki-logs
Observabilityprometheus (12 scrape links) · grafana · loki · alloy
Deliveryargo-cd (21 links) · reloader · cert-manager
Operationsstack-agent · fastmcp

The application's code reads its configuration from environment variables. Every one of them comes from a link; none is typed by hand.

Link on the diagramIn signal-desk's environmentElsewhere in the stack
apisix-external_source_code, subdomain desk, apisix_oidc_enable on—The route desk.<domain> with TLS. Because login is on and the application links a Keycloak client, the route gets an openid-connect plugin built from that client: nobody reaches the application without signing in
external_source_code-client to signal-desk-clientOIDC_ISSUER_URL, OIDC_DISCOVERY_URL, OIDC_REALM, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_REDIRECT_URISThe client in Keycloak, created and kept in line by the Keycloak sync Job
external_source_code-db to signal-dbDATABASE_URL (the FastAPI form)The database and its user in the CloudNativePG cluster
external_source_code-topic to doc-ingestedKAFKA_BOOTSTRAP_SERVERS, KAFKA_TOPICS, KAFKA_SECURITY_PROTOCOL and the TLS file locationsWith the Kafka component's mtls on, a TLS user with ACLs per client and its certificate in the application's namespace. This stack runs with mtls off
external_source_code-collection to docsQDRANT_HOST, QDRANT_PORT, QDRANT_URL, QDRANT_COLLECTION, QDRANT_VECTOR_SIZEThe collection, created and reconciled by Qdrant's init Job from the sub-component
external_source_code-valkeyREDIS_URL— (the application uses it for its own rate limit and an answer cache)
external_source_code-ai_gateway to ai-chat and to ai-embedAI_GATEWAY_URL, AI_GATEWAY_MODEL, AI_GATEWAY_API_KEY, AI_GATEWAY_API_KEY_HEADER from the first link, and one complete set per gateway: AI_CHAT_AI_GATEWAY_* and AI_EMBED_AI_GATEWAY_*—
argo_cd-external_source_code—An Argo CD Application for the component

The per-gateway names are the gateway sub-component's name in upper case with dashes as underscores. An application with a single gateway link gets only the plain AI_GATEWAY_* set.

The models​

Each AI gateway sub-component is one route on the gateway to one served model:

Gateway routeLinkModelAlso used by
ai-chatai_gateway-modelqwen3-8bsignal-digest, Open WebUI (open_webui-model), Langflow (langflow-model)
ai-embedai_gateway-modelbge-m3—

The application only ever talks to the gateway, so the key stays server-side and the gateway applies its key auth, prompt guard and token budget — see Private AI.

The event chain​

The second application is started by events, not by a person.

signal-deskpublishesdoc-ingestedKafka topicsensorDagster · topic-sensornightly-digestDagster jobsignal-digestruns as a k8s jobexternal_source_code-topictopic-sensorsensor-jobjob-external_source_codesignal-dbtopic-db · Kafka Connect sink
Four links make the pipeline: no consumer code, no connector configuration and no scheduler wiring is written by hand.
LinkWhat it generates
external_source_code-topicsignal-desk's Kafka configuration, above; the application publishes an ingest event per document
topic-db (topic doc-ingested to database signal-db)A Kafka Connect cluster and a sink connector that writes every event into the database, with the statement in the link's sink_query attribute (here an audit table)
topic-sensor (topic to Dagster sensor)A Dagster sensor on that topic, generated with default_status=RUNNING, so it evaluates from the first daemon tick
sensor-job (sensor to job)The sensor starts nightly-digest
job-external_source_code (job to signal-digest)The job runs the signal-digest image as a Kubernetes job, in that component's namespace
dagster-dbDagster's own storage, in the database dagster-db

signal-digest then reads signal-db and calls ai-chat through its own two links. No consumer loop, connector definition or scheduler entry was written by hand.

Around it​

ConcernOn the diagramWhat it gives this stack
Deliveryargo-cd linked to 21 components · reloaderOne Application per component; a changed Secret or ConfigMap restarts the pods that read it. The applications have push_and_deploy on: the build Job rolls the Deployment onto the image it just pushed
ImagesStack configuration: BuildKit, cache_build onIn-cluster builds with a layer cache, so a code-only change reuses the dependency layers
Metricsprometheus linked to 12 components · grafana-prometheusScrape configuration, alert rules and dashboards for each linked component
Logsalloy-loki · grafana-loki · loki-swbucket to loki-logsLogs from every pod, stored in a bucket, queried in Grafana
Backupscnpg-swbucket to cnpg-backupsThe database's backups in a bucket
Operationsfastmcp linked to client, argo-cd, stack-agent, valkey, langflowAn MCP server behind Keycloak login, with Argo CD runtime tools, the stack agent's scans, persistent OAuth client storage and Langflow flow tools
Validationstack-agent, deploy_access onLink tests for every link above; a deploy arm that applies committed branches

Security in this stack​

LayerSetting
LoginThe application route requires a Keycloak login, built from the client link
WorkloadBoth applications carry pod_security, drop_capabilities, no_privilege_escalation, read_only_fs and seccomp
Buildbuild_gate set to enforce: a source scan finding blocks the build; sast_gate off
NetworkThe standard generated network policies (the stack's microsegmentation_level is not set, which means the standard set)

How it was built​

The application code lives on the stack repository's build branch under apps/signal-desk and apps/signal-digest. It was written and committed there by the MCP server, each commit signed "Stacktic MCP". The generated files come from the platform's branch and are merged in on every build — see The stack repository.

→ How a stack fits together · A secured marketplace