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:

  1. Direct MongoDB writes from scripts
  2. Via backend-docs-api with JWT auth
  3. Via backend-docs-api with SYSTEM_TOKEN auth
  4. 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


🔗 Related


Auto-generated by MCP Smart Consolidation