Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automotive Suite

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.

Features

  • 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

Prerequisites

  • Python 3.7+
  • Kafka broker running (default: localhost:9092)
  • Kafka topic iot_video with Vehicle_Movement events

Quick Start

1. Install Dependencies

For the web dashboard:

pip install fastapi uvicorn[standard] aiokafka python-multipart

For the CLI dashboard:

pip install kafka-python rich

2. Run the Web Dashboard

python app.py

The dashboard will be available at: http://localhost:5001

3. Run the CLI Dashboard

python cli-dash.py

Project Structure

automotiveSuite/
├── 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

Configuration

Environment Variables

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

Kafka Message Format

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"
  }
}

Web Dashboard

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

Speed Color Coding

  • 🟢 Green: ≤ 30 km/h (Low speed)
  • 🟡 Yellow: 31-60 km/h (Medium speed)
  • 🔴 Red: > 60 km/h (High speed)

CLI Dashboard

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

API Endpoints

WebSocket

  • ws://localhost:5001/ws - Real-time data stream

HTTP

  • GET / - Web dashboard
  • GET /api/state - Current vehicle state snapshot
  • GET /static/* - Static assets

Development

Running in Development Mode

# 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.py

Testing Kafka Connection

Use the included utility to test Kafka connectivity:

python magnif.py

Monitoring

The 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

Security Notes

  • 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

Troubleshooting

Common Issues

  1. Kafka Connection Failed

    • Ensure Kafka broker is running on localhost:9092
    • Check if topic iot_video exists
    • Verify network connectivity
  2. No Data Displayed

    • Confirm Vehicle_Movement events are being published
    • Check message format matches expected schema
    • Verify device_id and coordinates are present
  3. Web Dashboard Not Loading

    • Check if port 5001 is available
    • Ensure static files are in the static/ directory
    • Check browser console for JavaScript errors

About

A comprehensive fleet monitoring solution that transforms Kafka vehicle data into actionable real-time dashboards for tracking and managing vehicle fleets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages