https://backend.example.com)Authentication: Firebase JWT token in
Authorization: Bearer <token> headerContent-Type:
application/json for all
requests/responses
🔐 Authentication Routes (/api/auth)
Set or update the role for an authenticated user
Request Body:
Response:
{ success: true, message: "Role set successfully" }
Allow user to choose from available roles during onboarding
Response: Returns available roles and current selection
🌐 Public Routes (/api/public)
No authentication required. Public information about batteries, models, and companies.
Get public battery passport information
Returns battery details including technical specs, compliance info, and environmental data without owner-specific data
List all models from a company visible to the public
Returns model specifications, carbon performance class, and durability compliance status
List all publicly available batteries
Supports filtering by category, compliance status, and search parameters
📏 Compliance Routes (/api/compliance)
Public read access to regulatory thresholds; admin-only for mutations per EU Regulation 2023/1542 (Articles 7 and 10).
List durability thresholds (public). Supports optional filters: battery_category, valid_from, valid_to.
List carbon performance thresholds (public). Supports optional filters: battery_category, valid_from, valid_to.
Create durability threshold (admin)
Create carbon threshold (admin)
Update durability threshold (admin)
Update carbon threshold (admin)
Soft delete durability threshold (admin)
Soft delete carbon threshold (admin)
🏢 Company Routes (/api/companies)
Manage companies, dashboards, and thresholds
List all companies
Create a new company
Get comprehensive dashboard data for authenticated company
"Fat endpoint" providing aggregated company data: models, batches, batteries, and compliance information in a single request
Get current authenticated user's company details
Update company information
Get company details by ID
Get durability compliance thresholds for a company
Returns active thresholds where
valid_from ≤ today ≤ valid_to
Get carbon footprint thresholds for a company
Returns active thresholds where
valid_from ≤ today ≤ valid_to
Create new durability threshold (EU Regulation 2023/1542)
Create new carbon footprint threshold
Delete a company
👨💼 Admin Routes (/api/admin)
Administrative operations for system management
All endpoints require authentication and admin role
/api/companies/:id/users for company admins.
🏭 Plant Routes (/api/plants)
Manage manufacturing plants
List plants for a company
Get plant details
Create new plant
Fields
| Field | Type | Required | Description | Compliance |
|---|---|---|---|---|
| global_location_number | string | No |
Global Location Number (GLN), 13-digit identifier. Validated
by regex ^\d{13}$.
|
EU Regulation 2023/1542 Article 13; Catena-X 6.0.0 Identification.Plant |
global_location_number. Database column
gln maps to this field in API responses and internal
services.
🔧 Model Routes (/api/models)
Manage battery models and technical specifications
List all models with optional filtering
Returns model specifications, durability compliance, and carbon performance class
Get detailed model information
Includes technical specifications, compliance data, and associated batches
Create new battery model
Includes specifications, chemistry, and EU Annex VI compliance data
📦 Batch Routes (/api/batches)
Manage production batches and batch-specific data
List production batches
Includes inherited model properties: durability compliance, carbon performance class
Get batch details
Shows batch specifications and inherited model compliance data
Create new production batch
🔋 Battery Routes (/api/batteries)
Consolidated endpoint for all battery operations following resource-based REST architecture
List batteries with RBAC-filtered sections
Returns different data based on user role (manufacturer, recycler, repurposer, owner, authority)
Get detailed battery information
Includes technical specs, compliance status, lifecycle history, usage data, and environmental impact
Get battery data in JSON-LD format
Structured data for semantic web and interoperability (EU Battery Regulation Annex VI)
List batteries owned by current user/company
List batteries manufactured by current company
List batteries repurposed using models from this company
Create new battery
Create complete battery hierarchy in one transaction
Creates company (optional), plant, model, batch, battery, and technical documents with Firestore/Storage rollback on failure
Mark battery as recycled (Article 13 - Lifecycle)
Updates lifecycle status to "recycled" and records recovered materials
Mark battery for repurposing (Article 13 - Lifecycle)
Update battery state of health (SoH) and residual lifetime
BMS devices and owners can report usage data; calculates remaining useful life
⚗️ Materials Routes (/api/materials)
Manage battery composition and material information
Get available materials and units
Returns standardized materials for composition data (EU Annex VI)
📄 Technical Documents Routes (/api/tech-docs)
Manage technical documentation for models
Get technical documents for a model
Returns Firestore references, QR codes, and document metadata
Upload/save technical documents
🛒 Marketplace Routes (/api/marketplace)
Battery marketplace for buying and selling used batteries
List batteries available for sale on marketplace
Public listing with filtering by category, condition, price
List battery for sale
Purchase battery from marketplace
Transfers ownership and updates lifecycle history
✅ Compliance Features
-
durability_compliant: Boolean from backend (compliant with EU Regulation 2023/1542 Article 10) -
carbon_performance_class: Class A-G from backend calculations (Article 7) -
carbon_class: Carbon footprint classification on batteries - All values displayed in EntityTable, PublicBatteryPassportOrganism, and EntityDetailPage
- No frontend validation triggered during render
Durability Compliance (Article 10)
Backend service calculates durability_compliant based
on:
- Round-trip efficiency ≥ threshold for battery category
- Capacity fade < threshold per 1000 cycles
- Thresholds vary by category (EV, LMT, SLI, industrial, portable, incorporated)
-
Active thresholds returned via
GET /api/companies/:id/durability-thresholds
Carbon Performance Class (Article 7)
Backend calculates carbon_performance_class (A-G) based
on:
- Carbon intensity (kg CO₂eq/kWh) vs. class boundaries
- Weighted average across production batches
- Thresholds vary by category and year
-
Active thresholds returned via
GET /api/companies/:id/carbon-thresholds
⚠️ Error Handling
| Status Code | Meaning | Example |
|---|---|---|
| 200 OK | Request successful | GET /api/batteries/123 returns battery details |
| 400 Bad Request | Invalid request data | Missing required field in POST request |
| 401 Unauthorized | Missing or invalid authentication | Missing Bearer token or expired JWT |
| 403 Forbidden | Authenticated but insufficient permissions | Non-admin attempting to create company |
| 404 Not Found | Resource does not exist | GET /api/batteries/nonexistent |
| 500 Internal Server Error | Server-side error | Database connection failure |
🔒 Authentication & Authorization
Firebase JWT Authentication
All protected endpoints require a valid Firebase JWT token in the request header:
Available Roles
| Role | Permissions |
|---|---|
| manufacturer | Create/edit models, batches, batteries; view manufacturing data |
| owner | View owned batteries; update usage data; manage ownership transfer |
| repurposer | Access technical docs; update lifecycle to "repurposed"; view composition data |
| recycler | Access composition data; update lifecycle to "recycled"; record recovered materials |
| authority | Read-only access to all data for regulatory compliance audits |
| admin | Unrestricted access to all endpoints and management functions |
| public | Access public endpoints (no authentication required) |
| bms_device | Write usage data for assigned battery; read battery specs |
📊 Data Flow Architecture
Firestore & PostgreSQL Integration
Entities stored in both databases for audit and user management:
- Firestore: User authentication, technical documents, usage data
- PostgreSQL: Relational data, audit trails, compliance calculations
- Firebase Storage: Binary files (QR codes, technical docs, usage logs)
SQL vs. Firestore ID References
When both sqlId and firestoreUid exist:
📞 Support & Documentation
BackEnd/ directoryRoute Files:
BackEnd/routes/Services:
BackEnd/services/Database:
BackEnd/database_schema.sqlCompliance Details:
BackEnd/services/complianceService.js
Version: Phase 1 (Backend compliance display)
Last Updated: January 2026
EU Compliance: Regulation 2023/1542, Directive
2024/1861 (NIS2)