NC

Technical Deep Dive

Crypto Copilot

Simulation-first AI trading decision support system.

Crypto Copilot is a full-stack trading copilot prototype designed around a safe boundary: market analysis and structured trade planning are allowed; live execution is not. The system combines a Next.js interface shell with a typed FastAPI backend that normalizes exchange market data, generates schema-constrained AI trade plans, validates those plans against guardrails, and routes them into simulation-only execution.

PrivateTrading InfrastructurePrivate backend prototype
Trading InfrastructureAI Decision SupportFastAPINext.jsSimulation-First Systems

The system explores the right boundary for financial AI: structured decision support over real market context, with validation before anything reaches even simulated execution.

Problem

AI trading demos often collapse into two bad patterns: vague chatbot advice or unsafe agent places trades automation. Crypto Copilot explores a better architecture: use AI for structured decision support while keeping execution constrained, inspectable, and simulation-only. The engineering challenge is to connect market context, typed APIs, schema-constrained LLM output, validation guardrails, and a frontend workflow without pretending the prototype is a production trading platform.

System Shape / Architecture

Next.js Interface Shell

The platform repository contains dashboard, status, orders, positions, PnL, logs, and prompt surfaces backed by React Query, local state, typed client helpers, and schema validation.

FastAPI Boundary

The API exposes public health and market-data routes plus protected LLM decision and execution-simulation routes behind X-Demo-Api-Key.

Market Context

Services normalize BYBIT spot candles, order books, recent trades, and read-only DEX snapshots into structured Pydantic models.

Simulation Boundary

LLM decisions are schema-constrained and validated before they can be submitted to simulated execution; no exchange-write path or live trading is implemented.

System Flow

Fetch BYBIT spot market context through CCXT-backed services.Normalize candles, order book, and recent trades into typed models.Generate a schema-constrained AI trade plan from structured context.Validate the plan against Pydantic contracts and guardrails.Submit only to simulation endpoints; live exchange writes stay out of scope.

Technical Highlights

  • Typed FastAPI API boundary for market data, LLM decisions, and simulated execution.
  • Pydantic decision contracts for proposed trades, cancels, stop moves, and flatten actions.
  • Market data normalization for candles, order books, and recent trades.
  • BYBIT spot market context integration through CCXT.
  • Read-only DEX pool snapshot endpoints for Uniswap v3 and Meteora.
  • Protected showcase endpoints using X-Demo-Api-Key.
  • Async SQLAlchemy and Alembic provide migration-backed persistence scaffolding.
  • Separate Next.js platform repository demonstrates dashboard and plan-review surfaces without turning the project into a single backend script.
  • Simulation-only execution model; no live trading, broker writes, or exchange writes.

AI / Automation Design

The AI component is treated as a decision-support module, not an autonomous trader. It receives structured market context and produces a schema-constrained trade plan. That output is validated before it can move into the execution simulator. This is the correct boundary for a credible financial AI prototype: AI can reason over context, the API constrains output shape, guardrails validate the plan, execution remains simulated, and no real credentials or exchange-write paths are required.

Engineering Tradeoffs

Crypto Copilot intentionally does not implement live trading, account management, broker writes, production-grade user authentication, or production trading guarantees. That restraint is part of the architecture. The project focuses on backend/API judgment, safe AI integration, typed contracts, market-data normalization, and trading workflow design while keeping real-money execution outside the system.

Stack

Frontend

Next.js 15React 19TypeScriptTanStack React QueryZustandReact Hook FormZodRechartsTailwind CSSVitestMSWTesting Library

Backend

Python 3.11+FastAPIPydanticSQLAlchemy asyncAlembicPostgresSQLite local supportCCXTOpenAI SDKWeb3HTTPXWebSockets

Validation

PytestRuffBlackmypyPydantic schema validationDemo API key boundaries

Market / AI Boundary

BYBIT spot contextOrder-book and trade snapshotsRead-only DEX poolsSchema-constrained AI plansSimulation-only execution

What This Demonstrates

Crypto Copilot demonstrates that I can build AI-assisted systems in a domain where correctness and safety matter. It connects my professional exposure to crypto and trading environments with product engineering: market data ingestion, typed service design, structured AI output, validation, simulation boundaries, and a user-facing copilot workflow.

Next Technical Steps

  • Add a portfolio-facing architecture diagram.
  • Add persisted AI decision audit trails.
  • Add richer simulation reports.
  • Add exchange adapter abstraction.
  • Add stronger evaluation fixtures for AI plan quality.
  • Add frontend flows around plan review and risk explanation.

Source Grounding

  • The API README defines the simulation-first showcase flow and explicitly states no live trading, no exchange writes, no production auth, and no full production readiness.
  • pyproject.toml documents FastAPI, Pydantic, SQLAlchemy, Alembic, CCXT, OpenAI, Web3, HTTPX, WebSockets, Pytest, Ruff, Black, and mypy.
  • app/main.py wires health, candles, market data, DEX, LLM decision, and execution-simulation route groups.
  • app/schemas/llm_contract.py and app/api/routes/llm_decider.py define the strict decision contract and protected LLM decision route.
  • app/api/routes/exec_sim.py keeps execution in protected simulation, while DEX routes expose read-only pool snapshots.
  • The platform package.json and app/services files support the Next.js interface shell, React Query client calls, dashboard status, positions, orders, PnL, and prompt surfaces.

Links

Projects · Home · Contact