QUICK REFERENCE

Documentation for Sessions

Session 16.1 Quick Reference

🚀 What Changed

New Routes

/space/:spaceSlug/universe/:universeSlug/vibe     → AI Platform Builder (universe-scoped)
/space/:spaceSlug/universe/:universeSlug/canvas   → Universe Canvas (universe-scoped)

New Component

IntelligentInputComponent - Real-time autocomplete for platform descriptions

Enhanced Services

ModuleSuggestionsService

PlatformStateService

ToolNavigationService

ModularityIntegrationService

Backend API

New Endpoint: POST /workflow/suggest

Request:

{
  "input": "restaurant management system",
  "context": {
    "spaceId": "space-123",
    "universeId": "universe-456"
  }
}

Response:

{
  "industries": ["restaurant"],
  "modules": [...],
  "entities": [...],
  "confidence": 0.95
}

🔄 Navigation Flow

From Vibe to Universe

// In VibeUniverseGenerator
deployToUniverse() {
  // Resolves universe context
  const universeId = queryParams['universeId'] 
    || routeParams['universeSlug']
    || universeContext.universeId()
    || createNewUniverse();
  
  // Navigates with context
  integration.proceedToUniverse(moduleId, universeId);
}

From Universe to Workbench

// In ModularityIntegrationService
refineInWorkbench(moduleId: string) {
  // Adds return context
  router.navigate(['/space', spaceSlug, 'modularity', 'workbench', moduleId], {
    queryParams: { returnTo: 'modular-universe', universeId }
  });
}

From Workbench Back to Universe

// In ModuleWorkbench
returnToPreviousTool() {
  const context = returnContext(); // From query params
  toolNavigation.navigateTo(context.tool, {
    universeId: context.universeId
  });
}

🎨 Using IntelligentInput

In Your Component

import { IntelligentInputComponent } from './intelligent-input/intelligent-input.component';
import { PlatformSuggestion } from '@libs-structural/universe-map';

@Component({
  imports: [IntelligentInputComponent]
})
export class YourComponent {
  readonly description = signal('');
  
  handleSuggestion(suggestion: PlatformSuggestion): void {
    console.log('Selected:', suggestion.industry);
    console.log('Modules:', suggestion.suggestedModules);
    console.log('Entities:', suggestion.suggestedEntities);
  }
}

In Your Template

<lib-intelligent-input
  [(userInput)]="description"
  [placeholder]="'Describe your platform...'"
  [minChars]="3"
  [debounceMs]="300"
  (suggestionSelected)="handleSuggestion($event)"
/>

💾 MongoDB Sync Usage

Sync Platform to MongoDB

import { PlatformStateService } from '@libs-structural/modularity-lib';

// Manual sync
const universe = await platformState.syncToMongoDB();

// Auto-sync (Observable)
platformState.autoSyncToMongoDB().subscribe(universe => {
  console.log('Synced:', universe);
});

What Gets Synced

{
  id: platform.id,
  spaceId: spaceId,
  name: platform.name,
  slug: 'generated-slug',
  description: platform.description,
  deploymentStatus: 'draft' | 'building' | 'deployed',
  modules: [...], // Converted to UniversalModule[]
  createdAt: Date,
  updatedAt: Date
}

🐛 Troubleshooting

Routing Error: NG04002

Symptom: Cannot match any routes

Fix: Ensure using space-aware paths:

// ❌ Wrong
['/tools/modularity/workbench', moduleId]

// ✅ Correct
['/space', spaceSlug, 'modularity', 'workbench', moduleId]

Suggestions Not Appearing

Checks:

  1. Input length > 3 characters?
  2. Waited 300ms (debounce)?
  3. ModuleSuggestionsService injected?
  4. Console errors?

Context Lost

Checks:

  1. Query params include returnTo and universeId?
  2. UniverseContextService has spaceSlug?
  3. PlatformStateService tracking context?

📚 Key Files Reference

Frontend

File Purpose
intelligent-input.component.ts Real-time autocomplete
tool-navigation.service.ts Space-aware routing
modularity-integration.service.ts Tool integration
platform-state.service.ts Shared state + MongoDB sync
module-suggestions.service.ts Platform suggestions

Backend

File Purpose
suggest.controller.ts REST API endpoint
suggestion.service.ts Suggestion logic
workflow.module.ts Module registration

Routes

File Purpose
app.routes.ts Universe-scoped routes
modularity.routes.ts Modularity tool routes
modular-universe.routes.ts Universe canvas routes

🎯 Testing Commands

# Start servers
yarn dev:gograb        # Frontend on :5200
yarn serve:backend-ai    # Backend on :3000

# Test routing
open http://localhost:5200/space/chrome-space-1/vibe
open http://localhost:5200/space/chrome-space-1/universe/test/vibe

# Test backend API
curl -X POST http://localhost:3000/workflow/suggest \
  -H "Content-Type: application/json" \
  -d '{"input": "restaurant management"}'

✅ Completion Checklist

Session 16.1: COMPLETE ✅