Migration Guidance: Socket.IO to NATS
Goalβ
Perform an incremental transport migration from Socket.IO trade-feed to NATS with minimal functional disruption.
Backend Service Migrationβ
trade-serviceβ
- Replace Socket.IO publish client usage with NATS publish client.
- Publish validated trade events on
trades.new.
trade-processorβ
- Replace Socket.IO subscribe client with NATS subscription to
trades.new. - Publish account-scoped update events:
trades.account.<accountId>.updatedpositions.account.<accountId>.updated
account-service / position-service / othersβ
- Keep existing REST behavior unchanged.
- Add NATS integration only if service-specific event consumption is required.
Frontend Migrationβ
- Replace Socket.IO subscription client with
nats.ws. - Connect through ingress websocket route (
/nats-ws). - Subscribe to account-scoped wildcard subjects for selected account.
Cutover Strategyβ
- Introduce NATS broker and subject mapping in parallel spec artifacts.
- Migrate producers first (trade-service).
- Migrate consumers (trade-processor, frontend stream path).
- Remove trade-feed runtime references after conformance checks pass.
Post-Migrationβ
- Validate baseline flows F2/F4 still pass.
- Keep JetStream and durable replay out of scope for this state; add in a future state.