|
| 1 | +# RustForge Terminal (rust-finance) |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + <img src="https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white" alt="Rust" /> |
| 5 | + <img src="https://img.shields.io/badge/Tokio-1A2421?style=for-the-badge&logo=Rust&logoColor=white" alt="Tokio" /> |
| 6 | + <img src="https://img.shields.io/badge/Solana-14F195?style=for-the-badge&logo=Solana&logoColor=white" alt="Solana" /> |
| 7 | + <img src="https://img.shields.io/badge/Anthropic-FF7F50?style=for-the-badge&logo=Anthropic&logoColor=white" alt="Anthropic" /> |
| 8 | + <img src="https://img.shields.io/badge/Ratatui-0A0C0F?style=for-the-badge&logo=Linux&logoColor=white" alt="Ratatui" /> |
| 9 | + <img src="https://img.shields.io/badge/WebSocket-010101?style=for-the-badge&logo=socket.io&logoColor=white" alt="WebSocket" /> |
| 10 | +</div> |
| 11 | + |
| 12 | +A high-performance, low-latency trading terminal and daemon built completely in Rust. Engineered for direct connection to market data streams (Finnhub, Alpaca), real-time AI signal analysis, and Solana-based trade execution. |
| 13 | + |
| 14 | +## System Architecture |
| 15 | + |
| 16 | +```mermaid |
| 17 | +graph TD; |
| 18 | + subgraph External Sources |
| 19 | + NYSE[Market Exchanges] |
| 20 | + NASDAQ[Market Exchanges] |
| 21 | + Crypto[Crypto WSS] |
| 22 | + end |
| 23 | +
|
| 24 | + subgraph Data Pipeline |
| 25 | + Ingestion(Ingestion Crate) |
| 26 | + Normalizer(Normalizer) |
| 27 | + Ingestion --> Normalizer |
| 28 | + end |
| 29 | +
|
| 30 | + NYSE --> Ingestion |
| 31 | + NASDAQ --> Ingestion |
| 32 | + Crypto --> Ingestion |
| 33 | +
|
| 34 | + subgraph Core Infrastructure |
| 35 | + EventBus[TCP Event Bus] |
| 36 | + Daemon((Core Daemon Engine)) |
| 37 | + DB[(Persistence Layer)] |
| 38 | + |
| 39 | + Normalizer -- Market Events --> EventBus |
| 40 | + EventBus <--> Daemon |
| 41 | + Daemon --> DB |
| 42 | + end |
| 43 | +
|
| 44 | + subgraph Intelligence & Execution |
| 45 | + AI_Dexter(Dexter Analyst AI) |
| 46 | + AI_Miro(MiroFish Swarm AI) |
| 47 | + AnthropicAPI[Anthropic Claude 3.5] |
| 48 | + |
| 49 | + Relay(Network Relay & Node Selector) |
| 50 | + RPC[Solana Mainnet RPC Nodes] |
| 51 | +
|
| 52 | + Daemon <--> AI_Dexter |
| 53 | + Daemon <--> AI_Miro |
| 54 | + AI_Dexter <--> AnthropicAPI |
| 55 | + AI_Miro <--> AnthropicAPI |
| 56 | + |
| 57 | + Daemon --> Relay |
| 58 | + Relay --> RPC |
| 59 | + end |
| 60 | +
|
| 61 | + subgraph Interfaces |
| 62 | + TUI[Terminal User Interface - Ratatui] |
| 63 | + Web[Web Dashboard] |
| 64 | + |
| 65 | + EventBus --> TUI |
| 66 | + EventBus --> Web |
| 67 | + end |
| 68 | +``` |
| 69 | + |
| 70 | +## Workspace Crates |
| 71 | + |
| 72 | +The workspace is organized into discrete, highly decoupled crates: |
| 73 | + |
| 74 | +* **`daemon`**: The central orchestrator. It manages the Tokio asynchronous runtime, spawns the EventBus, starts ingestion pipelines, controls the AI analyst intervals, and routes signals to the execution engine. |
| 75 | +* **`tui`**: A standalone Ratatui application featuring an advanced 3-column layout mimicking professional desktop terminals. It subscribes to the `event_bus` to render watchlists, deep order books, high-res braille charts, and live AI intelligence. |
| 76 | +* **`ai`**: Contains `DexterAnalyst` and `MiroFishSimulator`. Interacts natively with Anthropic APIs to detect catalysts, perform fundamental analysis, and run swarm probability algorithms on market feeds. |
| 77 | +* **`ingestion`**: Connects to `Finnhub` and `Alpaca` WebSockets. Normalizes trade and quote data into a standard `MarketEvent` format and pumps it into the system at extremely low latency. |
| 78 | +* **`relay`**: Handles network routing and edge measurement. Specifically benchmarks multiple RPC nodes (Helius, Triton, QuickNode) and routes transactions through the lowest-latency path available. |
| 79 | +* **`event_bus`**: A custom-built, lightweight TCP broadcasting system that decouples producers and consumers. Allows the TUI and Web Dashboards to run in entirely separate processes from the Daemon. |
| 80 | +* **`persistence`**: Storage layer designed to record transactional records, system P&L tracking, and order history. |
| 81 | +* **`common`**: Shared models, structs, commands, and `BotEvent` enumerations used across all systems to guarantee strict typing on inter-process communications. |
| 82 | + |
| 83 | +## Configuration & Usage |
| 84 | + |
| 85 | +The system expects several environment variables to be set for external API integrations: |
| 86 | + |
| 87 | +```sh |
| 88 | +export ANTHROPIC_API_KEY="..." |
| 89 | +export FINNHUB_API_KEY="..." |
| 90 | +export ALPACA_API_KEY="..." |
| 91 | +export ALPACA_SECRET_KEY="..." |
| 92 | +export USE_MOCK="1" # Enables mocked market generation for UI testing |
| 93 | +``` |
| 94 | + |
| 95 | +### Running the System |
| 96 | + |
| 97 | +Start the background daemon process first: |
| 98 | +```sh |
| 99 | +cargo run -p daemon --release |
| 100 | +``` |
| 101 | + |
| 102 | +In a separate terminal, launch the Terminal User Interface: |
| 103 | +```sh |
| 104 | +cargo run -p tui --release |
| 105 | +``` |
| 106 | + |
| 107 | +## UI and Visual Constraints |
| 108 | + |
| 109 | +The TUI utilizes `Constraint::Length` and custom Ratatui widget styling to enforce a strict immutable grid layout. Custom hex colors have been applied globally to match a proprietary theme design. |
0 commit comments