01-Product / 01.05.API-Features

01.05.API Features

01.05. API Features

This document outlines the core features and functionalities of the bnc-cpt-api project.

Core Backend Features

Payment Integration

Tesla Fleet API Integration

Charging Invoice Downloads

PDF Generation & Reporting

Asynchronous PDF Pipeline

The PDF generation uses a non-blocking async pipeline so the user's browser is freed immediately:

  1. Trigger — Frontend sends POST /api/v1/tesla/vehicle-report/pdf/async with the report data and locale. The API returns { task_id, status: "queued" } within milliseconds.
  2. Background Worker — A FastAPI BackgroundTask renders the PDF outside the main request loop using WeasyPrint + Jinja2 templates (vehicle_report.html). This prevents the site from becoming sluggish for other users while one report is generating.
  3. Cloud Storage — The generated PDF bytes are uploaded to a private GCS bucket (reports/{vin}-{lang}-{timestamp}.pdf). No direct public access is possible.
  4. Signed URL — The API generates a time-limited (1 hour) cryptographically signed download link.
  5. Polling & Progress — The frontend polls GET /api/v1/tesla/reports/status/{task_id} every ~2 seconds. Redis tracks progress stages: queued (0%)processing (10%)uploading (70%)complete (100%). On complete, the frontend opens the signed download_url and the user gets the PDF instantly.

Concurrent Multi-Language Support

Each PDF request gets a unique task_id, so a single user can request reports in multiple languages (en, fi, sv, no, da, de, fr, es, it) simultaneously. All tasks run concurrently in the background.

Core Capabilities

Configuration & Environments

Vehicle Picture Upload