High-Level Architecture
Relevant source files
The following files were used as context for generating this wiki page:
Rabid Raccoon is a multi-featured trading platform specifically designed for the Micro E-mini S&P 500 (MES) futures market. The system integrates real-time market data ingestion, persistent storage via Prisma and PostgreSQL, and an advanced technical analysis engine that combines deterministic mathematical signals with AI-driven overlays from Claude (Anthropic) and OpenAI.
The architecture is built on a Next.js framework, leveraging Inngest for background job orchestration and Databento for high-fidelity market data. It serves as both a live trading dashboard and a data engineering pipeline for building datasets used in machine learning (AutoGluon).
Sources: README.md:1-15, cubic.yaml:12-16, package.json:44-53
System Core Components
1. Data Ingestion & Storage Pipeline
The system utilizes a structured ingestion pipeline to handle high-frequency market data and macroeconomic indicators. Data is stored in a PostgreSQL database using Prisma ORM with specific time-series tables for different granularities (15m, 1h, 1d).
- Market Data (Databento): Fetches OHLCV candles with strict validation rules (e.g., high >= low, volume as BigInt).
- Macro Indicators (FRED): Syncs yield curves, volatility indices (VIX), and interest rates.
- Background Jobs (Inngest): Manages scheduled tasks such as daily price incremental updates, macro refreshes, and news feed ingestion.
The diagram shows the data flow from external providers through the Inngest orchestration layer into the persistent database.
Sources: README.md:65-95, cubic.yaml:63-100, scripts/ingest-alt-news-feeds.ts:400-450
2. Technical Analysis Engine
The analysis engine operates on a multi-timeframe basis (15M, 1H, 4H) and computes over 200 technical signals. It uses a hybrid approach: "Raw Math" for deterministic signal directions and AI for narrative overlays and trade planning.
- Deterministic Indicators: SMA, EMA, RSI, Stochastic, Bollinger Bands, ATR, and MACD.
- Structural Detection: Identifies Swing Points, Fibonacci levels, and Measured Move (AB=CD) patterns.
- AI Overlay: Uses OpenAI and Claude Opus to interpret mathematical signals into tradeable narratives, including entry, stop, and target levels.
Sources: src/lib/instant-analysis.ts:1-20, src/lib/instant-analysis.ts:100-250, src/app/api/analyse/chart/route.ts:100-130
Data Models and Configuration
Database Schema (Time-Series)
The system maintains specific tables for futures data and economic indicators to ensure data integrity and query performance.
| Table | Granularity | Key Fields |
|---|---|---|
mkt_futures_mes_15m | 15 Minute | eventTime, open, high, low, close, volume, rowHash |
mkt_futures_mes_1h | 1 Hour | eventTime, open, high, low, close, volume, rowHash |
econ_yields_1d | Daily | seriesId, eventDate, value |
ingestionRun | per Job | job, status, rowsProcessed, rowsInserted, details |
Sources: cubic.yaml:142-150, scripts/build-lean-dataset.ts:50-80, scripts/ingest-alt-news-feeds.ts:450-480
Core Architecture Rules
The project enforces strict isolation and data integrity rules via cubic.yaml to prevent cross-project contamination and data corruption.
| Rule Name | Description | Affected Files |
|---|---|---|
| Inngest Isolation | Client ID must be "rabid-raccoon" | src/inngest/client.ts |
| Volume Type | Must use BigInt to avoid overflow | src/lib/**/*.ts |
| UTC Enforcement | All market data timestamps must be UTC | scripts/**/*.ts |
| Batch Limits | Prisma createMany calls limited to ≤100 rows | src/inngest/**/*.ts |
Sources: cubic.yaml:25-45, cubic.yaml:102-110, cubic.yaml:204-212
Analysis & Forecasting Workflow
The following sequence diagram illustrates how a user request for market analysis is processed by combining local database data with external AI providers.
This diagram depicts the orchestration between deterministic signal computation and the AI interpretation layer.
Sources: src/lib/instant-analysis.ts:800-880, src/lib/forecast.ts:150-200
AI Analysis Specifications
The platform utilizes specific environment configurations to route analysis requests to various Large Language Models.
| Environment Variable | Default/Fallback | Purpose |
|---|---|---|
OPENAI_ANALYSIS_MODEL | gpt-5.2-pro | Primary model for technical signal narrative interpretation. |
OPENAI_FORECAST_MODEL | Analysis Model | Used for generating trade plans and risk conditions. |
ANTHROPIC_API_KEY | - | Required for vision-based chart analysis (Claude Opus). |
Sources: README.md:46-52, src/lib/instant-analysis.ts:35-45, src/app/api/analyse/chart/route.ts:60-70
Dataset Construction Architecture
For machine learning integration (specifically AutoGluon), Rabid Raccoon includes a feature engineering system that builds "Complete" and "Lean" datasets. These scripts merge technical price action with point-in-time macroeconomic data.
- Price Features: RSI, Moving Average distances, volatility ratios, and range positions.
- Macro Features: Yield curve slopes (10Y-2Y), credit spreads (HY-IG), and Fed liquidity (Assets - RRP).
- Target Generation: Computes forward return targets across multiple horizons (1h, 4h, 8h, 24h, 1w).
Sources: scripts/build-lean-dataset.ts:25-40, scripts/build-complete-dataset.ts:380-450, scripts/build-15m-dataset.ts:250-300
Conclusion
The high-level architecture of Rabid Raccoon is defined by its robust data isolation and its hybrid analytical approach. By strictly separating deterministic technical signal math from generative AI interpretation, the system ensures technical accuracy while providing sophisticated trading narratives. The integration of Inngest for background synchronization and Prisma for time-series management creates a scalable foundation for both live trading and historical backtesting.