Project Structure
Relevant source files
The following files were used as context for generating this wiki page:
Rabid Raccoon is a specialized trading platform for Micro E-mini S&P 500 (MES) futures, built using Next.js, Prisma ORM, and Inngest for background job orchestration. The system integrates real-time market data from Databento with AI-driven forecasting and technical analysis tools to provide traders with automated insights and signal detection.
The project is structured to isolate high-frequency trading logic, data ingestion pipelines, and web-based analytical dashboards. It emphasizes data integrity for financial time-series and strict execution environments to prevent cross-project contamination with other trading systems.
Sources: README.md:1-15, cubic.yaml:8-15
Core Directory Hierarchy
The repository follows a standardized Next.js and TypeScript project layout, categorized by function:
| Directory | Purpose |
|---|---|
src/app/ | Next.js App Router including UI layouts and API routes. |
src/components/ | Reusable React components for dashboards and technical charting. |
src/lib/ | Core business logic, technical indicators, and utility functions. |
src/inngest/ | Background job definitions and step-based workflow logic. |
scripts/ | Data backfill, dataset builders, and ingestion maintenance scripts. |
indicators/ | Pine Script v6 trading indicators for TradingView integration. |
Sources: README.md:17-26, cubic.yaml:226-234
Data Flow and Integration Architecture
The architecture relies on a persistent data layer using PostgreSQL and Prisma, fed by multiple ingestion streams including Databento for live market prices and FRED for macro indicators.
The system employs a "Zero Tolerance for Silent Data Corruption" policy, requiring OHLCV validation before database insertion and BigInt for volume fields to avoid precision errors.
Sources: cubic.yaml:13-15, cubic.yaml:83-110, README.md:65-80
Analytical Engine and AI Integration
The src/lib/instant-analysis.ts module serves as the primary engine for multi-timeframe analysis. It computes over 200 technical signals (Moving Averages, RSI, Stochastics, VWAP) across 15M, 1H, and 4H timeframes. This deterministic data is then optionally overlaid with AI-generated narratives from models like Claude or GPT.
Analytical Components
- Technical Indicator Computation: High-performance math for signals like RSI, Bollinger Bands, and MACD.
- Swing & Fibonacci Detection: Identifies market structure and potential retracement levels.
- Measured Move Engine: Detects AB=CD patterns to project trade targets.
Background Ingestion and Maintenance
Automation is handled via Inngest workflows located in src/inngest/. These workflows are strictly isolated to the "rabid-raccoon" client ID to prevent collision with other projects.
Critical Inngest Rules
- Deterministic Replay: All side effects (database writes, API calls) must be wrapped in
step.run()to prevent duplicate Databento credit consumption during retries. - Append-Only Tables: Time-series tables for market data are treated as append-only;
DELETEandUPDATEoperations are flagged as corruption risks. - Batch Processing: Prisma batch sizes are capped at 100 rows to satisfy Prisma Accelerate limits.
Sources: cubic.yaml:24-40, cubic.yaml:141-155, cubic.yaml:194-203
Machine Learning Dataset Pipeline
The scripts/ directory contains specialized builders for generating datasets used in model training (e.g., AutoGluon).
Dataset Configuration (build-lean-dataset.ts)
- MES Technicals: 22 price action features.
- Daily Macro Context: 19 FRED series (VIX, DFF, Yield Curve, FX).
- Regime Velocity: Derived momentum and percentile features.
- Event Flags: FOMC days and high-impact economic calendar events.
Sources: scripts/build-lean-dataset.ts:12-65, scripts/build-15m-dataset.ts:15-50
Summary
The Rabid Raccoon project structure is designed for high-integrity financial data processing. By separating Pine Script indicators, React-based analytical dashboards, and Inngest-driven background ingestion, the architecture ensures that real-time trading signals are derived from both deterministic mathematical models and advanced AI analysis while maintaining strict isolation from external workflows.