220,000+ lines of TypeScript · 44 DB models · 7 automation systems

The self-hosted forex platform
that trades while you sleep

AI-powered trade discovery, multi-agent debate analysis, autonomous execution, and real-time management — all running on your machine. Open source. Built with Claude Code.

ForexFlow is provided as-is for educational and personal use. It is not financial advice. Trading forex involves significant risk of loss. Use at your own risk.

221K+
Lines of TypeScript

strict mode

114
API Routes

Next.js handlers

44
Database Models

Prisma / SQLite

363
React Components

shadcn/ui based

7
Automation Systems

trading + AI

Everything you need to trade smarter

Seven automation systems working together — from real-time monitoring to fully autonomous multi-agent AI trading.

EdgeFinder AI Trader

Autonomous 3-tier pipeline with multi-agent debate for trade discovery and execution.

  • 14 local TA techniques (SMC, FVG, order blocks, divergence)
  • Bull/bear adversarial debate before every decision
  • Post-trade reflection memory improves future decisions
  • Manual, Semi-Auto, and Full Auto operating modes

Real-Time Dashboard

Command center with live WebSocket data, AI insights, and full account overview.

  • Live P&L, equity, margin, drawdown, and NAV
  • Open positions with sub-second price streaming
  • AI insights card, automation status tiles
  • Notification center with deep-linked actions

Trade Finder

Supply/demand zone scanner with 11-dimension scoring and automatic order placement.

  • Multi-timeframe zone detection and HTF confluence
  • 11 scoring dimensions with adaptive threshold tuning
  • Entry confirmation patterns (engulfing, pin bar, BOS)
  • Queue system with currency exposure guards

SmartFlow Trading

Autonomous scanner with 4 modes, AI management suggestions, and preset strategies.

  • Trend following, mean reversion, breakout, session momentum
  • 6 strategy presets with adaptive R:R thresholds
  • AI-powered management suggestions via Claude
  • Real-time activity feed and performance tracking

AI Trade Analysis

Every trade analyzed by Claude with executable conditions and scheduled re-analysis.

  • Structured context: candles, indicators, win rate history
  • One-click executable conditions (price, time, P&L triggers)
  • Auto-analysis on fill, close, or scheduled intervals
  • Reconciliation system for re-run condition management

TradingView Automation

Cloudflare Worker webhook relay with 9 safety checks and risk-based sizing.

  • Durable Object relay with IP validation and rate limiting
  • Risk-based position sizing (ATR fallback when no SL)
  • Per-instrument cooldowns and circuit breaker
  • Full signal audit trail with quality scoring

Multi-Panel Charts

TradingView Lightweight Charts with interactive overlays and order editing.

  • 1x1 through 2x2 grid layouts with saved configurations
  • Draggable SL/TP lines with live R:R preview
  • Supply/demand zone, trend, and indicator overlays

Desktop App

Electron macOS app that bundles web + daemon for non-technical users.

  • One-click DMG install — no terminal required
  • Daemon runs as managed child process
  • Auto-updates and native menu integration

Multi-Agent Debate

Adversarial bull/bear analysis inspired by institutional trading desks.

  • Technical + macro analyst briefs (parallel Haiku)
  • Bull advocates FOR, bear counters AGAINST
  • Judge weighs debate + past trade reflections

Price Alerts

Configurable above/below price alerts with repeating and expiry options.

  • Real-time tick-level monitoring on open positions
  • One-shot or repeating alerts with optional expiry
  • Push notifications via the notification system

Position Management

Full trade lifecycle with MFE/MAE tracking, partial closes, and tagging.

  • MFE/MAE watermarks updated per tick, persisted every 30s
  • Partial closes, breakeven, trailing stops, SL/TP editing
  • Filter and sort by instrument, direction, source, or tags

Remote Access & PWA

Trade from anywhere with secure tunnel access and installable mobile app.

  • Cloudflare Tunnel for HTTPS access from any device
  • PIN authentication with lockout and session management
  • Installable PWA with offline-first service worker

Architecture

A TypeScript monorepo with 5 apps, 3 shared packages, and an MCP server — the daemon orchestrates 13+ subsystems.

