Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fatelessdev/autonome/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Autonome uses PostgreSQL with Drizzle ORM to manage trading data, model invocations, and portfolio history. The schema is designed with these critical principles:- Quoted identifiers: Table names use PascalCase (e.g.,
"Models","Orders") - TEXT for money: Store monetary values as TEXT, cast to NUMERIC for calculations
- UUID generation: Primary keys use
crypto.randomUUID()for consistency - Orders table is single source of truth: OPEN = active positions, CLOSED = completed trades
Tables
Models
Stores AI model configurations and runtime statistics.id: UUID primary keyname: Model display name (e.g., “GPT-4”, “Claude”)variant: Trading strategy variant (Apex, Trendsurfer, Contrarian, Sovereign)lighterApiKey: Account index for Lighter exchange APIinvocationCount: Total number of AI invocationstotalMinutes: Cumulative runtime across all invocations
(name, variant) enforces this.
Invocations
Records each AI model invocation with the response and payload.id: UUID generated viarandomUUID()modelId: Foreign key to Models tableresponse: Raw AI response textresponsePayload: JSONB containing full AI SDK response structure
ToolCalls
Tracks tool invocations made by the AI during trading decisions.CREATE_POSITION: AI opened a new tradeCLOSE_POSITION: AI closed an existing positionHOLDING: AI decided to hold (no action)
PortfolioSize
Time-series data tracking portfolio net asset value (NAV) over time.- Store as NUMERIC in DB for precision
- Use TEXT in application code, cast to NUMERIC for calculations
- Multiple indexes support efficient time-range queries and aggregations
Orders (Single Source of Truth)
The Orders table is the single source of truth for all positions and trades.-
OPEN vs CLOSED:
OPEN: Active position (appears in Positions tab)CLOSED: Completed trade (appears in Trades tab)
-
Derived Values (NOT stored):
entryNotional = quantity * entryPriceexitNotional = quantity * exitPrice- Unrealized P&L calculated live from current market price
-
Exit Plan Structure:
-
Real SL/TP Orders:
slOrderIndex/tpOrderIndex: Exchange order IDs for real stop-loss/take-profitslTriggerPrice/tpTriggerPrice: Actual trigger prices set on exchange- Used for live trading mode (not simulator)
Enums
Variant Enum
Trading strategy variants (derived from SSOT in@/core/shared/variants):
Relations
Drizzle ORM relations enable easy joins:Type Exports
Generate TypeScript types from schema:Critical Schema Rules
1. Quoted Identifiers
PostgreSQL requires quoting for capitalized identifiers:2. TEXT for Money
Store money as TEXT in application code, cast to NUMERIC for DB operations:3. UUID Generation
Usecrypto.randomUUID() consistently:
4. Timestamps
All tables with user data havecreatedAt and updatedAt:
updatedAt in update queries:
Next Steps
- Migration Workflow - Learn how to generate and apply schema changes
- Repositories - Explore data access patterns and helpers

