How me-sarvar/emo_drive works
Project type and purpose
• EmoDrive is a full-stack web application. The frontend is built with Flutter (Dart) and compiled to a web app. The backend is a Flask (Python) service.
• Purpose: capture passenger facial expressions in real time, detect emotion (using OpenCV), then fetch and recommend Spotify music matching that emotion.
File structure
• Top level:
• README.md, LICENSE.md, .gitignore
• backend/
• ui/
• backend/ directory:
• app.py – main Flask server with REST endpoints
• opencv.py – face/emotion detection logic
• autodelete.py – cleanup script (e.g., temporary files or sessions)
• templates/ and static/ – standard Flask folder layout for any server-rendered pages (index.html, CSS)
• requirements.txt, .env – Python deps and environment variables (Spotify credentials)
• ui/ directory:
• pubspec.yaml, lib/ – Flutter app source code
• lib/main.dart – app entry point
• lib/*.dart – screens (home, Google Map, Spotify page, weather), helpers (map_helpers, logger, opencv integration)
• ui/backend/app.py and ui/backend/venv – likely a small local shim or test script (isolated Flask or proxy)
• web/ – compiled web assets (index.html, manifest)
Extract additional insights from README
• Tech stack: Flutter Web, Flask, Spotify API, facial recognition (OpenCV).
• Data flow described: frontend ↔ Flask ↔ Spotify.
• No persistent database is listed; state is ephemeral or held in memory/files.
a. Main components:
– Flutter Web App (client)
– Flask Backend Service (server)
– Emotion-Detection Module (OpenCV library, part of backend)
– Spotify API (external service)
– (Optional) Autodelete/Cleanup Script
b. Relationships and interactions:
1. User’s browser runs Flutter Web App.
2. Flutter captures webcam frames and sends HTTP requests (REST or WebSocket) to Flask endpoints.
3. Flask receives image data, invokes the OpenCV module to detect emotion.
4. Flask uses Spotify API (OAuth2 tokens from .env) to query or control playback, based on the detected emotion.
5. Flask returns playlist metadata or playback URLs to the Flutter app.
6. Flutter renders the recommended playlist and controls playback via embedded Spotify web player or API calls.
7. Autodelete module may periodically purge temporary files or reset sessions.
c. Architectural patterns / design principles:
– Two-tier client-server architecture
– Strict separation of concerns: UI logic in Flutter, business logic in Flask, detection logic in OpenCV
– RESTful API contract between Flutter and Flask
– Environment-driven configuration for credentials (.env)
d. Key technologies & libraries:
– Flutter / Dart (UI)
– Flask (Python web framework)
– OpenCV (emotion detection)
– Spotify Web API (recommendations, playback)
– Standard web protocols (HTTP, JSON)
Detail
• That every significant piece (assets, helper libraries, setup scripts) is shown if it impacts data flow or deployment.
• Environment configuration (.env) feeding into the Flask service.
• Cleanup/autodelete as either a cron job or server-side thread.