Architecture: How should session documentation be synced to production Mon...
Documentation for Sessions
🏗️ Architecture: How should session documentation be synced to production Mon...
Date: 2026-01-22
Time: 19:22:11 UTC
Session: editor2-58.12
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
How should session documentation be synced to production MongoDB for searchability?
Task: Fix session docs sync authentication and document the pattern
🎯 Decision Made
Chosen:
Via backend-docs-api with SYSTEM_TOKEN auth
Options Considered:
- Direct MongoDB writes from scripts
- Via backend-docs-api with JWT auth
- Via backend-docs-api with SYSTEM_TOKEN auth
- Manual upload via admin panel
💭 Reasoning
The JwtAuthGuard in @libs-api/auth-core has built-in support for SYSTEM_TOKEN authentication (lines 63-75). When a token matches the SYSTEM_TOKEN env var, it bypasses JWT verification and authenticates as a system user. This is the documented pattern for internal service-to-service communication. The sync script uses getSystemToken() from env-loader.js to read the actual token from .env.local, ensuring proper authentication without needing to generate/manage JWTs for scripts.
📁 Files Involved
tools/scripts/database/sync-session-docs-to-mongodb.jslibs/libs-api/auth-core/src/lib/guards/jwt-auth.guard.tstools/scripts/database/env-loader.js
🔗 Related
- Decision ID:
dev_1769109730984_c9xx6w5 - Session: 58
- Workspace: editor2
Auto-generated by MCP Smart Consolidation