End-to-end engineering of a personal vehicle telemetry platform: configuring the Tesla Fleet Telemetry API, streaming sensor ticks into PostgreSQL/PostGIS, and building a Next.js geospatial visualization web app.
Looking for the energy regression models and charging/driving decisions built on top of this pipeline?
The Core Business Problem
Accessing granular real-time vehicle sensor data (GPS coordinates, instantaneous kW power draw, battery pack temperature, elevation, and sleep states) requires navigating Tesla’s strict Fleet API security architecture (OAuth2 + ECDSA P-256 virtual key pairing) and handling high-frequency time-series storage without waking the car when parked.
Engineered Architecture & Solution
Built a 3-stage production architecture: (1) Registered a Tesla Developer application with `.well-known` public key hosting and mTLS/Webhook telemetry streaming, (2) Designed a partitioned PostgreSQL + PostGIS database (`vehicle_telemetry_ticks` & `drive_sessions`) with Haversine elevation-grade enrichment and sleep-aware polling backoff, and (3) Shipped a Next.js + Mapbox GL web application that renders color-coded `Wh/km` route polylines and live vehicle state.
Tesla Fleet Telemetry — Geospatial Drive & Power Explorer
From Vehicle Sensor Stream to Next.js Geospatial Web App
Tesla Fleet Telemetry API & Virtual Key Pairing
Registered a developer application on the Tesla Developer Portal, generated an ECDSA P-256 public/private key pair hosted at /.well-known/appspecific/com.tesla.3p.public-key.pem, and paired the virtual key to the vehicle to stream real-time telemetry fields (Location, DriveState, ChargeState, ClimateState).
PostgreSQL / Supabase Schema & Trip Segmentation
Raw telemetry packets arrive every 2–5 seconds while driving. An ingestion worker normalizes voltage × current into instantaneous power (kW), detects shift_state transitions (P ➔ D/R ➔ P) to automatically segment discrete trips, and writes spatial coordinates into PostgreSQL.
Next.js App Router + Interactive Map & Telemetry Cockpit
Built a responsive Next.js dashboard that queries aggregated trip summaries and renders color-coded GPS polylines on a map (green = regenerative braking, blue = optimal cruise, red = high-power acceleration/climb) alongside synchronized speed and battery SoC charts.