Node.js pipeline that predicts stocks in real time, sort of
A Kafka-and-TensorFlow.js demo that streams CSV stock data through topics to a time-series model, training and predicting in parallel.

What it does
This is a server-side wiring demo: CSV files of stock data feed into Kafka topics, one topic dumps logs to MongoDB while another feeds a TensorFlow.js LSTM-style model for real-time prediction. The model trains on stored data, saves weights, then loads them in a consumer to predict the next time-step from seven prior values. Node.js runs the whole show.
The interesting bit
The author uses Kafka’s topic parallelism to separate storage from inference—data lands in MongoDB for later training while the same stream triggers predictions immediately. It’s a clean teaching example of how streaming ML pipelines could work, even if the “real-time” source is just local CSV files.
Key highlights
- TensorFlow.js model built and trained entirely in Node.js, with MinMax-scaled time-series preprocessing
- Kafka topics split the stream: one consumer writes to MongoDB, another runs inference with loaded model weights
- Training/validation split (80/20) with charts stored back to MongoDB for monitoring
- Includes shell scripts (
start.sh,server.sh) to spin up producers and training jobs - ~650 stars, suggesting solid tutorial value for JS developers entering ML ops
Caveats
- No actual live market data feed—source is static CSV files in a
datasetfolder - Client-side abandoned: author mentions React.js research “failed at some aspects” and left it for future work
- Code explicitly noted as unoptimized; architecture and model performance need work
- No benchmarks, accuracy metrics, or comparison to baseline strategies disclosed
Verdict
Good for developers who want to see Kafka + TensorFlow.js plumbing in one repo before building something production-grade. Skip it if you need working trading logic, live data connectors, or a finished UI.