AIS vessel analytics
A live data system for ship traffic. It ingests Digitraffic AIS messages over MQTT into PostgreSQL, runs an ETL loop every 30 seconds, projects each vessel's next positions and serves them through a FastAPI API and a map dashboard.

The problem
Ships around Finland broadcast their position, speed and heading over AIS, and Finland’s Digitraffic service republishes those messages as a live MQTT feed. The data is free and it never stops. The job was to turn that stream into something a person can look at: where each vessel is now and where it is likely to be in the next few minutes.
What we built
The system has four parts, and each one does a single job.
- Ingestion. A subscriber listens to the Digitraffic topics and writes every raw position message and every vessel metadata update into PostgreSQL. Raw data is kept as it arrived, so any prediction can be traced back to the message it came from.
- Storage. Three tables:
vesselsfor metadata,ais_messagesfor the raw stream, andais_predictions, which links each prediction back to its source message. - ETL loop. Every 30 seconds it pulls the last 30 minutes of messages, drops stale rows and position jumps larger than a set limit, builds motion features and writes new predictions.
- Serving. FastAPI exposes the latest vessel state, the ETL status and the raw data as JSON or CSV. A small Leaflet dashboard shows live markers and the projected tracks.
Why the simple model stayed
We tested XGBoost against a plain constant-velocity projection. XGBoost was not clearly better, and it would have added retraining, model files and more ways for a live loop to fail. So the deployed predictor is constant velocity, and XGBoost stays in the repository as a comparison. For a system that has to keep running unattended, the simpler model was the right call.