How walker65434/train_prediction works
Train Prediction is a web application for starting train watches and viewing live train status, route details, and predicted delay. Users enter or upload train information, then follow a train on the tracking page. The API gateway manages watch sessions and results; RabbitMQ connects watch requests to the ML service, which fetches live data from RailRadar and produces predictions. The tree also shows a broader set of business analytics pipelines in the ML service. Their exact orchestration and several frontend/API links are not established by the sampled source, so those relationships are left out.
Main entry points: app.js HTTP gateway · App.jsx Web app · TrackPage.jsx Tracking page · watch.controller.js Watch sessions
Components 23
User interface
- Web app
apps/frontend/src/App.jsx - Home page
apps/frontend/src/pages/HomePage.jsx - Ticket upload
apps/frontend/src/components/TicketUploader.jsx - Ticket OCR
apps/frontend/src/lib/ocr.js - Tracking page
apps/frontend/src/pages/TrackPage.jsx - Live metrics
apps/frontend/src/components/LiveMetricsGrid.jsx - Route timeline
apps/frontend/src/components/RouteTimeline.jsx - API client
apps/frontend/src/lib/api.js - Socket client
apps/frontend/src/lib/socket.js
API gateway
- HTTP gateway
apps/api-gateway/src/app.js - Watch sessions
apps/api-gateway/src/modules/watch/watch.controller.js - Watch records
apps/api-gateway/src/modules/watch/watch.model.js - Result endpoint
apps/api-gateway/src/modules/result/result.controller.js - Prediction results
apps/api-gateway/src/modules/result/result.model.js
Async messaging
- Start producer
apps/api-gateway/src/queues/start.producer.js
Prediction service
- Queue consumers
apps/ml-service/app/workers/consumers.py - ETA prediction
apps/ml-service/app/services/prediction_service.py - Loaded model
apps/ml-service/app/core/model_loader.py - Prediction route
apps/ml-service/app/api/routes/predict.py - Business analytics pipelines
apps/ml-service/app/pipelines
Other components
- Train user
- RabbitMQ
- RailRadar live API
Connections 21
- Train user → Web app: uses
- Web app → Home page: routes
- Web app → Tracking page: routes
- Home page → Ticket upload: offers upload
- Ticket upload → Ticket OCR: extracts text
- Tracking page → Live metrics: displays
- Tracking page → Route timeline: displays
- API client → HTTP gateway: HTTP requests
- Socket client → HTTP gateway: socket connection
- HTTP gateway → Watch sessions: routes watch requests
- HTTP gateway → Result endpoint: routes result requests
- Watch sessions → Watch records: creates and counts
- Watch sessions → Start producer: publishes start
- Start producer → RabbitMQ: sends message
- Queue consumers → RabbitMQ: consumes messages
- Queue consumers → ETA prediction: invokes
- ETA prediction → RailRadar live API: fetches live data
- ETA prediction → Loaded model: loads for inference
- HTTP gateway → RabbitMQ: connects
- HTTP gateway → Prediction results: connects database
- Result endpoint → Prediction results: reads result