A real-time telematics platform for simulating CAN-like vehicle data, streaming it securely, and detecting anomalies using machine learning. Built for hands-on experience with modern telematics, API security, and cloud deployment.
- CAN-like Data Simulation: Generates realistic vehicle telemetry (RPM, temperature, voltage, speed, etc.) with occasional injected faults.
- Real-Time Streaming: Streams live data to clients using FastAPI WebSocket endpoints.
- JWT Authentication: Secures API access and data transmission with industry-standard JWT tokens.
- Anomaly Detection: Uses an Isolation Forest model to flag abnormal vehicle behavior in real time.
- Cloud Deployment: Backend and ML inference deployed on AWS EC2 for scalable, remote access.
- Dashboard Integration: (Planned) Live dashboard for visualization and monitoring.
-
Clone the repository:
git clone https://github.com/Architrawat25/telematics-anomaly-detection.git cd telematics-anomaly-detection -
Set up a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt -
Train the anomaly detection model (optional, if you want to retrain):
- Open
ml/model_training.ipynbin Google Colab or Jupyter. - Run all cells to generate and save
anomaly_detector.joblibin theml/folder.
- Open
-
Start the FastAPI backend:
python -m uvicorn backend.main:app --reload -
Test the WebSocket stream:
- Use the provided
test_ws.pyscript or any WebSocket client. - Obtain a JWT token by sending a POST request to
/token. - Connect to
ws://localhost:8000/ws/vehicle-dataand send the token as the first message.
- Use the provided
- The backend can be deployed on AWS EC2 (Free Tier).
- After deployment, update security groups to allow HTTP/WebSocket traffic.
├── backend/ # FastAPI app and JWT logic ├── simulator/ # CAN-like data generator ├── ml/ # Model training notebook and saved model ├── requirements.txt └── test_ws.py # WebSocket test client
Python, FastAPI, WebSocket, JWT, Scikit-learn, Pandas, AWS
- Real-time CAN-like data simulation
- Secure streaming with JWT authentication
- ML-based anomaly detection
- AWS cloud deployment
- Dashboard integration (coming soon)