KaireonAI separates business logic from infrastructure through a set of TypeScript interfaces (Documentation Index
Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt
Use this file to discover all available pages before exploring further.
lib/infra/interfaces.ts) and a dependency injection container (lib/infra/container.ts). Each infrastructure concern — interaction storage, event publishing, search, caching, and logging — has a default implementation that works out of the box and one or more alternatives that you can activate with a single environment variable.
No code changes are required to switch backends. Set the env var, restart, and the container instantiates the correct adapter as a singleton.
All infrastructure backends support graceful shutdown. On a termination signal, the platform closes connections cleanly so in-flight requests finish and no events are lost. Backends are also re-initialized automatically when configuration changes at runtime, without requiring a process restart.
Interaction Store
The interaction store persists decision history, customer interactions, impressions, outcomes, and conversion data. It powers the Customer Viewer 360, attribution, and analytics.- PostgreSQL (default)
- DynamoDB
- Scylla / Cassandra
- AWS Keyspaces
Adapter:
pg-interaction-store.tsThe default. Stores interactions in the same PostgreSQL database as the rest of the platform. Zero additional infrastructure.| Best for | Development, small deployments, less than 10K decisions/day |
| Config | No additional config — uses DATABASE_URL |
| Cost | Included with your existing database |
Event Bus
The event bus handles asynchronous event routing for decision events, model update notifications, pipeline triggers, and real-time streaming. Every backend supports the same operations: publishing events to a topic, subscribing consumers to receive them, and shutting down cleanly on termination.- Redis Pub/Sub (default)
- Kafka / Redpanda
- AWS MSK
- Kinesis
- EventBridge
Adapter:
redis-events.tsUses your existing Redis instance for lightweight pub/sub messaging. Simple, no additional infrastructure.| Best for | Development, staging, low-to-medium throughput |
| Config | Uses REDIS_URL — no additional env vars |
| Cost | Included with your Redis instance |
Search Index
The search index powers full-text search across offers, categories, decision flows, and other platform entities. It also drives the global search bar and analytics queries.- PostgreSQL FTS (default)
- OpenSearch
Adapter:
pg-search.tsUses PostgreSQL’s built-in tsvector full-text search. No additional infrastructure needed.| Best for | Under 1M records, simple search queries |
| Config | Uses DATABASE_URL — no additional env vars |
| Cost | Included with your existing database |
Cache
Redis is used for caching enrichment data, sliding-window rate limiting, session storage, circuit breaker state, and background job queues. The cache layer supports standard read, write, and delete operations plus a cache-aside helper that fetches and stores a value in one call when the key is missing.- Redis OSS — local development or self-hosted
- Amazon ElastiCache — managed Redis on AWS
- Upstash Redis — serverless Redis with per-request pricing
- Dragonfly — Redis-compatible, multi-threaded drop-in replacement
Redis is optional in development (the platform falls back to in-process defaults), but required for production. Without Redis, rate limiting, enrichment caching, and background job processing will not function correctly.
Logging
KaireonAI uses Winston for structured JSON logging. The default console transport works for development and containerized deployments where log aggregation happens at the orchestrator level (e.g., CloudWatch Container Insights, Datadog Agent).- Console (default)
- CloudWatch
Structured JSON logs written to stdout/stderr. Works with any log aggregation system that reads container output.
Choosing Your Stack
Use these reference architectures as a starting point. Every backend is independently swappable, so you can mix and match based on your requirements.Development (zero config)
Development (zero config)
All defaults. No additional services beyond PostgreSQL and optionally Redis.
| Concern | Backend | Config |
|---|---|---|
| Interactions | PostgreSQL | Default |
| Events | Redis Pub/Sub | REDIS_URL |
| Search | PostgreSQL FTS | Default |
| Cache | Redis | REDIS_URL |
| Logging | Console | Default |
| Estimated cost | $0 (local) |
Startup on AWS (~$50-100/mo)
Startup on AWS (~$50-100/mo)
Lean AWS deployment using managed services with pay-per-use pricing.
| Concern | Backend | Config |
|---|---|---|
| Interactions | PostgreSQL | Default |
| Events | EventBridge | EVENT_PUBLISHER=eventbridge |
| Search | PostgreSQL FTS | Default |
| Cache | Upstash Redis | REDIS_URL=rediss://... |
| Logging | CloudWatch | Via platform settings |
| Estimated cost | $50-100/mo |
Growth on AWS (~$500-1K/mo)
Growth on AWS (~$500-1K/mo)
Higher throughput with dedicated event streaming and search infrastructure.
| Concern | Backend | Config |
|---|---|---|
| Interactions | DynamoDB | INTERACTION_STORE=dynamodb |
| Events | MSK or Kafka | EVENT_PUBLISHER=msk |
| Search | OpenSearch | SEARCH_INDEX=opensearch |
| Cache | ElastiCache | REDIS_URL=rediss://... |
| Logging | CloudWatch | Via platform settings |
| Estimated cost | $500-1K/mo |
Enterprise (>$2K/mo)
Enterprise (>$2K/mo)
Maximum throughput with dedicated high-performance backends.
| Concern | Backend | Config |
|---|---|---|
| Interactions | Scylla | INTERACTION_STORE=scylla |
| Events | MSK | EVENT_PUBLISHER=msk |
| Search | OpenSearch | SEARCH_INDEX=opensearch |
| Cache | ElastiCache (cluster mode) | REDIS_URL=rediss://... |
| Logging | CloudWatch | Via platform settings |
| Estimated cost | $2K+/mo |
Adding a Custom Backend
Every infrastructure concern is behind a TypeScript interface. To add your own implementation:Implement the backend contract
Add a new adapter alongside the existing infrastructure adapters. Each backend type has a small contract to satisfy:
- Interaction store — record an event, fetch interaction summaries, and shut down cleanly.
- Event bus — publish events to a topic, subscribe consumers, and shut down cleanly.
- Search index — run a search query, index a document, and shut down cleanly.
- Cache — get, set, and delete keys, fetch-or-populate in one call, health-check the connection, and shut down cleanly.