Skip to content

Architecture

import { Aside } from ‘@astrojs/starlight/components’;

Kodel.AI is a client-server monorepo with schema-per-tenant PostgreSQL isolation. This page covers the system components, key data flows, and the multitenancy model.

The NestJS backend is the central hub — it owns all business logic, data, and LLM access.

ResponsibilityDetails
REST APIJWT auth, all CRUD endpoints, SSE streaming
WebSocket hubManages connected agent instances
LLM proxyStreams requests to LLM providers, logs to ClickHouse
Task engineWorkflow transitions, automation rules, AI job scheduling
MultitenancySchema-per-tenant isolation via SET LOCAL search_path

React 19 SPA with TanStack Router. No full-page reloads — all navigation is client-side.

FeatureTechnology
RoutingTanStack Router (file-based)
StylingTailwind CSS
StateTanStack Query (server state) + Zustand (UI state)
Real-timeSSE via EventSource

A stateless worker that connects to the server over WebSocket and executes one task at a time.

ToolWhat it does
read_fileRead file contents from /workspace
write_fileCreate or overwrite a file
edit_fileTargeted search/replace edits
bashRun shell commands (tests, git, npm…)
globFind files by pattern
grepSearch file contents with regex

Each organization gets its own PostgreSQL schema (org_{slug}). All tenant data is fully isolated at the database level.

Migrations are applied in two layers:

  • Shared (migrations/shared/) — runs once, affects public schema
  • Tenant (migrations/tenant/) — runs for each org schema on server startup
LayerTechnology
FrontendReact 19, TypeScript, TanStack Router, Tailwind CSS
BackendNestJS, TypeScript, Drizzle ORM
DatabasePostgreSQL (schema-per-tenant)
AnalyticsClickHouse (AI job events, LLM call logs)
AuthJWT (passport-jwt), optional OIDC/SSO
Agent runtimeBun, Docker
LLMOpenAI, Anthropic, OpenRouter, Ollama
Package managerpnpm workspaces