RAILWAY VARIABLES CORRECTIONS

Documentation management API with real-time MongoDB sync

✅ Railway Variables Review for backend-docs-api

Your Current Variables - Review

✅ CORRECT (Keep These)

# 🔒 Get these values from your .env.local file
MONGODB_CONNECTION_STRING_TEST_MODULES="<YOUR_MONGODB_CONNECTION_STRING>"
JWT_SECRET="<YOUR_JWT_SECRET>"
NODE_ENV="production"

✅ These are exactly what backend-docs-api needs. Get actual values from .env.local.

❌ MISSING (Need to Add)

SYSTEM_TOKEN=<copy-from-backend-api-Railway-variables>

Action: Go to backend-api Railway service → Variables → Copy SYSTEM_TOKEN value → Add to Docs-api

⚠️ NEEDS UPDATE

# Current (WRONG for production):
ALLOWED_ORIGINS="http://localhost:5701,http://localhost:5200,http://localhost:4200,http://localhost:5300"

# Should be (for backend-docs-api):
ALLOWED_ORIGINS="https://gograb.space,http://localhost:5010"

Why:

Action: Update ALLOWED_ORIGINS variable in Railway

❌ NOT NEEDED (Remove or Ignore)

These are NOT used by backend-docs-api:

MONGODB_CONNECTION_STRING="..."        # ❌ This is for backend-api only
MONGODB_DATABASE="gograb-api"          # ❌ This is for backend-api only
MONGODB_TEST_MODULES_DATABASE="docs"   # ❌ Not needed (we set dbName in code as 'docs-database')
JWT_EXPIRATION="7d"                    # ❌ Not needed (set in code)
OPENAI_API_KEY="..."                   # ❌ Not needed for docs-api
ANTHROPIC_API_KEY="..."                # ❌ Not needed for docs-api
GOOGLE_API_KEY="..."                   # ❌ Not needed for docs-api

Action: Remove these from Docs-api service (they won't hurt, but they're unnecessary)


Final Configuration for Docs-api

Your Railway "Docs-api" service should have ONLY these 5 variables:

# 1. MongoDB Connection (test-modules cluster)
# 🔒 Get from: .env.local or MongoDB Atlas Dashboard
MONGODB_CONNECTION_STRING_TEST_MODULES="<YOUR_MONGODB_CONNECTION_STRING>"

# 2. Shared Authentication (MUST match backend-api)
# 🔒 Get from: .env.local file
JWT_SECRET="<YOUR_JWT_SECRET>"
SYSTEM_TOKEN="<YOUR_SYSTEM_TOKEN>"

# 3. CORS Configuration
ALLOWED_ORIGINS="https://gograb.space,http://localhost:5010"

# 4. Environment
NODE_ENV="production"

Why Two MongoDB Clusters?

You have the setup correct:

Main Cluster (gograbspace.dgajj2t.mongodb.net)

Test Modules Cluster (test-modules.7hkxufn.mongodb.net)

This separation is correct - it isolates documentation from production data! ✅


Database Name Clarification

You don't need MONGODB_TEST_MODULES_DATABASE variable because:

// In app.module.ts, we hardcode the database name:
createMongooseConfig(configService, {
  dbName: 'docs-database',  // ← Hardcoded in code
  connectionStringKey: 'MONGODB_CONNECTION_STRING_TEST_MODULES',
})

MongoDB will automatically use the docs-database database within your test-modules cluster.


Action Items

  1. ✅ You have: MONGODB_CONNECTION_STRING_TEST_MODULES
  2. ✅ You have: JWT_SECRET
  3. ✅ You have: NODE_ENV
  4. ❌ ADD: SYSTEM_TOKEN (copy from backend-api)
  5. ⚠️ UPDATE: ALLOWED_ORIGINS to "https://gograb.space,http://localhost:5010"

Quick Fix in Railway

  1. Click "+ New Variable"
  2. Add SYSTEM_TOKEN → Value from backend-api
  3. Click on ALLOWED_ORIGINS variable
  4. Update to: https://gograb.space,http://localhost:5010
  5. Click "Deploy" (top right)

Then you're ready to go! 🚀