UNIVERSE SYNC VERIFICATION GUIDE
Documentation for Plans
Universe Sync Verification Guide
Date: November 17, 2025
Status: 🔬 Testing Phase
Backend: ✅ Deployed to Railway
Quick Verification Checklist
✅ Step 1: Clear Browser Data (Optional - Fresh Start)
// In browser console:
localStorage.clear();
await new Promise((resolve) => {
const request = indexedDB.deleteDatabase('gg-storage');
request.onsuccess = () => resolve();
});
location.reload();
✅ Step 2: Create a New Universe
- Navigate to:
/space/your-space-slug/universe/create - Fill in:
- Name:
test-universe-sync - Description:
Testing MongoDB sync - Template: Blank Universe
- Name:
- Click Create Universe
✅ Step 3: Watch Console Logs
Expected Success Pattern:
[SpaceService] ⚡ Universe created (offline-first): { queueSize: 1 }
[SpaceService] ⚡ Space updated with new universe: { queueSize: 2 }
[SyncEngine] 🔄 Syncing... { operations: 2 }
[SyncEngine] 🔄 Syncing operation to backend: { operation: "update", entity: "universe", key: "universe_xxx" }
[SpaceApiService] 🌌 Updating universe: { spaceId: 'xxx', universeId: 'universe_xxx', name: 'test-universe-sync' }
✅ LOOK FOR: 200 OK (NOT 404!)
[SyncEngine] 🔄 Syncing operation to backend: { operation: "update", entity: "space", key: "space_xxx" }
[SpaceApiService] 🌌 Updating space: xxx
[SpaceApiService] 📤 Request body: { ..., "universeIds": ["universe_xxx"], ... }
[SpaceApiService] 🌌 Sending universeIds: ['universe_xxx'] (1 items)
✅ LOOK FOR: 200 OK (NOT 404!)
[SyncEngine] ✅ Synced { duration: "XXXms" }
❌ OLD Failure Pattern (Should NOT see this anymore):
PUT /api/spaces/xxx/universes/universe_xxx → 404
PUT /api/spaces/xxx → 404
[SyncEngine] ❌ Sync failed
Detailed Verification Steps
1. Railway Backend Logs
Access: Railway Dashboard → backend-api → Logs
Search for: SpacesController
Expected Logs:
[SpacesController] 🌌 Updating universe: {
spaceId: '69067c087ebb621cd9ff8c3f',
universeId: 'universe_1763422972924'
}
[SpacesService] Updating universe: universe_1763422972924 in space: 69067c087ebb621cd9ff8c3f
📌 Added universe universe_1763422972924 to space's universeIds
✅ Universe updated: universe_1763422972924
[SpacesController] 📥 Update request received: {
spaceId: '69067c087ebb621cd9ff8c3f',
userId: '68fbe3ac4740d821e041f9df',
hasUniverseIds: true,
universeIdsCount: 1
}
📥 Received universeIds to update: ["universe_1763422972924"]
✅ Updated space.universeIds to: ["universe_1763422972924"] (1 universes)
✅ Space saved to MongoDB: 69067c087ebb621cd9ff8c3f
2. MongoDB Verification
Access: Railway MongoDB → gograb-api database → spaces collection
Find your space document:
// Your space ID (from console logs or Railway)
db.spaces.findOne({ _id: ObjectId("69067c087ebb621cd9ff8c3f") })
Expected Result:
{
"_id": ObjectId("69067c087ebb621cd9ff8c3f"),
"name": "Xxb7jayp",
"spaceSlug": "chrome-space-1",
"ownerId": "68fbe3ac4740d821e041f9df",
"universeIds": [
"universe_1763422972924" // ✅ NOW POPULATED!
],
"settings": {
"defaultTheme": "dark",
"aiProvider": "anthropic",
"storageLocation": "local",
"autoSave": true,
"autoBackup": false
},
"createdAt": "2025-11-01T21:30:48.262Z",
"updatedAt": "2025-11-17T23:XX:XX.XXXZ" // ✅ Recent timestamp!
}
Check universe metadata:
// Access space-specific database
use space_69067c087ebb621cd9ff8c3f
// Find universe metadata
db.universes.findOne({ _id: "universe_1763422972924" })
Expected Result:
{
"_id": "universe_1763422972924",
"name": "test-universe-sync",
"description": "Testing MongoDB sync",
"slug": "test-universe-sync",
"spaceId": "69067c087ebb621cd9ff8c3f",
"deploymentStatus": "draft",
"createdAt": ISODate("2025-11-17T23:XX:XX.XXXZ"),
"updatedAt": ISODate("2025-11-17T23:XX:XX.XXXZ")
}
3. Multi-Browser Sync Test
Purpose: Verify universes sync across different browsers
Steps:
Browser 1 (Chrome):
- Login as
[email protected] - Create universe:
chrome-test-universe - Wait 10 seconds for sync
- Login as
Browser 2 (Firefox):
- Login as
[email protected] - Navigate to dashboard
- Expected: See
chrome-test-universeappear
- Login as
Verify MongoDB:
db.spaces.findOne({ ownerId: "68fbe3ac4740d821e041f9df" }) // Should show: "universeIds": ["chrome-test-universe"]Browser 2 (Firefox):
- Create universe:
firefox-test-universe - Wait 10 seconds
- Create universe:
Browser 1 (Chrome):
- Refresh or wait for auto-pull (30 seconds)
- Expected: See both universes
Verify MongoDB:
db.spaces.findOne({ ownerId: "68fbe3ac4740d821e041f9df" }) // Should show: "universeIds": ["chrome-test-universe", "firefox-test-universe"]
Common Issues & Solutions
Issue 1: Still seeing 404 errors
Symptom:
PUT /api/spaces/xxx/universes/universe_xxx → 404
Solution:
- Verify Railway deployment completed:
curl https://your-backend.railway.app/api/health - Check Railway logs for startup errors
- Verify environment variables are set correctly
Issue 2: MongoDB universeIds still empty
Symptom:
{
"universeIds": [],
"updatedAt": "2025-11-03T17:34:07.014Z" // ❌ Old timestamp
}
Possible Causes:
- Backend not receiving requests - Check Railway logs
- Authentication failing - Check for 401/403 errors in browser console
- Wrong spaceId - Verify
spaceIdin sync operations matches MongoDB_id
Debug Steps:
// In browser console:
// 1. Check current space
const spaceService = /* inject SpaceService */;
console.log('Current space:', spaceService.currentSpace());
// 2. Check sync queue
const syncEngine = /* inject SyncEngineService */;
console.log('Sync queue:', syncEngine.getSyncQueue()); // If exposed
// 3. Check local storage
console.log('Sync queue:', localStorage.getItem('sync-queue'));
Issue 3: Duplicate universes in array
Symptom:
{
"universeIds": ["universe_xxx", "universe_xxx", "universe_xxx"]
}
Cause: Backend updateUniverse adds to array without checking duplicates
Fix: Already handled in backend code (line 356-361 in spaces.service.ts):
// Ensure universe ID is in space's universeIds array
if (!space.universeIds.includes(universeId)) {
space.universeIds.push(universeId);
// ...
}
Success Criteria ✅
Must-Have:
- ✅ Creating universe returns 200 OK (not 404)
- ✅ MongoDB
universeIdsarray is populated - ✅ MongoDB
updatedAttimestamp is recent - ✅ Universe metadata exists in
space_{spaceId}database - ✅ Multi-browser sync works within 30 seconds
Nice-to-Have:
- ✅ Sync logs are clean (no errors)
- ✅ Sync happens within 5 seconds of universe creation
- ✅ Backend logs show detailed operation info
Performance Benchmarks
Expected Timings:
| Operation | Expected Time | Acceptable Time |
|---|---|---|
| Local universe creation | < 100ms | < 500ms |
| Sync to backend | < 500ms | < 2s |
| Cross-browser update pull | 30s (next sync cycle) | 60s |
| MongoDB write | < 50ms | < 200ms |
Monitor:
[SyncEngine] ✅ Synced { duration: "XXXms" }
- ✅ Good: < 500ms
- ⚠️ Warning: 500ms - 2s
- ❌ Bad: > 2s (investigate network/backend issues)
Next Steps After Verification
If Everything Works:
- ✅ Mark todos as complete
- ✅ Close this issue
- ✅ Document architecture for future reference
- ✅ Consider adding unit/integration tests
If Issues Remain:
- Share Railway backend logs
- Share MongoDB space document
- Share browser console logs
- Share specific error messages
Testing Checklist
Copy this to track your testing progress:
[ ] Backend deployed to Railway successfully
[ ] Backend logs show SpacesController initialization
[ ] Created test universe in browser
[ ] Browser console shows 200 OK (not 404)
[ ] Railway logs show universe update operations
[ ] MongoDB space document has populated universeIds
[ ] MongoDB updatedAt is recent
[ ] Universe metadata exists in space database
[ ] Multi-browser test: Universe created in Chrome
[ ] Multi-browser test: Universe appears in Firefox
[ ] Multi-browser test: Both browsers show same data
[ ] Sync happens within 30 seconds
[ ] No errors in browser console
[ ] No errors in Railway logs
Last Updated: November 17, 2025
Status: Ready for Testing 🚀