System Architecture
Orquestra is built on a modern, serverless architecture leveraging Cloudflare’s edge network for global performance and scalability.High-Level Flow
The system follows a straightforward pipeline from IDL upload to transaction generation:- IDL Upload: User uploads an Anchor IDL JSON file via the dashboard
- IDL Parsing: System validates the IDL structure and extracts metadata
- API Generation: RESTful endpoints are automatically created for each instruction
- Transaction Building: Users call endpoints with parameters to build Solana transactions
Component Architecture
Frontend (React SPA)
Location:packages/frontend/
- Stack: React 18 + TypeScript + Tailwind CSS + Vite
- Deployment: Cloudflare Pages (static + dynamic assets)
- Features:
- GitHub OAuth authentication
- IDL upload & project management
- API key management
- Usage analytics dashboard
- Interactive API explorer
Backend (Hono + Workers)
Location:packages/worker/
- Stack: Hono + TypeScript + Cloudflare Workers
- Runtime: Cloudflare Workers (V8 Edge Runtime)
- Features:
- RESTful API endpoints
- IDL parsing and validation
- Transaction building engine
- Markdown documentation generation
- GitHub OAuth integration
The backend runs entirely on Cloudflare’s edge network, ensuring low latency worldwide
with automatic scaling.
Architecture Diagram
Edge Deployment
Why Cloudflare Workers?
Orquestra runs on Cloudflare Workers for several key advantages:- Global Edge Network: Code runs in 300+ data centers worldwide
- Automatic Scaling: Handles millions of requests without configuration
- Zero Cold Starts: Workers start in less than 1ms
- Cost Effective: Pay only for actual usage
- Integrated Storage: D1 database and KV store built-in
Edge Runtime Benefits
Edge Runtime Benefits
Traditional serverless platforms like AWS Lambda have cold start penalties (100ms-1s).
Cloudflare Workers eliminate this by using V8 isolates that start instantly.Additionally, Workers run in the same data center closest to your users, reducing latency
from 100ms+ to under 10ms globally.
Data Storage
D1 Database (SQLite)
Stores structured data with automatic replication:- users: Authenticated user accounts
- projects: Solana programs/projects
- idl_versions: IDL version history
- api_keys: API credentials for private projects
- project_socials: Project metadata and social links
KV Store (Key-Value)
Caches frequently accessed data:- IDL Cache:
idl:{projectId}:{version}(TTL: 1 week) - General Cache:
cache:{type}:{id}(variable TTL)
KV provides eventual consistency with global replication. Data is available in under 60 seconds
worldwide after write.
Request Flow
Authentication Flow
- User clicks “Sign in with GitHub”
- Redirects to GitHub OAuth authorization
- GitHub redirects to
/auth/github/callbackwith code - Worker exchanges code for access token
- Fetches user data from GitHub API
- Creates/updates user in D1 database
- Returns JWT token (7-day expiration)
- Frontend stores token in localStorage
- Includes token in
Authorizationheader for requests
Transaction Building Flow
- User provides instruction name, accounts, and arguments
- Sends POST to
/api/{projectId}/instructions/{name}/build - Worker validates request data against IDL schema
- Derives PDAs if needed from seed templates
- Constructs Solana instruction with data
- Builds transaction with recent blockhash
- Serializes to base58 format
- Returns serialized transaction + metadata
Performance Optimizations
Caching Strategy
- KV Cache: IDL and docs cached for 1 week
- HTTP Cache: Static assets cached for 1 year (immutable)
- Browser Cache: JS/CSS bundles with content hashing
- Database Query Cache: Frequently accessed data memoized
Load Reduction
- Code Splitting: Vite splits JS into route-based chunks
- Asset Compression: Automatic gzip/brotli compression
- Lazy Loading: Pages and components loaded on demand
- Image Optimization: Cloudflare Image Resize for avatars
Scalability
Horizontal Scaling
- Workers: Automatically scale across Cloudflare’s network
- D1: Distributed database scales with usage
- KV: Globally distributed key-value store
Rate Limiting
Protects against abuse:- Per IP per endpoint (100 req/min)
- Per API key for private projects (1000 req/hr)
- Per user account (500 req/min)
Development Workflow
Local Development
vite.config.ts.
Building & Deployment
GitHub Actions automatically deploys on push to
main (production) or develop (staging).