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>
2.5 KiB
2.5 KiB
1. Database Schema
- 1.1 Add
encryptedCredentialscolumn tojournal.sync_connectionstable - 1.2 Add
journal.import_batchestable (id, userId, connectionId, status enum, totalFound, importedCount, duplicateCount, errorMessage, startedAt, completedAt) - 1.3 Reuse
journal.sync_importsfor deduplication (existing table from Wahoo sync) - 1.4 Add
sourcecolumn tojournal.routestable (nullable, e.g. "komoot", "manual", "gpx-upload") - 1.5 Run
pnpm db:pushand verify schema locally
2. Credential Encryption
- 2.1 Create
apps/journal/app/lib/crypto.server.tswith AES-256-GCM encrypt/decrypt usingINTEGRATION_SECRETenv var - 2.2 Write unit tests for encrypt/decrypt roundtrip
3. Komoot API Client
- 3.1 Create
apps/journal/app/lib/komoot.server.tswith 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.tswith 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
/integrationsroute 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_SECRETenv var to docker-compose.yml - 7.3 Add
INTEGRATION_SECRETto deploy secrets (needs manualsopsedit)
8. Verify
- 8.1 Typecheck passes
- 8.2 Lint passes
- 8.3 All 79 unit tests pass