How wardzik4/ztm-backend works
ztm-tracker is a Ktor backend that enriches vehicle data with depot and route information. Its API accepts vehicle details, looks up stored route data, calculates enrichment fields, and returns a unified response. Separately, background jobs poll Warsaw’s ZTM API, cache live locations, and periodically refresh the database. The excerpts show these flows, but not how the application starts or registers them; those links are therefore omitted. The README documents JSON content negotiation, though its registration path is not shown.
Main entry points: ZtmSyncJob.kt Background Pollers · Routing.kt Enrichment Endpoint · DepotCalculator.kt Depot Calculator · VehicleRoutes.kt Vehicle Route Table
Components 12
HTTP API
- Enrichment Endpoint
src/main/kotlin/Routing.kt - Ktor Entrypoint
src/main/kotlin/main.kt - JSON Negotiation
src/main/kotlin/Serialization.kt
Live Data Ingestion
- Background Pollers
src/main/kotlin/ZtmSyncJob.kt - Live GPS Cache
src/main/kotlin/ZtmSyncJob.kt
Vehicle Enrichment
- Depot Calculator
src/main/kotlin/DepotCalculator.kt
Persistence
- Vehicle Route Table
src/main/kotlin/VehicleRoutes.kt
Data Contracts
- Vehicle DTOs
src/main/kotlin/ZtmBackendModels.kt - Route Data Model
src/main/kotlin/RouteMockData.kt
Other components
- API Client
- Warsaw ZTM API
- Supabase PostgreSQL
Connections 12
- API Client → Enrichment Endpoint: requests
src/main/kotlin/Routing.kt - Enrichment Endpoint → Vehicle Route Table: queries
src/main/kotlin/Routing.kt - Enrichment Endpoint → Depot Calculator: calculates depot
src/main/kotlin/Routing.kt - Enrichment Endpoint → Supabase PostgreSQL: reads
src/main/kotlin/Routing.kt - Enrichment Endpoint → API Client: returns response
src/main/kotlin/Routing.kt - Background Pollers → Warsaw ZTM API: polls locations
src/main/kotlin/ZtmSyncJob.kt - Background Pollers → Live GPS Cache: updates
src/main/kotlin/ZtmSyncJob.kt - Background Pollers → Vehicle Route Table: refreshes rows
src/main/kotlin/ZtmSyncJob.kt - Background Pollers → Supabase PostgreSQL: writes
src/main/kotlin/ZtmSyncJob.kt - Background Pollers → Depot Calculator: calculates depots
src/main/kotlin/ZtmSyncJob.kt - Background Pollers → Vehicle DTOs: decodes locations
src/main/kotlin/ZtmSyncJob.kt - Enrichment Endpoint → Vehicle DTOs: builds response
src/main/kotlin/Routing.kt