Monorepo Architecture
Orquestra is built as a modern monorepo using Bun workspaces, allowing multiple packages to be developed, tested, and deployed together while maintaining clear separation of concerns.Technology Stack
- Package Manager: Bun 1.0+ (fast, all-in-one toolkit)
- Monorepo Tool: Bun workspaces
- Runtime: Cloudflare Workers (V8 isolates)
- Frontend: React 18 + Vite + Tailwind CSS
- Backend: Hono (ultra-fast edge framework)
- Database: Cloudflare D1 (SQLite at the edge)
- Cache: Cloudflare KV (key-value storage)
Root Directory Structure
Package: Frontend
React-based single-page application deployed to Cloudflare Pages. Location:packages/frontend/
Key Frontend Files
- App.tsx (
src/App.tsx:1): Main routing and layout component - main.tsx (
src/main.tsx:1): React app entry point with providers - authStore.ts (
src/store/authStore.ts:1): Global authentication state - client.ts (
src/api/client.ts:1): Axios instance with interceptors
Frontend Technologies
- React 18: UI library with concurrent features
- React Router v6: Client-side routing
- Vite: Build tool and dev server (HMR)
- Tailwind CSS: Utility-first CSS framework
- Zustand: Lightweight state management
- Axios: HTTP client for API requests
- Solana Web3.js: Blockchain interaction
Package: Worker
Hono-based REST API backend deployed as a Cloudflare Worker. Location:packages/worker/
Key Worker Files
- index.ts (
src/index.ts:1): Main Hono application with middleware setup - api.ts (
src/routes/api.ts:1): Dynamic API routes for IDL projects - idl-parser.ts (
src/services/idl-parser.ts:1): Core IDL processing logic - tx-builder.ts (
src/services/tx-builder.ts:1): Solana transaction building - doc-generator.ts (
src/services/doc-generator.ts:1): AI-optimized docs generation
Worker Architecture
Worker Technologies
- Hono: Fast, lightweight web framework
- Cloudflare Workers: Edge computing runtime
- Cloudflare D1: Distributed SQLite database
- Cloudflare KV: Low-latency key-value store
- Zod: TypeScript-first schema validation
- Web Crypto API: JWT signing (no Node.js dependencies)
Package: Shared
Shared TypeScript types and utilities used across packages. Location:packages/shared/
Key Shared Types
- User: User account structure
- Project: IDL project metadata
- IdlVersion: IDL version with history
- ApiKey: API authentication keys
- Idl: Anchor IDL type definitions
Shared Utilities
- String manipulation helpers
- Date formatting functions
- Common validation logic
Package: CLI
Command-line tools for discovering and analyzing Solana programs on-chain. Location:packages/cli/
CLI Commands
CLI Features
- Program Discovery: Finds all programs using BPF loaders
- IDL Detection: Checks for Anchor IDL accounts
- Resume Support: Checkpoint-based resumption
- Rate Limiting: Automatic retry with backoff
- Progress Tracking: Real-time progress indicators
- CSV Output: Structured data export
Database Migrations
Database schema is managed through migration files inmigrations/:
Location: migrations/
Migration Files
-
001_initial_schema.sql - Core tables
- users
- projects
- idl_versions
- api_keys
- project_socials
-
002_indexes.sql - Performance indexes
- User lookup indexes
- Project query indexes
- API key indexes
-
003_custom_docs_and_known_addresses.sql
- Custom documentation support
- Known addresses table
Configuration Files
wrangler.toml
Location:wrangler.toml:1
Cloudflare Workers configuration:
- Development: Local testing with dev bindings
- Production: Live environment with prod bindings
package.json
Location:package.json:1
Workspace configuration and scripts. See Local Setup for available scripts.
tsconfig.json
Location:tsconfig.json:1
Root TypeScript configuration with:
- Strict type checking
- Path aliases for imports
- Composite project references
Development Patterns
Monorepo Package References
Packages reference each other using workspace dependencies:Type Safety
All packages use strict TypeScript:- No implicit any
- Strict null checks
- Shared types in
packages/shared
Code Organization
Follow the established patterns:- Routes: Handle HTTP requests, minimal logic
- Services: Business logic and data processing
- Middleware: Cross-cutting concerns (auth, logging)
- Types: Centralized in
sharedpackage
Environment Variables
Environment-specific configuration:- Local:
.env.localin root - Workers:
wrangler.tomlvars section - Secrets:
wrangler secret put <NAME>
Build System
Build Process
Build Outputs
- Frontend:
packages/frontend/dist/- Static files for Pages - Worker: Bundled by Wrangler at deployment time
- Shared:
packages/shared/dist/- Compiled TypeScript
Testing Strategy
Unit Tests
Worker tests inpackages/worker/tests/:
Type Checking
Validate types across all packages:Linting
Code quality checks:Deployment Structure
Frontend Deployment
- Platform: Cloudflare Pages
- Build Output:
packages/frontend/dist/ - Build Command:
npm run build:frontend - URL: https://orquestra.dev
Worker Deployment
- Platform: Cloudflare Workers
- Entry Point:
packages/worker/src/index.ts - Build Command:
npm run build:worker - URL: https://api.orquestra.dev
Database
- Platform: Cloudflare D1
- Migrations: Applied via
wrangler d1 execute - Environments:
orquestra-dev,orquestra-prod
Next Steps
- Review Local Setup to get started
- Understand Database Schema
- Explore the API Reference
- Check Contributing Guidelines