01-Product / 01.04.App-Features01.04.App Features
01.04. App Features
This document provides a detailed technical overview of the Car Pulse Tracker application, mapping source code implementation to functional capabilities.
1. Backend Architecture (FastAPI)
1.1 Service Layer & Orchestration
- Modular Service Pattern: Decoupled services for Authentication, Payments, Tesla API, and PDF Generation.
- Asynchronous Execution: Leverages Python's
asyncio for non-blocking I/O operations (API calls, file handling).
- Domain-Driven Models: Pydantic v2 schemas (
app/models/) define strict data contracts across the API.
1.2 Tesla Fleet API Integration (app/services/vehicle_providers/tesla/)
- OAuth 2.0 Flow: Implements Tesla's official authentication flow, supporting code exchange and token refreshes.
- Regional API Support: Intelligent fallback across North America (NA), Europe (EU), and China (CN) regions based on Tesla's 412 status code responses.
- Data Acquisition Engine (
acquisition.py): Parallel fetching of multiple Tesla API modules (Vehicle Data, Charging History, Recent Alerts, Warranty Details).
- Normalization Service (
normalization.py): Transforms raw Tesla API payloads into standardized internal formats for report rendering.
1.3 Payment Strategy Pattern (app/services/payment_providers/)
- Abstract Base Provider: Standardized interface for all payment providers.
- Provider Factory: Dynamically instantiates the correct provider (Stripe, PayPal) based on payment method or ID format.
- Implementation Status:
- Stripe: Full integration with checkout sessions and webhooks.
- PayPal: Integrated for transaction verification.
- Placeholders: MobilePay, Apple Pay, and Google Pay (architecture ready for implementation).
1.4 PDF Generation Engine (app/services/pdf.py)
- WeasyPrint Integration: Converts HTML templates to PDF bytes in a separate worker thread (
anyio.to_thread) to maintain API responsiveness.
- Dual-Mode Generation: Supports both immediate (synchronous) and long-running (asynchronous with Redis status polling) PDF generation.
- Automated Cleanup: Scheduled background tasks to remove temporary PDF files after a configurable delay.
- Storage Strategy: Support for local disk storage and Google Cloud Storage (GCS) with signed URL generation.
2. Frontend Architecture (Vue 3)
2.1 State Management (Pinia)
- Persistent Storage: Critical session and payment state automatically synced to
localStorage.
- Reactive Dashboard: Real-time UI updates based on vehicle data availability and payment status.
2.2 Dashboard Components
- Dynamic Report Views: Different layouts for "Basic" and "Pro" plans (
ReportDashboardBasic.vue, ReportDashboardPro.vue).
- Interactive Multi-Vehicle Selector: Tabbed interface for users with multiple vehicles in their Tesla account.
- Photo Upload: Client-side image handling for adding vehicle photos to reports.
3. Localization (i18n)
- Frontend Localization: Vue-i18n implementation for English, Finnish, and Swedish.
- Backend Translation Service: Python-based translation helper (
app/services/i18n.py) to ensure PDFs are generated in the user's selected language.
- Standardized Field Schemas: Centralized labels and panel titles to maintain consistency between Web UI and PDF reports.
4. Infrastructure & DevOps
- Dockerized Environment: Containerized services for API, WUI, Tesla Mock, and Testing (The-Bot).
- Automated UI Testing: Puppeteer-based end-to-end testing suite in a dedicated container.
- Terraform Orchestration: Infrastructure as Code (IaC) for GCP (Cloud Run, GCS, Secrets, DNS).
- Tesla Mock Server: FastAPI-based local mock server for development without real Tesla credentials.