Backend
Боевой бэкенд (пакет app в backend/): принимает поток NDTP-телеметрии от терминалов
(и эмулятора), сопоставляет его с расписанием, считает производные признаки, получает прогнозы
ML-сервиса в горизонте 10–15 минут, поднимает алерты и отдаёт всё диспетчерскому дашборду.
Поток данных:
терминалы / эмулятор ──TCP:9201──▶ ndtp.server ─┐
traffic.csv (история) ──────────▶ ingest.replay ─┴─▶ ingest.pipeline ──▶ state.fleet
(unit → ТС, датасетные часы)
state.fleet ──▶ predict.predictor ──HTTP──▶ ML-сервис
│
├──▶ alerts ──▶ api.ws (WebSocket) ──▶ дашборд
└──▶ db.history (Postgres)
Спецификация HTTP API — Swagger UI бэкенда: https://api.mowtransit.ru/docs
(локально http://localhost:8000/docs). Подробности, замеры и инструкции — backend/README.md.
Модули
FastAPI application: starts telemetry ingest (NDTP listener + dataset replay) and serves the API. |
|
Runtime settings, read from environment variables (and |
|
Dataset clock: maps wall-clock time onto the dataset's timeline. |
|
NDTP wire codec: stream framing, CRC, and decoding of what the telematics terminals send. |
|
NDTP TCP server: accepts terminal connections and turns their byte streams into navigation fixes. |
|
The normalized telemetry point every downstream component works with. |
|
Loading |
|
Ingest pipeline: NDTP fixes and replayed rows become |
|
Replay source: plays |
|
The planned schedule: every vehicle's stop visits for the day, indexed for arrival detection. |
|
Arrival detection from GPS: when did a vehicle actually reach each planned stop. |
|
Per-vehicle state: telemetry buffer, arrivals log, and the features derived from them. |
|
HTTP client for the ML service ( |
|
Building ML |
|
The predictor: every tick, finds each vehicle's target stop 10–15 minutes ahead and gets a delay forecast. |
|
Alerts: turns red forecasts into dispatcher alerts and checks them against what actually happened. |
|
Write-behind history store. |
|
Dashboard views: routes, vehicles and schedules in the shapes |
|
The dashboard's REST API — the calls |
|
WebSocket push to dashboards: |