Delivered remotely for a business based in Tallinn, Estonia. Names withheld by agreement.
Project Overview
Digital asset ownership rarely lives in a single custody account. A typical investor in Tallinn holds Bitcoin across cold-storage UTXO addresses, stakes assets on Ethereum or Solana validators, provides concentrated liquidity in decentralized exchanges, and executes spot trades across multiple centralized venues. Standard spreadsheet trackers break down under 18-decimal token units, wrapped assets, cross-chain bridges, and overlapping exchange fee currencies.
We built a cryptocurrency portfolio tracker powered by TypeScript, Node.js, and Redis to turn fragmented on-chain and off-chain activity into one continuously valued, tax-reconciled ledger. The system ingests read-only wallet addresses and exchange API keys, streams real-time market valuations over WebSockets, and runs deterministic cost-basis calculations aligned with European digital asset reporting expectations.
Fragmented Asset Visibility
Building reliable crypto analytics requires solving data-integrity challenges that traditional equity trackers never encounter:
- Token precision drift: Standard IEEE-754 floating-point math introduces silent dust errors across wei-scale quantities and micro-cap liquidity tokens.
- Unmatched internal transfers: Moving assets from an exchange to a hardware wallet looks like a taxable sale unless outbound and inbound legs are paired across venues.
- Noisy spam airdrops: Public EVM and Solana addresses accumulate malicious or worthless dust tokens that distort portfolio totals and chart scales unless filtered.
- Heterogeneous rate limits: Aggregating dozens of RPC providers and exchange REST endpoints simultaneously without centralized coordination triggers IP bans and partial syncs.
Architectural Strategy
Our engineering approach separated fast ephemeral market state from immutable historical ledger truth. Live spot prices, order-book reference feeds, user session subscriptions, and distributed API rate limiters live inside Redis for low-latency in-memory coordination. Canonical transaction histories, transfer-matching overrides, and realized tax lots persist in PostgreSQL alongside TimescaleDB historical candle series.
By keeping TypeScript shared across the Node.js ingestion workers, WebSocket gateway, and Next.js frontend, exact schema definitions and arbitrary-precision serialization formats remain identical from blockchain RPC decoding down to browser table rendering.
Core Capabilities
- Unified Multi-Chain & CEX Aggregation: Connects read-only exchange keys, EVM chains, Bitcoin XPUB descriptors, and Solana addresses into one normalized event stream.
- Real-Time Mark-to-Market Streaming: Redis Pub/Sub pushes spot price ticks through a Node.js WebSocket layer, updating unrealized P&L and allocation weights without page reloads.
- Smart Transfer & Bridge Pairing: Automatically links wallet-to-wallet movements, wrapped token conversions, and bridge exits to carry forward original cost basis.
- DeFi Yield & Staking Accounting: Separates principal LP deposits, claimed rewards, and protocol gas fees so income events and capital disposals remain distinct.
- Deterministic Tax-Lot Engine: Computes realized gains under FIFO, LIFO, HIFO, or specific-identification rules with point-in-time EUR/USD fiat conversion via TimescaleDB.
Technical Architecture
Ingestion begins when a user links an address or read-only exchange credential in Next.js. Node.js workers enqueue scoped backfill jobs onto Redis Streams, acquiring distributed token-bucket permits before querying RPC nodes or exchange endpoints. Raw payloads normalize into typed double-sided ledger movements (acquisition, disposal, fee, transfer, reward) stored in PostgreSQL.
Flow: Chain RPCs & CEX APIs → Node.js Rate-Limited Adapters (Redis Token Buckets) → Event Normalizer & Transfer Matcher → PostgreSQL Canonical Ledger + TimescaleDB FX/Candles → Redis Valuation Cache & Pub/Sub → Node.js WebSocket Gateway → Next.js Dashboard
Whenever the cost-basis worker replays a wallet's chronological event stream, it commits immutable lot-consumption rows and publishes a cache-invalidation signal via Redis. Connected Next.js clients receive fresh valuation vectors immediately while historical tax reports stream out asynchronously as verifiable CSV or PDF audit packets.
Technology Stack
| Category | Technology detail |
|---|---|
| Web Dashboard | Next.js with TypeScript interactive holdings tables, allocation charts, and tax views |
| Ingestion & API Runtime | Node.js and TypeScript services coordinating wallet syncs, exchange adapters, and REST APIs |
| Real-Time Cache & Bus | Redis Pub/Sub, Streams, and Sorted Sets for live ticks, rate limits, and job queues |
| Ledger Storage | PostgreSQL persisting canonical wallet events, cost-basis lots, and reconciliation rules |
| Historical Pricing | TimescaleDB storing OHLCV candles and historical fiat FX rates for point-in-time cost basis |
| Live Streaming | Node.js WebSocket gateway broadcasting Redis price deltas to subscribed browser sessions |
| Precision Arithmetic | Arbitrary-precision Decimal/BigInt math avoiding IEEE-754 rounding drift across 18-decimal tokens |
| Chain & CEX Adapters | Modular TypeScript connectors for EVM chains, Solana, Bitcoin UTXO, and read-only exchange APIs |
| Tax Export Engine | Streaming CSV and PDF lot-disposition generators supporting FIFO, LIFO, and HIFO methods |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| Live market ticks across thousands of tokens saturate database reads | Stored normalized latest prices and asset-to-user subscription indexes in Redis, reducing PostgreSQL reads to historical ledger queries at the expense of maintaining cache warm-up routines. |
| Out-of-order historical CSV imports invalidate downstream FIFO cost basis | Designed an event-sourced lot-recomputation pipeline triggered per affected asset stream; importing old records replays only the impacted asset's lot queue rather than the entire account. |
| Malicious spam tokens clutter holdings and skew valuation charts | Integrated Redis-cached token-reputation registries and liquidity-depth checks that quarantine unverified tokens from net-worth sums while keeping raw transactions inspectable. |
| Node.js single-threaded event loop stalls during large multi-year tax exports | Offloaded heavy lot-matching and PDF/CSV streaming to isolated Node.js worker processes fed by Redis Streams, keeping the API and WebSocket gateway responsive under load. |
Security & Read-Only Custody Boundaries
Portfolio trackers attract phishing and credential-stuffing pressure because they sit adjacent to user wealth. Every exchange integration enforces strictly read-only API permissions—rejecting keys with withdrawal or trade scopes during initial validation—and encrypts stored secrets using envelope encryption with per-tenant keys.
On-chain tracking requires only public addresses or extended public keys (xpub/zpub), guaranteeing private signing keys never touch application servers. Publicly shareable portfolio views use stripped projection payloads that mask exact wallet addresses and sensitive transaction hashes.
Throughput & Streaming Scale
During volatile market sessions, incoming price feed updates spike dramatically while users simultaneously trigger portfolio refreshes. Node.js price-aggregator processes coalesce rapid exchange ticker bursts inside Redis pipelines, publishing throttled state deltas over WebSockets so browser DOM reconciliation stays smooth.
Backfill jobs scale horizontally across worker containers consuming Redis Stream consumer groups. Each blockchain adapter isolates chain-specific retry policies and finality buffers, ensuring congestion on one network never delays valuation updates or tax calculations on another.
Operational Outcomes
Unifying real-time Redis state streaming with an exact TypeScript accounting ledger delivered dependable clarity for digital asset holders and tax professionals:
- Consistent multi-venue visibility: Cold wallets, exchange balances, and active DeFi positions resolve into one continuously updated net-worth picture.
- Exact decimal integrity: Arbitrary-precision arithmetic eliminates penny and dust discrepancies between transaction logs and annual tax exports.
- Audit-ready tax trails: Every realized gain links back to specific acquisition timestamps, historical TimescaleDB FX rates, and matched transfer pairs.
- Resilient sync execution: Distributed Redis rate limiting and consumer-group workers absorb high-volume wallet backfills without degrading live dashboard responsiveness.