trails/openspec/changes/komoot-import/tasks.md
Ullrich Schäfer 5fd60ba07d WIP: Komoot import integration
Add Komoot API client, import logic, crypto helpers, integration routes,
DB schema changes, and i18n strings for the Komoot import feature.

Import processing runs as a durable pg-boss background job with retries
instead of blocking the HTTP request.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 20:10:00 +02:00

2.5 KiB

1. Database Schema

  • 1.1 Add encryptedCredentials column to journal.sync_connections table
  • 1.2 Add journal.import_batches table (id, userId, connectionId, status enum, totalFound, importedCount, duplicateCount, errorMessage, startedAt, completedAt)
  • 1.3 Reuse journal.sync_imports for deduplication (existing table from Wahoo sync)
  • 1.4 Add source column to journal.routes table (nullable, e.g. "komoot", "manual", "gpx-upload")
  • 1.5 Run pnpm db:push and verify schema locally

2. Credential Encryption

  • 2.1 Create apps/journal/app/lib/crypto.server.ts with AES-256-GCM encrypt/decrypt using INTEGRATION_SECRET env var
  • 2.2 Write unit tests for encrypt/decrypt roundtrip

3. Komoot API Client

  • 3.1 Create apps/journal/app/lib/komoot.server.ts with login function (email + password → username + token)
  • 3.2 Add fetchTours function (paginated, fetches all pages)
  • 3.3 Add fetchTourGpx function (fetch GPX geometry for a single tour)
  • 3.4 Write unit tests for API response parsing (mock fetch)

4. Import Logic

  • 4.1 Create apps/journal/app/lib/komoot-import.server.ts with importKomootTours function that: creates batch, pages through tours, fetches GPX, creates activities + routes, deduplicates via sync_imports, updates batch
  • 4.2 Write integration test for import with mock Komoot responses

5. API Routes

  • 5.1 Create POST /api/integrations/komoot/connect — validate credentials, store encrypted
  • 5.2 Create POST /api/integrations/komoot/disconnect — delete credentials
  • 5.3 Create POST /api/integrations/komoot/import — trigger import, return batch ID
  • 5.4 Create GET /api/integrations/komoot/import-status — return current batch progress

6. UI

  • 6.1 Create /integrations route with Komoot connection form (email + password)
  • 6.2 Show connected status, last sync time, and import button when connected
  • 6.3 Import progress UI — poll import-status, show counts (found, imported, duplicated)
  • 6.4 Add link to integrations page from Journal navigation
  • 6.5 Add i18n keys for all integration strings (en + de)

7. Privacy & Config

  • 7.1 Update /privacy page to document Komoot integration (credentials stored encrypted, what data is imported)
  • 7.2 Add INTEGRATION_SECRET env var to docker-compose.yml
  • 7.3 Add INTEGRATION_SECRET to deploy secrets (needs manual sops edit)

8. Verify

  • 8.1 Typecheck passes
  • 8.2 Lint passes
  • 8.3 All 79 unit tests pass