Nikola
Tesla EV Companion App with an Interactive 3D Garage
Rust (Axum, Tokio) · React 19 (TypeScript) · Three.js / React Three Fiber · SQLite (SQLx) · Cloudflare Workers · Protocol Buffers (prost)
Overview
Nikola is a full-stack Tesla companion app pairing real-time vehicle telemetry and remote controls with an interactive, fully rendered 3D Model 3 that reacts to your car live in the browser. It features a real-time 'Light Lab' for tuning headlights, taillights, and hazards, plus detailed charging analytics including cost per mile, cost per kWh, carbon emissions, and gas vehicle cost comparisons. The Rust backend implements the full Tesla Vehicle Command Protocol (TVCP) signing pipeline required by all 2024+ Tesla firmware.
Highlights
- Built an interactive 3D Tesla Model 3 rendered in-browser with Three.js and React Three Fiber: custom GLTF model with hand-tuned PBR materials, procedurally generated tires, a reflective studio floor, orbiting camera controls, and Bloom post-processing for real headlight/taillight beams and glow
- Created 'Light Lab', a real-time lighting studio: live sliders drive a custom light rig, beam, and glow system to control headlights, taillights, and hazards on the 3D model with instant visual feedback
- Built full Tesla Fleet API integration: real-time vehicle telemetry (battery, range, drive state, location, charging metrics), remote vehicle controls (trunk, charge port open/latch, flash lights, climate, wake), and charging history with per-session cost breakdowns and invoice retrieval
- Implemented the full Tesla Vehicle Command Protocol (TVCP) signing pipeline in Rust: P-256 ECDH key exchange → SHA-1 KDF → AES-128 key → HMAC-SHA256 subkey via 'authenticated command' derivation → TLV-encoded metadata signing → Protocol Buffer serialization → signed RoutableMessage over HTTPS
- Engineered Virtual Key pairing via RFC 8615 .well-known endpoint: registered P-256 public key with Tesla, implemented one-time vehicle pairing via deep link, verified pairing cryptographically via live vehicle_data fetch
- Implemented OAuth 2.0 with PKCE for Tesla auth with SQLite-backed (SQLx) session and token persistence: server-side-only token storage (frontend never sees tokens) and automatic token refresh with a 60-second expiry buffer to prevent race conditions
- Managed two independent TVCP signing domains (VCSEC=2 for structural commands, Infotainment=3 for cabin controls) with per-domain session caching, monotonic anti-replay counters, and automatic session resync on epoch/counter fault
- Diagnosed and resolved multiple undocumented TVCP edge cases: from_destination must be 16 random bytes (not the 65-byte public key); FLAGS_ENCRYPT_RESPONSE = 2 (bit 1, not 1); P-256 key loading requires fallback DER parser for Tesla's explicit-curve-parameter encoding