Context Lake is a real-time context engine for AI agents.
It helps you:
- ingest operational data safely
- publish events through Kafka
- build fast read models
- serve agent-friendly context over APIs
- keep an audit trail of what happened
Think of it like this:
write data -> publish events -> build projections -> serve context -> store audit history
This repo is built for local development and project demos. It is production-oriented, but the included Docker Compose setup is not full production infrastructure.
- a transactional ingestion pipeline
- Kafka-based event flow
- materialized context views for fast reads
- an audit trail for access and agent activity
- metrics, tracing, and health/readiness checks
- a presentation frontend for demoing the system
ingest-api- receives write requests
- stores source-of-truth data and outbox events
stream-processor- consumes Kafka events
- builds projection tables
context-query-api- serves context from projections
audit-writer- stores immutable audit rows
presentation-web- frontend for presenting the architecture and live runtime
services/
ingest-api/
context-query-api/
stream-processor/
audit-writer/
presentation-web/
packages/
shared-config/
shared-db/
shared-events/
shared-http/
shared-logging/
shared-observability/
shared-types/
infra/
docker/
load/
postgres/
scripts/
docs/
Install these first:
- Node.js
20+ pnpm- Docker Desktop or Docker Engine with Compose
Check versions:
node -v
pnpm -v
docker --version
docker compose versionRun these commands from the repo root:
pnpm install
bash infra/scripts/copy-env.sh
pnpm compose:up
pnpm db:migrate
pnpm db:seed
pnpm devWhat each step does:
pnpm installinstalls all workspace dependenciesbash infra/scripts/copy-env.shcreates local.envfiles from the examplespnpm compose:upstarts Postgres, Kafka, Redis, MinIO, Grafana, Prometheus, and Jaegerpnpm db:migratecreates the database schemapnpm db:seedloads local sample datapnpm devstarts all app services in watch mode
- Presentation UI:
http://localhost:3010
This is the best place to start if you want to present the project.
- Ingest API:
http://localhost:3001 - Context Query API:
http://localhost:3002 - Audit Writer admin:
http://localhost:3003 - Stream Processor admin:
http://localhost:3004
- Grafana:
http://localhost:3005 - Kafka UI:
http://localhost:8080 - Prometheus:
http://localhost:9090 - Jaeger:
http://localhost:16686 - MinIO API:
http://localhost:9000 - MinIO Console:
http://localhost:9001
http://localhost:3001/healthhttp://localhost:3002/healthhttp://localhost:3003/healthhttp://localhost:3004/health
http://localhost:3001/readyhttp://localhost:3002/readyhttp://localhost:3003/readyhttp://localhost:3004/ready
http://localhost:3001/metricshttp://localhost:3002/metricshttp://localhost:3003/metricshttp://localhost:3004/metrics
http://localhost:3010/api/runtime
Once everything is running, use it in this order:
Go to:
http://localhost:3010
Youβll see:
- system overview
- service health/readiness
- architecture flow
- request lifecycle
curl http://localhost:3001/ready
curl http://localhost:3002/ready
curl http://localhost:3003/ready
curl http://localhost:3004/readycurl -X POST http://localhost:3001/ingest/customer \
-H 'content-type: application/json' \
-H 'authorization: Bearer context-lake-local-dev-token' \
-H 'x-tenant-id: aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa' \
-H 'idempotency-key: customer-demo-001' \
-d '{
"external_ref": "cust-demo-001",
"email": "demo@example.com",
"full_name": "Demo User",
"status": "active",
"metadata": {
"source": "demo"
}
}'curl http://localhost:3002/context/customer/11111111-1111-4111-8111-111111111111 \
-H 'authorization: Bearer context-lake-local-dev-token' \
-H 'x-tenant-id: aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa'pnpm db:outboxpnpm db:projectionspnpm stream:replaypnpm dev
pnpm compose:up
pnpm compose:down
pnpm compose:logspnpm db:migrate
pnpm db:seed
pnpm db:migrate:smoke
pnpm db:outbox
pnpm db:projectionspnpm lint
pnpm test
pnpm test:unit
pnpm test:integration
pnpm test:contracts
pnpm test:resilience
pnpm typecheck
pnpm build
pnpm validate:fullpnpm load:ingest
pnpm load:context- external system calls
ingest-api - request is validated
- DB transaction writes:
- domain row
- idempotency record
- ingestion record
- outbox event
- outbox relay publishes to Kafka
stream-processorconsumes Kafka events- validates event envelope
- updates projection tables
- ignores duplicates safely
- caller hits
context-query-api - API reads projection tables
- returns context-shaped response
- emits an audit event
audit-writerconsumes audit events- stores immutable audit rows
Use this token locally:
context-lake-local-dev-token
Example auth header:
-H 'authorization: Bearer context-lake-local-dev-token'docs/architecture.mddocs/data-model.mddocs/event-catalog.mddocs/ingestion.mddocs/projections.mddocs/context-query.mddocs/operations-runbook.mddocs/deployment-readiness.mddocs/load-testing.md
If you want to verify the full repo:
pnpm install
pnpm lint
pnpm test:unit
pnpm test:integration
pnpm test:contracts
pnpm test:resilience
pnpm typecheck
pnpm build
docker compose config
docker compose -f docker-compose.yml -f docker-compose.prod.yml config- This repo is great for demos, development, and architecture reviews
- Docker Compose here is not a full production deployment
- HA Kafka, secret managers, managed Postgres failover, and durable object storage are still future work