57.1 Architecture Generation Router Service

Documentation for Sessions

57.1 Architecture: GenerationRouterService for Unified AI Generation

Date: January 20, 2026 Type: Architecture Decision Confidence: 95% (Certain)

Context

The "Generate Widget" button in the AI Panel's widget tab was not working - no logs appeared in backend-api or backend-ai-api. Investigation revealed that IntelligenceCoordinatorService.processCompletion() was returning placeholder code instead of parsing actual AI responses.

Decision

Create GenerationRouterService as a unified entry point for all AI generation requests that routes directly to the correct backend-api endpoints.

Options Considered

  1. Fix only IntelligenceCoordinatorService.processCompletion() - Quick fix but doesn't address fragmented generation paths
  2. Create GenerationRouterService + fix processCompletion() ✅ CHOSEN - Clean abstraction + backward compatibility
  3. Bypass all frontend services and call backend directly from components - Too scattered, no reusability

Implementation

GenerationRouterService Routes

Generation Type Backend Endpoint
widget POST /api/ai/generate/widget
module POST /api/ai/generate/module
image POST /api/ai/images/generate
video POST /api/ai/videos/generate
code POST /api/ai/chat/generate-code
chat POST /api/ai/chat

Key Features

processCompletion() Fix

The fix includes:

Alignment with Session 56 Decisions

Session 56 decided to integrate gograb-modules' PhaseExecutor into backend-ai-api. This aligns because:

  1. GenerationRouterService is an abstraction layer - When PhaseExecutor is integrated, we only need to change the routing targets
  2. We're not creating a new separate service - Following the "integrate into existing" principle
  3. Backend endpoints are already production-ready - Leveraging existing infrastructure

Files

Consequences

Positive:

Neutral:

Negative: