This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a microservices architecture for processing Token Transfer Protocol (TTP) events from the Stellar blockchain. The system consists of data sources, processors, and consumer applications that work together via gRPC streaming.
Stellar Data Source → stellar-live-source/datalake → ttp-processor → Consumer Apps
→ ledger-jsonrpc-processor → JSON-RPC API
The repository is organized as a Go workspace with multiple services:
stellar-live-source: RPC-based ledger data sourcestellar-live-source-datalake: Storage-based ledger data source with Nix buildsttp-processor: Processes raw ledgers into TTP eventsledger-jsonrpc-processor: Converts ledgers to JSON-RPC formatconsumer_app/: Multiple consumer implementations (Node.js, Go WASM, Rust WASM)cli_tool/: Command-line interface tool
Each Go service has a Makefile with consistent targets:
# Build any Go service
cd <service-directory>
make build
# Generate protobuf code
make gen-proto
# Run the service
make run
# Clean build artifacts
make clean# Go services - run tests
cd <service-directory>/go
go test ./...
# Individual test files
go test -v ./path/to/packagecd consumer_app/node
npm install
npm run build
npm start -- <start_ledger> <end_ledger>
# With flowctl integration
ENABLE_FLOWCTL=true npm start -- <start_ledger> <end_ledger>cd consumer_app/go_wasm
# Build both WebAssembly and native versions
make all
# Build WebAssembly only
make build-wasm
# Build native version only
make build-native
# Run native with mock server
make run-native
# Run native with real server
make run-real-server
# Serve WebAssembly in browser
make serve-wasmcd consumer_app/rust_wasm
# Build for web target
wasm-pack build --target web
# Build for Node.js target
wasm-pack build --target nodejscd stellar-live-source-datalake
# Development shell with all dependencies
make nix-shell
# Build binary with Nix
make nix-build
# Build and run with Nix
make nix-run
# Build Docker image
make docker-build
# Run Docker container
make docker-run
# Full CI build process
make ci-build
# Vendor dependencies for offline builds
make vendor-allAll services use protobuf for gRPC communication. Proto files are in protos/ directories.
Key proto services:
raw_ledger_service: Raw Stellar ledger dataevent_service: Processed TTP eventsledger_jsonrpc_service: JSON-RPC formatted data
The project uses go.work to manage multiple Go modules:
- Services are independent Go modules
- Shared dependencies are managed at workspace level
- Use
go work use <path>to add new services - For Nix builds, Go workspace mode is disabled with
GOWORK=off
Services use environment variables for configuration:
Data Sources:
RPC_ENDPOINT: Stellar RPC endpointNETWORK_PASSPHRASE: Stellar network passphraseSTORAGE_TYPE: For datalake source ("GCS", "S3", "FS")BUCKET_NAME: Storage bucket/path
Processors:
LIVE_SOURCE_ENDPOINT: Address of data source serviceNETWORK_PASSPHRASE: Stellar network passphrase
Flowctl Integration:
ENABLE_FLOWCTL=true: Enable control plane integrationFLOWCTL_ENDPOINT: Control plane address (default: localhost:8080)FLOWCTL_HEARTBEAT_INTERVAL: Heartbeat interval (ms, default: 10000)STELLAR_NETWORK: Network name (default: testnet)HEALTH_PORT: Health check port (default: 8088)
The codebase supports multiple WebAssembly implementations:
Go WASM (consumer_app/go_wasm):
- Uses build tags for JS/WASM vs native compilation
- Generates both
.wasmfile and native binary - Includes web server for browser testing
Rust WASM (consumer_app/rust_wasm):
- Uses
wasm-packfor building - Supports both web and Node.js targets
- Includes example web application
- All inter-service communication uses gRPC streaming
- Services expose health endpoints for monitoring
- Metrics are reported to flowctl control plane when enabled
- Services handle stream reconnection and error recovery
- Data flows as continuous streams between services
- Use bidirectional streaming for real-time processing
- Handle backpressure and flow control
- Proto files define service contracts
- Generated Go code follows source_relative paths
- Client and server stubs are auto-generated
- Consumer app pulls proto files from Stellar Go repository
- Services track processing metrics (success/error counts, latency)
- Health endpoints expose service status and metrics at
/health - Graceful shutdown handling for all services
- Metrics reporting to flowctl control plane
Multiple consumer patterns are demonstrated:
- Node.js: Traditional gRPC client with TypeScript, flowctl integration
- Go WASM: WebAssembly for browser deployment with native fallback
- Rust WASM: Alternative WASM implementation with gRPC-Web support
- All support flowctl integration for monitoring
The stellar-live-source-datalake service uses Nix for reproducible builds:
- Flake-based configuration for dependencies
- Supports both binary and Docker image builds
- Includes vendoring for offline builds
- CI-friendly build targets
- Go 1.21+ (specified in go.work)
- Protocol Buffers compiler (protoc)
- protoc-gen-go and protoc-gen-go-grpc plugins
- Node.js 22+ (specified in package.json engines)
- TypeScript for development
- @grpc/grpc-js for gRPC client
- Go WASM: Standard Go toolchain with js/wasm build tags
- Rust WASM: Rust toolchain with wasm-pack
- Special considerations for browser gRPC (requires gRPC-Web proxy)
- Nix with flakes support enabled
- Development shell provides all build dependencies automatically
- Start data source service (stellar-live-source or stellar-live-source-datalake)
- Start processor service (ttp-processor or ledger-jsonrpc-processor)
- Start consumer applications
- Optional: Start flowctl control plane for monitoring
Each service will wait for dependencies and handle reconnection automatically.
- Go WASM uses build tags to separate browser and native code
- Rust WASM requires specific dependency versions to avoid feature conflicts
- Browser deployment requires gRPC-Web proxy in front of gRPC services
- Use
make vendor-allto prepare dependencies for offline Nix builds - Go workspace mode is disabled (
GOWORK=off) for consistent builds - Supports both development builds and containerized deployments
- Do not use mock data when testing functionality