Inspiration
What it does�
� RoadGenie: AI-Powered Smart Driving Assistant Comprehensive Project Documentation & Technical Submission Category: Artificial Intelligence & Mobility Solutions Goal: To mitigate driver distraction and optimize daily commutes using predictive and conversational AI.
- Executive Summary & Core Innovation 1.1 The Market Need The current in-car technology landscape is fragmented. Drivers juggle separate apps for:
- Navigation (Route Planning): Often providing generic, unreliable ETAs.
- Entertainment (Music): Requiring manual selection and control.
- Communication (Voice Assistants): Offering limited integration with driving context. This results in high cognitive load, increased screen interaction, and ultimately, compromised driver safety and efficiency. 1.2 RoadGenie's Disruptive Solution: The Unified Driver Hub RoadGenie solves this fragmentation by consolidating all essential driving services into a single, intelligent Progressive Web App (PWA) interface. We leverage a multi-modal AI approach to automate decision-making and enhance the driving experience safely. The Three Pillars of RoadGenie's AI:
- Predictive ML (Route Time): Provides Hyper-accurate, Personalized ETAs by modeling historical traffic data against live route parameters.
- Generative AI (Gemini): Enables Safe, Hands-Free Conversational Control and provides context-aware information retrieval.
- Recommendation ML (Music): Optimizes Driver State by curating mood-based music playlists, with the potential for dynamic selection based on real-time driver state detection. Value Proposition: RoadGenie delivers unparalleled trip predictability and safety, reducing commuter stress by unifying previously disparate systems.
- Technical Architecture & Component Deep Dive RoadGenie utilizes a production-ready, modular, and API-driven architecture built on Django's robustness, ensuring high maintainability and performance. 2.1 System Architecture Overview The backend is composed of four distinct, decoupled Django applications, communicating primarily through the Django REST Framework (DRF). The frontend acts as a single-page application (SPA) shell, communicating exclusively via secure REST API calls. Layer Component (Django App) Frontend PWA Dashboard Backend Accounts Service Backend Routes Service Backend ML Inference Service Key Technologies Used HTML5, CSS (Flex/Grid), Vanilla JS, Leaflet.js Django Authentication, SQLite Django Models, DRF Primary Service Role and Security Single-page UI, Offline Caching, Map Rendering, CSRF-Secured API consumption. User management, secure session handling, and storing personalized driver preferences (Mood). Manages the Trip data lifecycle (saving/retrieval) and historical trip context. Django, Scikit-learn, Joblib Predictive Hub: Loads and exposes trained Machine Learning models in-memory for fast, stateless inference. Backend Gemini AI Proxy External Mapping & Routing Django, Google GenAI SDK OpenStreetMap/OSRM 2.2 Backend Service Breakdown (Django Apps) A. Accounts Service (Authentication & Profile) Secure AI Gateway: Proxies conversational input to the external Gemini service, protecting the API key. Provides base geospatial road network data, polyline geometry, and raw distance/duration features. ● Purpose: Securely manages user identity, session state, and personalization settings. ● Key Model: UserProfile. This extends the default Django User model via a OneToOneField to store the mandatory preferred_music_mood (e.g., 'calm', 'pump-up'). ● Functionality: Uses Django's robust built-in authentication views for login/logout and a custom UserRegisterForm to include profile preferences during signup. B. Routes Service (Trip Persistence) ● Purpose: Stores user travel history and serves as the primary data persistence layer for navigation data. ● Key Model: Trip. Stores source/destination names, precise coordinates (for map redraws), calculated distance_km, and the crucial ML-derived predicted_time_minutes. ● API Endpoint: A REST API endpoint, utilizing DRF's ListCreateAPIView, enforces user authentication and ensures users can only access their own trip history, adhering to strict data privacy principles. C. ML Inference Service ● Purpose: Provides fast, in-memory serving of pre-trained models. ● Initialization: Models (route_model.joblib and music_data.joblib) are loaded once into global variables when the Django server starts. This eliminates disk I/O latency for every API request, achieving near real-time inference speed. ● Route Prediction API: Receives raw coordinates, handles external mapping service calls (OSRM) for feature engineering, and passes the resulting numerical vector to the loaded Scikit-learn model. ● Music Recommendation API: Reads the user's preferred mood and performs efficient Pandas dataframe filtering on the loaded music data structure. D. Gemini AI Proxy Service ● Purpose: Acts as a secure intermediary between the frontend and the Google Gemini API. ● Security: This is the only component that holds the Gemini API key, preventing exposure in the client-side code. ● Process: The view receives the user's chat message, constructs the API payload, sets the System Instruction (defining the AI persona), and returns the generated text response, ensuring safety and focus. 2.3 Machine Learning Pipeline Deep Dive A. Route Time Predictor (Random Forest Regressor) ● Model Training: The model is trained on synthetic data simulating varying traffic conditions based on time of day and road factors. ● Feature Engineering Rationale: The model's success relies on augmenting simple distance with temporal features: ○ Distance/Speed: The baseline is established by the OSRM raw duration, which is then adjusted. ○ Contextual Features (hour, day_of_week): These capture non-linear, peak-time congestion effects that standard distance calculations miss. For example, a 10km trip at 8:00 AM on a Monday will receive a higher predicted time (traffic factor) than the same trip at 11:00 AM on a Saturday. B. Mood-Based Music Recommender ● Implementation: The core logic is built around structured data filtering. The music_data object acts as a simple vector space for content-based recommendations. ● Extensibility: This architecture is designed to easily swap in more complex techniques, such as TF-IDF vectorization or collaborative filtering, without altering the frontend API contract.
- Core Functionality & Detailed Feature Breakdown 3.1 User Experience (UX) and Frontend Logic The frontend is structured as a module pattern (Vanilla JS) that manages all state and interacts with the Leaflet map and the various backend APIs. Feature Area Map Rendering Route Processing PWA & Offline Chat Interaction JavaScript Logic Detail initMap() function findRouteAndPredic t() updatePWAStatus(), service-worker.js sendMessage() function 3.2 Progressive Web App (PWA) Implementation Data Flow Initializes the Leaflet map, adds OpenStreetMap tiles, and uses L.marker and the specialized L.Polyline.fromEncoded() utility to draw the route path and markers based on data received from the ML API.
- Geocoding: Uses asynchronous calls to the Nominatim service (or coordinates if provided) to resolve location strings to Lat/Lon pairs. 2. ML Call: Posts coordinates to the ML Inference Service. 3. Visualization: Upon receiving the polyline and predicted time, it updates the ETA display and redraws the map boundary (map.fitBounds()). Uses navigator.onLine to update the UI status. The Service Worker intercepts all requests, using the cached ML models and cached API data when the network is unavailable. Captures user input, displays it immediately, and sends the payload to the Gemini AI Proxy. The returned response is then appended to the chat window, maintaining chat history scrolling. The PWA status ensures the application functions as a reliable, installable application on mobile devices. ● Service Worker Lifecycle:
- Installation (install event): Pre-caches the application shell, including all HTML, CSS, JavaScript, and critically, the ML model files in the static directory.
- Activation (activate event): Manages cache versioning and cleanup, ensuring only the latest assets are used.
- Fetch Strategy: Implements a Cache-First, Network-Fallback strategy for static assets and a Network-Only/Offline-Fail strategy for real-time services (Gemini/ML Prediction) where old data is unacceptable. 3.3 Mandatory Feature: Dedicated Feedback System The Feedback System is the keystone for the future of the predictive model, closing the loop between AI output and user experience. ● Purpose: To capture the actual success or failure of a predicted route (did the ML prediction match the user's experience?) and user satisfaction with the music recommendations. ● Data Model: The Feedback model captures the user, a discrete rating (1-5), and qualitative comments. ● Strategic Value: The recorded data—especially low ratings—will be combined with the original Trip parameters to flag historical prediction failures. This data set will be used to generate the loss function for future model retraining in a Reinforcement Learning approach.
- Visual Documentation & Key Screens This section provides visual evidence of RoadGenie's core functionality, user interface (UI), and critical features. 5.1 Authentication and Onboarding The login screen provides a seamless entry point, using Django's secure authentication pipeline. The registration process ensures we capture the user's preferred music mood (Initial state for Recommendation ML). Screenshot [--- INSERT SCREENSHOT HERE ---] Description Authentication Screen: Displays the clean, mobile-friendly login interface, supporting both traditional email/password and future planned social login integration (mocked Google button). 5.2 The Unified Dashboard & Route Planning The core dashboard unifies the map, route planning, and real-time metrics, eliminating the need to switch applications. Screenshot [--- INSERT SCREENSHOT HERE ---] [--- INSERT SCREENSHOT HERE ---] [--- INSERT SCREENSHOT HERE ---] 5.3 Conversational AI & Safety Description Primary Dashboard (New York Context): Shows the overall responsive layout. The main map dominates the left, while the Music and Assistant panels are logically grouped on the right. Primary Dashboard (US Context): Demonstrates the map rendering capabilities for longer-distance planning, clearly displaying the Real-Time Metrics section below the map. Route Planning and ML Metrics: Shows the Leaflet map successfully displaying the calculated polyline route. The Real-Time Metrics panel highlights the ML-derived ETA Optimization (predicted time) and estimated Fuel Saving. The Gemini Assistant provides a hands-free method of interacting with the application, ensuring driver focus remains on the road. Screenshot [--- INSERT SCREENSHOT HERE ---] 5.4 Affective Computing & Music Player Description Gemini Assistant Interaction: Displays the dedicated chat panel. The user's query ("What's the current traffic like on my route?") triggers a response from the Gemini AI Proxy, which maintains a context-aware conversation flow and offers quick action buttons (e.g., "Traffic update," "Song suggestion"). The music panel integrates the Recommendation ML pillar, focusing on driver well-being. Screenshot [--- INSERT SCREENSHOT HERE ---] [--- INSERT SCREENSHOT HERE ---] 5.5 Data Persistence and Feedback Loop Description Music Player (Calm Vibe): Shows the dedicated music panel displaying the currently playing track and the curated playlist (UP NEXT). Crucially, the "Detect Mood" button activates the Real-Time Affective Computing feature (Future Roadmap). Mood Detection Modal: Displays the dedicated overlay for the camera-based mood detection feature. This visual confirms the planned integration of the CV model for real-time driver state analysis. Historical data management and the mandatory feedback mechanism are vital for continuous improvement and system reliability. Screenshot [--- INSERT SCREENSHOT HERE ---] [--- INSERT SCREENSHOT HERE ---] Description Trip History: Shows the persistent data saved by the Routes Service. Each entry displays key details (start, end, distance, predicted time), providing data for the PWA's offline history feature and the basis for ML retraining. Feedback Integration: (Implied via button on top right) The Feedback button provides a direct, low-friction mechanism for users to submit data used to refine the ML model's prediction accuracy (Reinforcement Learning).
- Scalability and Future Roadmap The modular Django design ensures RoadGenie is ready for high-impact scaling and feature expansion. 6.1 Immediate Enhancements (Post-Hackathon Priority) ● Real-Time Affective Computing (Camera-Based Mood Detection): Highest priority feature. Integration of a lightweight computer vision (CV) library (e.g., TensorFlow.js or OpenCV) to analyze the driver's facial expressions via the device camera. This will allow the Music Recommendation service to dynamically and automatically switch music moods (e.g., from 'calm' to 'pump-up' if fatigue is detected or 'mellow' if stress is high), transitioning the system from preference-based to real-time driver state optimization. ● Voice Control Implementation (Web Speech API): Fully integrate frontend microphone access to map voice commands (e.g., "RoadGenie, I'm stressed, play mellow music") to the corresponding backend API calls, eliminating manual touch interaction. ● Hybrid Traffic Data Fusion: Integrate a third-party real-time traffic API. The ML prediction service will then consume both its historical prediction and the live latency data to provide the most accurate ETA possible. ● Real Music Service Integration: Transition from mock playback to a commercial API (e.g., Spotify SDK), allowing for genuine music streaming and playlist management based on the mood recommendations. 6.2 Long-Term Vision (RL & Advanced Context) ● RL-based Model Fine-Tuning (Self-Learning System): Implement a continuous training pipeline where the Feedback model's rating directly impacts the next iteration of the Route Predictor. The model will learn from its mistakes autonomously. ● Context-Aware Alerts & Interventions: Leverage device sensor data (if available) and geo-fencing to trigger proactive, personalized alerts. Examples include automatically suggesting a rest stop if driving duration exceeds a threshold or adjusting music tempo based on time spent in heavy congestion. ● Multi-User & Fleet Management: Expand the UserProfile and Trip models to support organizational accounts, enabling shared trip planning, optimized scheduling for commercial fleets, and aggregated driver performance metrics.
Log in or sign up for Devpost to join the conversation.