Babylon 2k
Expanded review: Observability, messaging, admin management and the living knowledge loop. This review refines the initial stack and explains ownership boundaries.
Proposed architecture · 6 October 2026

The engines behind Beth

Use Langflow to design the AI steps, Temporal to keep work recoverable, and PostgreSQL to preserve the records. CopilotKit and AG-UI bring the results into Beth’s chat. Redis supports shared workers. The current lean scope selects LiteLLM and OpenConnector, while n8n remains deferred.

This is a planning diagram. These engines have not been installed in the current demo, and the current scope includes the remaining custom integration work; expanded reference diagrams do not override the lean rollout.

Current selection: OpenConnector for external tools

Beth API authorises → Langflow MCP client → OOMOL OpenConnector → external app. LiteLLM remains the model gateway; Langfuse remains evaluation/tracing. This connector is now scoped for a two-provider pilot proof, not installed in the demo.

The large diagrams below are expanded reference designs. The current scope and connector flow take precedence: ContextForge and LiteLLM MCP aggregation are alternatives, and Temporal begins at broader launch.

Open the full diagram to zoom, trace connections, switch themes or use presentation mode.

Open the full diagram

Solid arrows show primary calls and data access. Dashed arrows mark optional routes. Response events return through the Beth adapter; this map is not a complete sequence diagram.

Follow a founder’s request

Choose a situation to see each engine’s responsibility and the result that should be saved.

Which components earn their place?

The proposed core has one owner for business progress. Frameworks support that owner; Beth still needs its own service rules, permissions and evidence checks.

Component / decisionWhat it does for BethWork needed to make it fit
OOMOL OpenConnectorSelected pilot connector proofApproved external-app actions and encrypted credentials through the Langflow MCP client. LiteLLM owns models.Two existing providers: prove transport, per-founder scopes, OAuth refresh/revocation and action receipts. Shares the app server; ContextForge is a replacement, not a second gateway.OpenConnector repository
CopilotKit + AG-UICore interfaceChat components, quote cards, progress and human approvals. AG-UI is the event protocol; CopilotKit provides the UI SDK.Build a Beth adapter, authentication and reconnect behaviour. Confirm supported event versions.AG-UI overview
FastAPI + PydanticProposed application layerOwn accounts, permissions, consent, cases and validated tool endpoints. FastAPI is a Python option that fits the proposed workers.Beth’s existing Node backend could remain instead; do not run two application backends without a reason.FastAPI documentation
TemporalCore recovery controllerPersist progress, retry failed stages, wait for approvals and enforce case deadlines.Operate the server and workers; split stages, add safe retries, idempotency and workflow versioning.Temporal workflows
LangflowCore AI flow builderVisually compose and version profiling, research and explanation flows.Run stage-sized flows through worker activities. Prove the AG-UI bridge; general compatibility is not a finished Beth integration.Langflow workflow API
PostgreSQLCore durable storageStore client profiles, approved service rules, estimates, tickets, evidence metadata and workflow persistence.Use separate databases / roles for Beth, Temporal and Langflow. Apply migrations, backups and restore checks.PostgreSQL licence
RedisFor shared Langflow workersShare job events, short-lived cache and related coordination across Langflow workers.Single-worker development can use the simpler configuration. Separate event/cache namespaces; Redis is not the case recovery engine.Langflow multi-worker deployment
n8nOptional integrationsConnect approved case events to CRM, email and messaging systems.Use an application outbox, delivery receipts and deduplication. Keep business case ownership in Temporal.n8n repository and licensing
LiteLLMOptional model gatewayCentralise model routing, usage tracking, budgets and provider fallback.Use task-specific allowlists. Do not silently send client data to an unapproved fallback provider. Direct provider calls work initially.LiteLLM proxy documentation

Good additions to consider

When a clear need appears

  • Langfuse: evaluate answer quality, trace model/tool behaviour and measure usage. Redact client data before recording traces. It adds operational overhead if self-hosted. Official repository.
  • Keycloak: add SSO and MFA if Babylon’s existing identity service cannot provide them. Avoid a second identity system without a need. Official site.
  • pgvector: search a small approved FAQ collection if normal database search becomes insufficient. A full tax-law corpus is not required. Official repository.

Alternatives, rather than extra layers

  • Valkey: an open-source alternative to Redis. Test Langflow’s streams, events, expiry and cancellation before substituting it. Official site.
  • PydanticAI or LangGraph: consider a code-first replacement for the AI-flow layer when visual flows become limiting. Do not add a second agent orchestrator by default. PydanticAI / LangGraph.
  • Existing Beth backend: retain Node if it already satisfies the application requirements; FastAPI is a proposed choice, not a compulsory migration.

What still needs building?

The Beth-specific engines

Profiling questions and category rules; an approved service catalogue; a reproducible quote calculator; specialist eligibility and capacity matching; consent and account isolation; the AG-UI / human-chat bridge; case tickets, appointments and document requests. Frameworks do not supply these business decisions.

See the related application screens or review the scoped engines.

Live research and a small verified cache

Fetch allowlisted authoritative pages when the question depends on current law. Keep a bounded cache of verified material with its URL, excerpt, publication/effective date, tax period, checksum and checked-at date. Recheck expiry and amendments before reuse.

If the source is unavailable, try an approved official alternate or an authorised access method. If a cached source cannot be freshly confirmed, label its last verification date and limit the answer or refer it for review. Do not bypass access controls or quietly turn a stale cache into a current legal claim. The model writes the explanation; the evidence tool and expert review determine whether it is safe to publish.

See model selection and evidence work in the scope.

Recovery and integration proof

Test a crash during research, a duplicate booking request, a human approval after a long wait, a lost event stream, source failure and an unavailable model. Record stage outputs and retry policies; require stable IDs for external actions. Langflow’s workflow API exposes AG-UI streaming, while the AG-UI overview lists Langflow integration as in progress. Confirm exact versions with a working bridge before committing to the stack.

Langflow API / AG-UI integration status / Temporal execution model.

Open-source and licence boundaries

n8n is source-available under its Sustainable Use / enterprise licensing, rather than strictly open source. Review the chosen use and edition before including it. n8n licensing.

Redis licensing depends on the version: Redis 8 and later offer an AGPLv3 option alongside RSALv2 and SSPLv1. Select the exact version and terms; Valkey is an alternative to evaluate. Redis licence history.

CopilotKit, LiteLLM and Langfuse have open-source core offerings with separate commercial features. Select required features explicitly. Self-hosting still costs engineering time and infrastructure; hosted model APIs and message channels may have separate charges. CopilotKit / LiteLLM / Langfuse.