Overview
Orquestra is built on a modern, serverless architecture leveraging Cloudflare’s global edge network. The system transforms Solana Anchor IDLs into production-ready REST APIs with automatic transaction building, documentation generation, and AI-optimized endpoints.High-Level Architecture
Architecture Diagram
Component Interactions
Request Flow
- User Request → Frontend or API call
- Edge Routing → Cloudflare distributes to nearest data center
- Worker Execution → Hono processes request at edge
- Middleware Chain → Auth → Rate Limit → Cache → Validation
- Service Layer → Business logic (IDL parser, tx builder, etc.)
- Data Layer → D1 queries + KV cache lookups
- Response → JSON returned to client
Component Dependencies
Data Flow
Authentication Flow
Steps:- User clicks “Sign in with GitHub”
- Redirects to GitHub OAuth authorization page
- GitHub redirects to
/auth/github/callbackwith code - Worker exchanges code for access token
- Worker fetches user data from GitHub API
- Creates/updates user in D1 database
- Returns JWT token (7-day expiry)
- Frontend stores token in localStorage
- Frontend includes token in
Authorizationheader
IDL Upload Flow
Steps:- User uploads IDL JSON file via dashboard
- Frontend validates file format and size (under 1MB)
- Sends to
/api/idl/uploadendpoint with JWT - Worker validates IDL structure (name, version, instructions)
- Stores in D1
idl_versionstable - Caches in KV for fast retrieval (
idl:{projectId}:{version}) - Generates Markdown documentation
- Returns project ID and API endpoints
Transaction Building Flow
Steps:- Client provides instruction name, accounts, and arguments
- Sends POST request to
/api/{projectId}/instructions/{name}/build - Worker:
- Validates request data against IDL schema
- Merges default values
- Derives PDAs (Program Derived Addresses) if configured
- Constructs Solana instruction with BorshSchema
- Builds transaction with accounts
- Fetches recent blockhash from Solana RPC
- Serializes to base58 format
- Returns serialized transaction + metadata
Edge Deployment
Cloudflare Workers
Runtime Characteristics:- V8 Isolates - Lightweight, fast cold starts (under 1ms)
- No Node.js - Uses Web APIs (Fetch, Crypto, Streams)
- Global Distribution - 275+ data centers worldwide
- Auto-scaling - Handles millions of requests
- Zero Config - No servers to manage
Cloudflare D1
SQLite at the Edge:- Global Read Replicas - Data replicated to all regions
- Strong Consistency - Writes to primary, reads from replicas
- Automatic Backups - Point-in-time recovery
- Low Latency - Under 10ms for most queries
Cloudflare KV
Key-Value Store:- Eventually Consistent - Optimized for reads
- Global Distribution - Low-latency worldwide
- High Throughput - Millions of reads/sec
- TTL Support - Automatic expiration
- IDL caching (
idl:{projectId}:{version}) - Response caching (
resp:api:{path}) - Rate limiting counters (
rl:api:{ip}) - Session storage (optional)
Scalability
Horizontal Scaling
Automatic:- Workers scale to handle demand
- D1 replicates reads globally
- KV distributes across edge
Database Optimization
Caching Strategy:- Indexed columns:
user_id,project_id,program_id - Prepared statements for SQL injection prevention
- Connection pooling (automatic)
Infrastructure as Code
Configuration inwrangler.toml:
Monitoring & Observability
Cloudflare Analytics:- Request count and error rates
- P50, P95, P99 latency metrics
- Bandwidth usage
- CPU time per request
- Request/response logging middleware
- Error tracking with stack traces
- Performance monitoring
- Rate limit violations
Related Documentation
Frontend Architecture
React 18, Zustand state management, and component structure
Backend Architecture
Hono framework, services, and middleware patterns
Security Model
Authentication, authorization, and security best practices
API Reference
Complete API endpoint documentation