Custom Rust AppView
The AppView is the read-optimized indexing layer that materializes the social graph and serves client queries. Building this in Rust ensures high performance, memory safety, and predictable latency under load.
Two-Tier Indexing Pipeline
The AppView consumes JSON events from Tap via WebSocket. Because the network supports dynamic lexicons, the indexer handles both known and unknown schemas through a two-tier approach.
Tier 1: Known Lexicons
Compile-time generated Rust types via ATrium. Strongly typed, zero-cost abstractions.
use atrium_api::app::bsky::feed::post;
// Compile-time validated
let record: post::Record =
serde_json::from_value(event.record)?;
indexer.insert_typed(&record).await?;Tier 2: Dynamic Lexicons
Runtime JSON Schema validation with PostgreSQL JSONB storage. No migrations needed.
// Runtime validated against fetched schema
let schema = registry
.resolve(&event.collection).await?;
schema.validate(&event.record)?;
indexer.insert_dynamic(
&event.collection, &event.record
).await?;Core Components
Firehose Consumer
WebSocket client connecting to Tap. Receives JSON events, handles acks for delivery guarantees, routes events to the indexer pipeline.
Indexer Pipeline
Validates records against known types (ATrium) or dynamic schemas. Writes to PostgreSQL typed tables or JSONB columns. Maintains materialized views for query performance.
XRPC API Server
Serves custom lexicon query endpoints. Handles OAuth token validation. Implements hydration layer for complex views. Provides WebSocket subscriptions for real-time updates.
Lexicon Registry
Watches firehose for com.atproto.lexicon.schema records. Indexes published schemas. Provides resolveLexicon endpoint. Triggers dynamic validator creation.
Agent Protocol Bridge
Maps A2A/AG-UI/A2UI protocols to AT Protocol lexicons. Manages agent lifecycle. Translates between protocol formats bidirectionally.
Recommended Crate Stack
| Crate | Purpose | Why |
|---|---|---|
| axum | HTTP/WebSocket server | Tower ecosystem, async-first, production proven |
| sqlx | Database access | Compile-time SQL verification, async PostgreSQL |
| tokio | Async runtime | Industry standard, mature, excellent tooling |
| serde / serde_json | Serialization | Zero-copy deserialization, ubiquitous |
| atrium-api | AT Protocol types | Official Rust types for all lexicons |
| tungstenite | WebSocket client | Lightweight, async-compatible via tokio |
| jsonschema | Dynamic validation | Runtime schema validation for unknown lexicons |
| tracing | Observability | Structured logging, spans, OTEL export |
| loro | CRDTs | High-performance collaborative state |