How berker00/canli_piyasalar works
Canlı Piyasalar is a Node.js service that collects real-time Turkish gold, foreign-exchange, and commodity prices, merges them into an in-memory snapshot, and serves API, SSE, and dashboard clients while periodically persisting JSON. The main runtime flow is the Harem Altın Socket.IO feed → socket client → rate store → HTTP clients and atomic file output. The README documents SSE, dashboard filtering/favorites, health telemetry, and graceful shutdown; some corresponding app routes are outside the sampled excerpt, so their implementation details are not inferred.
Main entry points: store.js Rate Store · socket.js Socket Client · server.js Runtime Bootstrap · app.js Web Dashboard
Components 17
Feed Collection
- Runtime Bootstrap
server.js - Runtime Config
src/config.js - Socket Client
src/socket.js
Rate State
- Rate Store
src/store.js - Live Rate State
src/store.js
HTTP Delivery
- HTTP App
src/app.js - Price API
src/app.js - SSE Stream
src/app.js - Web Dashboard
src/app.js - Health Telemetry
src/app.js
Persistence
- Atomic File Flush
src/store.js - JSON Snapshot
public/tmp/altin.json
Other components
- Harem Altın Feed
- API Consumers
- Dashboard Users
- Browser LocalStorage
- Static File Readers
Connections 24
- Runtime Bootstrap → Runtime Config: reads settings
- Runtime Bootstrap → Rate Store: creates
- Runtime Bootstrap → Socket Client: creates and connects
- Runtime Bootstrap → HTTP App: starts
- Runtime Config → Socket Client: supplies connection config
- Socket Client → Harem Altın Feed: connects and receives
- Socket Client → Rate Store: forwards payloads
- Rate Store → Live Rate State: merges rates
- Rate Store → Atomic File Flush: flushes on interval
- Atomic File Flush → JSON Snapshot: writes then renames
- API Consumers → Price API: requests prices
- Price API → Rate Store: reads snapshot
- Rate Store → Price API: returns snapshot
- Dashboard Users → Web Dashboard: opens dashboard
- Web Dashboard → Rate Store: reads initial state
- Rate Store → SSE Stream: pushes rate updates
- SSE Stream → Dashboard Users: streams events
- Web Dashboard → Browser LocalStorage: saves favorites
- API Consumers → SSE Stream: subscribes
- API Consumers → Health Telemetry: requests telemetry
- Health Telemetry → Rate Store: reads metrics
- Health Telemetry → Socket Client: reads status
- Static File Readers → HTTP App: requests static JSON
- HTTP App → JSON Snapshot: serves file fallback