ForexFlow Architecture Diagram TradingView Webhook alerts Cloudflare Worker Durable Object relay POST /webhook WebSocket Next.js Web App Frontend + 114 API routes React 19 + Tailwind CSS 4 WebSocket real-time Node.js Daemon 13+ subsystems, port 4100 Trade sync, signals, AI, zone scanner, autonomous trader HTTP REST + WebSocket broadcast OANDA API REST + SSE streams Prices & transactions REST API SSE streams SQLite Prisma ORM, 44 models Cloudflare Tunnel optional, HTTPS Phone / PWA
Apps
Daemon (hub)
External APIs
Data / Optional

AI governance that makes Claude Code production-ready

A reusable pattern for any AI-assisted project. The .claude/ directory is why 221,000+ lines of AI-generated code are consistent and production-quality.

CLAUDE.md

Project Constitution

Loaded into every Claude Code session. Defines monorepo layout, strict import boundaries, coding standards, and critical domain concepts. The AI reads this before writing a single line of code.

11 Path-Scoped Rules

.claude/rules/

Context-specific rules that auto-load based on which files the AI edits. TypeScript patterns, daemon architecture, accessibility standards, trading domain rules, desktop app conventions, and doc sync — each scoped to where they matter.

9 Reusable Skills

.claude/skills/

Task templates for common operations. When the AI adds an API route, daemon endpoint, or WebSocket event, it follows a defined pattern — ensuring consistency across the entire codebase.

Example: A path-scoped rule

.claude/rules/08-trading-domain.md
# Claude Rule: Trading Domain

- Trade.source is always "oanda" — true origin in metadata.placedVia
- Use enrichSource() to map to display labels
- JPY pairs use 0.01 pip size, all others use 0.0001
- Market hours: Sun 5pm ET → Fri 5pm ET
- Daily rollover window: 4:59pm → 5:05pm ET

Automated safeguards

format-on-edit

Prettier runs on every file the AI edits

guard-bash

Blocks destructive shell commands at execution time

Sandbox

AI cannot read .env files or access secrets

"The productivity gain from AI isn't 'it writes code faster.' It's that you can build a system where AI writes code that fits the project — every time, without re-explaining the project every time."

Tech Stack

Modern, production-grade tools across every layer.

Frontend Next.js 15, React 19, Tailwind CSS 4, shadcn/ui, Radix UI
Charts TradingView Lightweight Charts 5
Backend Node.js daemon — 13+ subsystems, HTTP + WebSocket
Desktop Electron macOS app with managed daemon process
Edge Cloudflare Workers + Durable Objects (webhook relay)
Database SQLite via Prisma ORM (44 models, LibSQL/Turso adapter)
AI Runtime Claude API — Haiku (filter/debate) + Sonnet (decisions)
AI Dev Tool Claude Code with 11 rules, 9 skills, 3 hooks
MCP Server Claude Code bridge to live trading data
Monorepo pnpm workspaces + Turborepo (5 apps, 3 packages)
Testing Vitest with coverage, Lefthook pre-commit/pre-push
Language TypeScript 5.7 (strict mode, ~221K lines)

Get started in 4 steps

From clone to running in under 5 minutes. Requires Node.js >= 22 and pnpm >= 10.

1

Clone and install

git clone https://github.com/bmarshall511/forexflow.git
cd forexflow
pnpm install
2

Generate Prisma client

pnpm --filter @fxflow/db db:generate
3

Configure environment

# Single root env file — no per-app duplicates
cat > .env.local <<'EOF'
DATABASE_URL=file:../../data/fxflow.db
ENCRYPTION_KEY=
NEXT_PUBLIC_DAEMON_REST_URL=http://localhost:4100
NEXT_PUBLIC_DAEMON_URL=ws://localhost:4100
EOF

# Generate an ENCRYPTION_KEY and paste it into .env.local
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
4

Initialize database and start

mkdir -p data
pnpm --filter @fxflow/db db:migrate
pnpm dev

Open http://localhost:3000/settings/oanda to connect your OANDA account. See the full configuration guide for all options.

Contributions welcome

The .claude/ governance system means you can use Claude Code effectively on this project from day one.

  • Additional broker integrations (currently OANDA only)
  • New AI analysis techniques and strategy profiles
  • Testing coverage improvements across all subsystems
  • Windows and Linux Electron desktop builds
  • Cloud deployment tooling (Docker, Railway, Fly.io)
  • Multi-language support for AI-generated trade analysis