DEV Community

Ricardo Saumeth
Ricardo Saumeth

Posted on

โญ ๐—ฃ๐—”๐—ฅ๐—ง ๐Ÿฏ โ€” ๐—ช๐—ต๐—ฒ๐—ฟ๐—ฒ ๐—”๐—œ ๐—ฆ๐˜๐—ฟ๐˜‚๐—ด๐—ด๐—น๐—ฒ๐˜€ (๐—ฎ๐—ป๐—ฑ ๐—ช๐—ต๐˜† ๐—ฆ๐—ฒ๐—ป๐—ถ๐—ผ๐—ฟ ๐—˜๐—ป๐—ด๐—ถ๐—ป๐—ฒ๐—ฒ๐—ฟ๐˜€ ๐— ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ)

๐—”๐—œ ๐—ฎ๐—ฐ๐—ฐ๐—ฒ๐—น๐—ฒ๐—ฟ๐—ฎ๐˜๐—ฒ๐˜€ โ€” ๐—ฏ๐˜‚๐˜ ๐—ถ๐˜ ๐—ฑ๐—ผ๐—ฒ๐˜€๐—ปโ€™๐˜ ๐˜‚๐—ป๐—ฑ๐—ฒ๐—ฟ๐˜€๐˜๐—ฎ๐—ป๐—ฑ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป.
๐ˆ๐ญ ๐ก๐ž๐ฅ๐ฉ๐ž๐ ๐š ๐ฅ๐จ๐ญ โ€” ๐›๐ฎ๐ญ ๐ข๐ญ ๐š๐ฅ๐ฌ๐จ ๐ฆ๐ข๐ฌ๐ฌ๐ž๐ ๐ญ๐ก๐ข๐ง๐ ๐ฌ ๐ญ๐ก๐š๐ญ ๐จ๐ง๐ฅ๐ฒ ๐ž๐ฑ๐ฉ๐ž๐ซ๐ข๐ž๐ง๐œ๐ž ๐œ๐š๐ญ๐œ๐ก๐ž๐ฌ.

๐—˜๐—ฑ๐—ด๐—ฒ ๐—ฐ๐—ฎ๐˜€๐—ฒ๐˜€
AI suggested basic heartbeat handling but missed a key nuance: stale detection must be perโ€‘channel, not global.

My initial implementation cleared all stale flags when any message arrived.
That keeps the UI green โ€” but it hides channelโ€‘specific failures.

Bitfinex channels can fail independently, so each subscription needs its own stale timer.

Thatโ€™s the kind of detail you only learn by shipping real systems.

๐—ฃ๐—ฒ๐—ฟ๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐—ป๐—ฐ๐—ฒ ๐˜๐—ฟ๐—ฎ๐—ฑ๐—ฒโ€‘๐—ผ๐—ณ๐—ณ๐˜€
AI defaulted to slice() everywhere.
I knew splice() was better for highโ€‘frequency, inโ€‘place updates.

๐—”๐—ฃ๐—œ ๐—พ๐˜‚๐—ถ๐—ฟ๐—ธ๐˜€
Bitfinex sends different formats for snapshots vs updates.

AI understood the idea, but not the exact formats โ€” for example:

  • Snapshot: [channelId, [trade1, trade2]]
  • Update: [channelId, 'te', trade]

These quirks matter. They break your parser if you donโ€™t know them.

๐Œ๐ž๐ฆ๐จ๐ซ๐ฒ ๐ฆ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ
AI didnโ€™t understand memoryโ€‘bounded arrays.

Without limits, 8 hours of trading data becomes:
288,000 updates ร— 10 pairs = a multiโ€‘GB memory leak.

The app enforces:

  • MAX_TRADES = 1000
  • MAX_CANDLES = 5000

This keeps memory stable at ~60MB instead of creeping past 2GB and crashing.

๐—ฃ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—ฐ๐—ผ๐—ป๐—ฐ๐—ฒ๐—ฟ๐—ป๐˜€ ๐€๐ˆ ๐๐ข๐๐งโ€™๐ญ ๐œ๐จ๐ง๐ฌ๐ข๐๐ž๐ซ

  • Handlerโ€‘based architecture (trades, tickers, candles, book)
  • 90โ€‘second stale timeouts with 30โ€‘second monitoring intervals
  • Exponential backoff (5 attempts, increasing delays)
  • Performance tracking via performanceTracker.updateLatency()
  • Environmentโ€‘configurable limits (VITE_MAX_TRADES)

These arenโ€™t โ€œnice to havesโ€ โ€” theyโ€™re what keep realโ€‘time systems alive.

๐“๐ก๐ž ๐ซ๐ž๐š๐ฅ๐ข๐ญ๐ฒ
Building a crypto trading dashboard made one thing clear:

AI is incredible at scaffolding โ€” but productionโ€‘grade realโ€‘time systems require architectural judgment that only comes from experience.

AI accelerates โ€” but it doesnโ€™t understand production.
Thatโ€™s where senior engineers still make the difference

๐—ช๐—ฟ๐—ถ๐˜๐˜๐—ฒ๐—ป ๐—ฏ๐˜† ๐—ฅ๐—ถ๐—ฐ๐—ฎ๐—ฟ๐—ฑ๐—ผ ๐—ฆ๐—ฎ๐˜‚๐—บ๐—ฒ๐˜๐—ต
๐—ฆ๐—ฒ๐—ป๐—ถ๐—ผ๐—ฟ ๐—™๐—ฟ๐—ผ๐—ป๐˜โ€‘๐—˜๐—ป๐—ฑ ๐—˜๐—ป๐—ด๐—ถ๐—ป๐—ฒ๐—ฒ๐—ฟ | ๐—ฅ๐—ฒ๐—ฎ๐—นโ€‘๐—ง๐—ถ๐—บ๐—ฒ ๐—จ๐—œ ๐—ฆ๐—ฝ๐—ฒ๐—ฐ๐—ถ๐—ฎ๐—น๐—ถ๐˜€๐˜

Top comments (0)