<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OrderCraft]]></title><description><![CDATA[OrderCraft]]></description><link>https://ordercraft.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6ae8c3f4c7ddd3687313ec1b/f7c1d2da-c45b-4a7d-9543-dc3936f54ae2.png</url><title>OrderCraft</title><link>https://ordercraft.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 12:22:52 GMT</lastBuildDate><atom:link href="https://ordercraft.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Building OrderCraft: A Local-First Financial Charting Terminal in a Single ~14MB Go Binary]]></title><description><![CDATA[Open-source local Go/React financial charting terminal with canvas drawing tools, SQLite persistence, and multi-pane workspaces.]]></description><link>https://ordercraft.hashnode.dev/building-ordercraft</link><guid isPermaLink="true">https://ordercraft.hashnode.dev/building-ordercraft</guid><category><![CDATA[Go Language]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[React]]></category><category><![CDATA[finance]]></category><category><![CDATA[trading, ]]></category><dc:creator><![CDATA[Shreyas]]></dc:creator><pubDate>Mon, 02 Nov 2026 17:21:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ae8c3f4c7ddd3687313ec1b/9c9beae6-266b-452e-b387-84f86da2323c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Modern financial charting platforms have converged on the same frustrating cloud SaaS model: lock basic technical analysis behind $15 to $60/month subscriptions, restrict free users to 2 indicators per chart, paywall multi-chart split-screen layouts, and force all your watchlists and layouts into their cloud.</p>
<p>On the flip side, developers who try to build hosted open-source alternatives hit two massive walls almost immediately:</p>
<ol>
<li><strong>IP Rate Limits:</strong> Public exchange APIs (like Binance or Yahoo Finance) ban central server IPs within hours when multiple users request market data through a shared backend.</li>
<li><strong>Market Data Redistribution Licensing:</strong> Exchanges demand thousands of dollars per month the moment a central server redistributes market feeds to third-party users.</li>
</ol>
<p>To solve both problems at the root, I built and open-sourced <strong>OrderCraft</strong> (<code>v0.1.0</code>, MIT License) — a high-performance, <strong>100% local-first</strong> financial charting and technical analysis terminal built with <strong>Go</strong>, <strong>React 19</strong>, <strong>TypeScript</strong>, and <strong>Lightweight Charts</strong> (Apache-2.0).</p>
<hr />
<h2>🏗️ How It Works: The Single-Binary Local-First Architecture</h2>
<p>Instead of running in the cloud, OrderCraft compiles into a single standalone ~14.8MB executable (<code>CGO_ENABLED=0</code>) that runs directly on your machine (<code>127.0.0.1</code>). Because <em>your</em> machine connects directly to public market data feeds or your own brokerage API keys, there is no middleman server, zero telemetry, and no exchange redistribution bottleneck.</p>
<h3>1. Zero-Dependency <code>//go:embed</code> Packaging</h3>
<p>The entire frontend (React 19, TypeScript, Vite) compiles down into static assets and is embedded directly into the Go binary using <code>//go:embed</code>:</p>
<ul>
<li>No Node.js, Python, or external database installation required for end-users.</li>
<li>Cross-compiles cleanly to standalone binaries for <strong>Windows (</strong><code>amd64</code><strong>)</strong>, <strong>macOS (</strong><code>arm64</code> <strong>/ Apple Silicon &amp;</strong> <code>amd64</code><strong>)</strong>, and <strong>Linux (</strong><code>amd64</code> <strong>/</strong> <code>arm64</code><strong>)</strong>.</li>
<li>Running <code>./ordercraft --app-mode</code> automatically detects Chromium, Brave, or Edge and launches the terminal inside a native, frameless desktop application window.</li>
</ul>
<h3>2. Concurrent Go WebSocket Fan-In / Fan-Out Coordinator</h3>
<p>Financial charting requires sub-second tick updates across multiple symbols and timeframes simultaneously. In <code>internal/server/hub.go</code> and <code>internal/datafeed/</code>:</p>
<ul>
<li>The Go backend manages upstream WebSocket streams and REST polling across <strong>Binance</strong>, <strong>Yahoo Finance</strong>, <strong>OANDA v20</strong>, <strong>Alpaca</strong>, and <strong>TwelveData</strong>.</li>
<li>Incoming ticks are normalized, aggregated into live OHLCV bars in memory, and fanned out over a local WebSocket hub to all subscribed chart panes in the browser.</li>
</ul>
<h3>3. Pure-Go SQLite Persistence (<code>0600</code> Permissions)</h3>
<p>All historical OHLCV candle caches, multi-pane workspace layouts, custom chart drawings, indicator templates, and BYOK (Bring Your Own Key) brokerage credentials are stored in a local SQLite database:</p>
<ul>
<li>Historical bars are cached locally so switching timeframes or scrolling back in history is instantaneous.</li>
<li>API keys (OANDA, Alpaca, TwelveData) are stored strictly on your local disk with <code>0600</code> file permissions (<code>0700</code> directory permissions) and are masked (<code>AKIA••••••••1234</code>) across all status endpoints so raw secrets are never exposed back to the browser.</li>
</ul>
<h3>4. Custom Canvas 2D Drawing Primitives (<code>ISeriesPrimitive</code>)</h3>
<p>While <code>lightweight-charts</code> (Apache-2.0) provides fast HTML5 Canvas candlestick rendering, it does not ship with interactive drawing tools out of the box. We built a custom Canvas 2D drawing engine from scratch supporting:</p>
<ul>
<li><strong>Trendlines, Rays &amp; Extended Lines</strong> (with OHLC magnet snapping)</li>
<li><strong>Fibonacci Retracements</strong> with customizable levels</li>
<li><strong>Parallel Channels &amp; Shaded Rectangles</strong></li>
<li><strong>Long &amp; Short Risk-Reward Position Calculators</strong> with interactive Entry, Take-Profit, and Stop-Loss drag handles</li>
<li><strong>Multi-Pane Synchronized Workspaces:</strong> Split your screen into <code>1x1</code>, <code>2V</code>, <code>2H</code>, <code>3</code>, or <code>4</code>-pane grids with synchronized crosshairs, symbols, and timeframes.</li>
</ul>
<h3>5. Hardening a <code>127.0.0.1</code> Server Against Cross-Tab Browser Attacks</h3>
<p>One overlooked attack surface in local-first web apps is <strong>Localhost CSRF &amp; Cross-Site WebSocket Hijacking</strong>. If a local server sets <code>Access-Control-Allow-Origin: *</code> or skips WebSocket <code>Origin</code> checks, any malicious website open in another browser tab can query <code>[http://127.0.0.1:3000/api/](http://127.0.0.1:3000/api/)*</code> and read user data.</p>
<p>Before releasing <code>v0.1.0</code>, we hardened the Go HTTP/WebSocket server to enforce:</p>
<ul>
<li>Strict loopback <code>Origin</code> validation (<code>localhost</code>, <code>127.0.0.1</code>, <code>[::1]</code>) on both REST preflight/mutation handlers and the WebSocket upgrader.</li>
<li>Upstream URL path and query escaping (<code>url.PathEscape</code> / <code>url.QueryEscape</code>) across all provider adapters to prevent SSRF/path traversal.</li>
<li><code>http.MaxBytesReader</code> payload caps and Slowloris connection timeouts (<code>ReadHeaderTimeout</code>, <code>ReadTimeout</code>, <code>WriteTimeout</code>).</li>
</ul>
<hr />
<h2>⚡ Try It Out in 10 Seconds</h2>
<p>You can grab the prebuilt <code>v0.1.0</code> binary for Windows, macOS, or Linux directly from our <a href="https://github.com/ordercraft-hq/terminal/releases/latest"><strong>GitHub Releases</strong></a> page, or build from source:</p>
<pre><code class="language-bash">git clone https://github.com/ordercraft-hq/terminal.git
cd terminal
# Run in native frameless desktop window mode:
./ordercraft --app-mode
</code></pre>
<p>Out of the box, it streams live crypto (<code>BINANCE:BTCUSDT</code>, <code>ETHUSDT</code>, etc.) and equity data (<code>AAPL</code>, <code>NVDA</code>, <code>SPY</code>) with zero configuration or API keys required.</p>
<p>I'd love for you to check out the repository, give it a ⭐ on GitHub if you find local-first tools useful, and let me know in the comments (or in <a href="https://github.com/ordercraft-hq/terminal/discussions">GitHub Discussions</a>) what indicators or market data providers (IBKR, Polygon, local CSV/Parquet backtest replay) you'd like to see in <code>v0.2.0</code>!</p>
<p>👉 <strong>GitHub Repository:</strong> <a href="https://github.com/ordercraft-hq/terminal">https://github.com/ordercraft-hq/terminal</a></p>
]]></content:encoded></item></channel></rss>