How to Get Started with Reactive Graphs in AINL
Build event-driven AI workflows that automatically react to database changes, realtime events, and pub/sub messages using clean, auditable graphs in AINL.
How to Get Started with Reactive Graphs in AINL
Build event-driven AI workflows that automatically react to database changes, realtime events, and pub/sub messages — all in clean, auditable graphs.
As of March 2026, AINL is production-ready for reactive workflows. You can now combine DynamoDB Streams, Supabase Realtime, Redis pub/sub, observability, and durable checkpointing using simple, composable graphs.
No more writing Lambda functions or managing complex event buses. Just write a graph, enable the right adapters, and let AINL handle the reactivity.
Prerequisites
- AINL installed and working
- Basic familiarity with running graphs (
ainl run your_graph.ainl) - The following adapters enabled:
dynamodbsupabaseredis
Step 1: Run Your First Reactive Graph
The easiest way to see reactive graphs in action is with the hybrid example that ties everything together:
AINL_RUNTIME_ASYNC=1 AINL_OBSERVABILITY=1 AINL_OBSERVABILITY_JSONL=/tmp/ainl-reactive-metrics.jsonl \
ainl run templates/production/hybrid_stream_to_realtime.ainl \
--runtime-async --observability --observability-jsonl /tmp/ainl-reactive-metrics.jsonl \
--enable-adapter dynamodb --enable-adapter supabase --enable-adapter redis
This single graph does the following in one bounded, auditable flow:
- Reads changes from a DynamoDB stream (with checkpointing)
- Broadcasts normalized events via Supabase Realtime
- Publishes to Redis for fast internal routing
- Acks the last processed sequence for durability
Step 2: Understand the Core Building Blocks
AINL gives you three powerful reactive primitives with consistent, bounded semantics.
DynamoDB Streams – ordered change capture with checkpointing:
R dynamodb.streams.subscribe "profiles" "LATEST" {"event_names":["INSERT","MODIFY"]} 0.5 25 "workers" "consumer-1" "memory" ->batch
R dynamodb.streams.ack "profiles" "shard-000" $batch.events[-1].dynamodb.SequenceNumber "workers" "consumer-1" ->ack
Supabase Realtime – WebSocket-based Postgres changes with fan-out and replay:
R supabase.realtime.subscribe "orders-ch" "orders" ["INSERT","UPDATE"] null 0.5 25 "latest" "workers" "consumer-a" ->batch
R supabase.realtime.ack "orders-ch" $cursor "workers" "consumer-a" ->ack
Redis Pub/Sub – low-latency internal messaging:
R redis.publish "events:profiles" $batch ->rpub
R redis.subscribe "events:profiles" 1.0 25 ->batch
All of these respect bounded timeout_s and max_events so your graphs stay responsive.
Step 3: Add Durability with Production Templates
Don’t start from scratch. Use the ready-made templates in templates/production/:
dynamodb_stream_worker.ainl– stream processing with Redis-backed checkpointssupabase_realtime_worker.ainl– realtime worker with fan-out and cursor persistencehybrid_stream_to_realtime.ainl– full DDB → Supabase → Redis pipeline
Simply include them or copy the patterns into your own graphs. They already include checkpoint loading, processing placeholders, acking, and observability hooks.
Step 4: Enable Observability
Add metrics with almost zero overhead:
AINL_RUNTIME_ASYNC=1 AINL_OBSERVABILITY=1 AINL_OBSERVABILITY_JSONL=/tmp/ainl-metrics.jsonl \
ainl run your_graph.ainl --runtime-async --observability --observability-jsonl /tmp/ainl-metrics.jsonl ...
You’ll get structured JSON lines with:
adapter.call.duration_msreactive.events_per_batchreactive.lag_secondsreactive.ack.success_rate
Perfect for debugging lag, monitoring throughput, or feeding into your logging stack.
Next Steps & Resources
- Read the full patterns:
docs/reactive/REACTIVE_EVENTS.md - Learn durability strategies:
docs/reactive/ADVANCED_DURABILITY.md - Explore ready-to-use templates:
templates/production/ - Run the examples with
AINL_RUNTIME_ASYNC=1
What’s next for AINL?
We’re focusing on multi-node durability coordination, smarter runtime scheduling, and optional advanced features. The foundation is solid and ready for your production workloads today.
Try it now — clone the repo, enable a couple adapters, and run your first reactive graph. We’d love to see what you build.
