What is oRPC?
oRPC is a modern RPC framework that combines:- Type safety - Full TypeScript types from server to client
- Schema validation - Zod schemas for inputs and outputs
- TanStack Query integration - Built-in queryOptions for data fetching
- Single endpoint - All procedures route through
/api/rpc/* - Error handling - Sentry integration for monitoring
Unlike REST APIs with multiple endpoints (GET /api/trades, POST /api/orders), oRPC uses a single endpoint (
/api/rpc/*) and routes procedure calls based on the procedure path (e.g., trading.getTrades, simulator.placeOrder).Architecture Overview
The Autonome API follows a split deployment architecture:Data Flow
- Client calls
orpc.*.*.queryOptions()with input parameters - HTTP Request sent to
/api/rpc/*endpoint - oRPC Router validates input and routes to procedure handler
- Handler processes request, queries database, and returns response
- TanStack Query caches result and manages reactivity
Real-time Updates
For live data, Autonome uses Server-Sent Events (SSE) streams:/api/events/positions- Real-time position updates/api/events/trades- Real-time trade updates/api/events/conversations- AI model invocations/api/events/portfolio- Portfolio snapshots/api/events/workflow- Workflow execution events
API Router Structure
The oRPC router is organized into five main domains:Trading
Real-time trading data and market information.src/server/orpc/router/trading.ts
Models
AI model management and invocation history.src/server/orpc/router/models.ts
Simulator
Paper trading simulator operations.src/server/orpc/router/simulator.ts
Analytics
Performance metrics and leaderboards.src/server/orpc/router/analytics.ts
Variants
Strategy-specific data (Apex, Trendsurfer, Contrarian, Sovereign).src/server/orpc/router/variants.ts
All router procedures are exported from
src/server/orpc/router/index.ts and grouped by domain. The Hono server mounts these at /api/rpc/* in api/src/index.ts.oRPC Procedure Pattern
Every oRPC procedure follows the same pattern:Key Components
- Polyfill Import - Must be first line for Node.js compatibility
- Input Schema - Validates request parameters with Zod
- Output Schema - Validates response structure
- Handler - Async function that processes the request
- Sentry Span - Wraps handler for performance monitoring
Environment Configuration
API endpoints are configured via environment variables:PORT and FRONTEND_PORT are read via process.env on the server. VITE_API_URL is exposed to the browser via import.meta.env. In development, Vite proxies /api/* requests to the API server.Next Steps
Authentication
Set up the oRPC client and authenticate requests
Trading API
Fetch trades, positions, and market data
Simulator API
Paper trade with the exchange simulator
Analytics API
Access performance metrics and leaderboards

