A real-time vehicle tracking and monitoring system that consumes Kafka messages and provides both web-based and command-line dashboards for visualizing vehicle movement data.
- Real-time Vehicle Tracking: Live monitoring of vehicle positions, speeds, and movement states
- Interactive Web Dashboard: Modern web interface with map visualization and device cards
- CLI Dashboard: Terminal-based dashboard for quick monitoring
- Kafka Integration: Consumes vehicle movement events from Kafka topics
- WebSocket Support: Real-time updates via WebSocket connections
- Responsive Design: Mobile-friendly web interface
- Python 3.7+
- Kafka broker running (default: localhost:9092)
- Kafka topic
iot_videowith Vehicle_Movement events
For the web dashboard:
pip install fastapi uvicorn[standard] aiokafka python-multipartFor the CLI dashboard:
pip install kafka-python richpython app.pyThe dashboard will be available at: http://localhost:5001
python cli-dash.pyautomotiveSuite/
├── app.py # FastAPI web dashboard server
├── cli-dash.py # Terminal-based dashboard
├── magnif.py # Kafka message reader utility
├── static/
│ └── index.html # Web dashboard frontend
└── README.md # This file
| Variable | Default | Description |
|---|---|---|
KAFKA_BOOTSTRAP |
localhost:9092 |
Kafka broker address |
KAFKA_TOPIC |
iot_video |
Kafka topic name |
APP_HOST |
0.0.0.0 |
Web server host |
APP_PORT |
5001 |
Web server port |
The system expects Vehicle_Movement events in the following format:
{
"event": "Vehicle_Movement",
"device_id": "vehicle_001",
"timestamp": 1640995200,
"data": {
"latitude": 17.3850,
"longitude": 78.4867,
"speed": 45.5,
"movement": "acceleration",
"state": "moving"
}
}The web dashboard provides:
- Interactive Map: Real-time vehicle positions with color-coded speed indicators
- Device Cards: Detailed information for each vehicle including speed, movement, and coordinates
- Live Telemetry Table: Tabular view of all vehicle data
- Real-time Updates: WebSocket-based live data streaming
- 🟢 Green: ≤ 30 km/h (Low speed)
- 🟡 Yellow: 31-60 km/h (Medium speed)
- 🔴 Red: > 60 km/h (High speed)
The terminal dashboard provides a live-updating table view with:
- Device ID
- Current speed
- GPS coordinates
- Movement state (acceleration/deceleration/constant)
- Vehicle state (moving/resting)
- Last seen timestamp
ws://localhost:5001/ws- Real-time data stream
GET /- Web dashboardGET /api/state- Current vehicle state snapshotGET /static/*- Static assets
# Install all dependencies
pip install fastapi uvicorn[standard] aiokafka python-multipart kafka-python rich
# Run web dashboard
python app.py
# In another terminal, run CLI dashboard
python cli-dash.pyUse the included utility to test Kafka connectivity:
python magnif.pyThe system tracks the following vehicle metrics:
- Position: GPS coordinates (latitude/longitude)
- Speed: Current velocity in km/h
- Movement: Acceleration/deceleration/constant
- State: Moving/resting status
- Timestamp: Last update time
- CORS is currently set to allow all origins (
*) - tighten for production - No authentication is implemented - add as needed for production use
- WebSocket connections are not secured - consider WSS for production
-
Kafka Connection Failed
- Ensure Kafka broker is running on localhost:9092
- Check if topic
iot_videoexists - Verify network connectivity
-
No Data Displayed
- Confirm Vehicle_Movement events are being published
- Check message format matches expected schema
- Verify device_id and coordinates are present
-
Web Dashboard Not Loading
- Check if port 5001 is available
- Ensure static files are in the
static/directory - Check browser console for JavaScript errors