ROUTING ARCHITECTURE V2

Ecosistema completo para organización y gestión de contenido con interfaces espaciales

GoGrab Space Routing Architecture V2

Date: November 16, 2025
Status: 🚧 In Progress
Vision: Ferrari/Lambo-level separation of concerns


🎯 Core Philosophy

Widgets consume themes, NOT themes consuming widgets!

The Problem (Old Architecture)

/ui-builder/ux/input          ← What is this? Demo? Widget? Design doc? ❌
/ui-builder/themes/           ← Themes mixed with widgets ❌
/ui-builder/ux/text-box       ← Routes broken, conceptually confusing ❌

Issues:

  1. Mixing inspiration with product - UX demos treated as final product
  2. Wrong dependency - Themes depend on widgets (should be opposite!)
  3. Unclear purpose - Is it a design guide or builder tool?
  4. Broken routes - Navigation doesn't match structure

The Solution (New Architecture)

/widgets/                     ← Dynamic widget showcase ✅
  - Base widgets (from @libs-widgets)
  - User-created widgets (from widget-builder)
  - All adapt to active theme

/theme/                       ← Pure theme system ✅
  - guide          → How to use themes
  - create         → Create/edit themes
  - templates      → Pre-built themes
  - editor         → Visual theme editor
  - NOT widget demos!

/ux/                          ← DEPRECATED ⚠️
  - Keep as internal design reference
  - Extract patterns → convert to widgets
  - Don't ship as product

🏗️ New Route Structure

1. /widgets/ - Dynamic Widget Showcase

Purpose: Demonstrate widgets that adapt to ANY theme

// Route Structure
/widgets/                     → Widget gallery (all widgets)
/widgets/:widgetId            → Dynamic widget demo
/widgets/builder              → Widget-builder tool
/widgets/builder/workspace    → Create new widget
/widgets/builder/edit/:id     → Edit existing widget

Widget Categories:

  1. Base Widgets (from @libs-widgets/widgets)

    • button, input, select, checkbox, etc.
    • Pre-built, production-ready
    • Fully theme-aware
  2. User-Created Widgets (from widget-builder)

    • Custom widgets built by space-builders
    • Stored per universe/space
    • Automatically inherit theme

Key Features:

Integration with Widget-Builder:

// Widget metadata enables dynamic routing
interface WidgetMetadata {
  id: string;
  name: string;
  category: 'form' | 'content' | 'layout';
  demoComponent: Type<any>;  // Dynamic component
  properties: PropertyGroup[];
  themeVariables: string[];  // CSS vars it uses
}

// Route resolver loads correct widget
{ 
  path: ':widgetId',
  component: WidgetDemoComponent,
  resolve: { widget: WidgetResolver }
}

2. /theme/ - Pure Theme System

Purpose: Theme creation, editing, and documentation (NO widget demos)

// Route Structure
/theme/guide              → Complete theme system overview
/theme/create             → Create new theme
/theme/templates          → Pre-built theme templates
/theme/editor             → Visual theme editor
/theme/reference          → CSS variable documentation
/theme/best-practices     → Design guidelines
/theme/advanced-effects   → Glass, neon, 3D effects

Theme System Boundaries:

Theme Components Move Here:

What Stays OUT:


3. /ux/ - DEPRECATED (Design Reference)

Purpose: Internal design inspiration (NOT shipped as product)

// Options:
Option A: Redirect to new structure
{ path: 'ux', redirectTo: 'widgets' }

Option B: Keep as internal reference
{ 
  path: 'ux', 
  component: DesignReferenceComponent,
  data: { 
    warning: 'Internal design reference - not for production' 
  }
}

Option C: Remove entirely
// Extract patterns → create widgets → delete

Migration Strategy:

  1. Extract design patterns from each UX demo
  2. Create base widgets based on those patterns
  3. Register widgets in widget-builder
  4. Delete UX demos or mark as deprecated

Example Migration:

// OLD: /ux/input
// Extract patterns: validation, states, accessibility
// Create: InputWidget in @libs-widgets/widgets
// Demo: /widgets/input (dynamic demo)

// OLD CODE (Delete):
libs/libs-ui/demos-lib/src/lib/demos/ux-input/

// NEW CODE (Keep):
libs/libs-widgets/widgets/src/lib/components/input-widget/

🔄 Migration Plan

Phase 1: Create Widget Showcase Route

# 1. Create widget showcase component
nx g @nx/angular:component \
  --name=widget-showcase \
  --project=widget-showcase \
  --standalone

# 2. Create dynamic widget demo component
nx g @nx/angular:component \
  --name=widget-demo \
  --project=widget-showcase \
  --standalone

# 3. Add routes to app.routes.ts

Phase 2: Move Theme Components

# 1. Create theme-showcase library (if needed)
nx g @nx/angular:library theme-showcase \
  --directory=libs/theme-system \
  --standalone

# 2. Move theme components
# From: libs/libs-ui/demos-lib/src/lib/ux-themes/
# To: libs/theme-system/theme-showcase/

# 3. Update imports and routes

Phase 3: Deprecate UX Routes

# 1. Add deprecation warnings
# 2. Update all navigation links
# 3. Test all routes work
# 4. Remove or redirect /ux/ routes

Phase 4: Widget Extraction

# For each UX demo:
# 1. Analyze design patterns
# 2. Create base widget
# 3. Register in widget-builder
# 4. Create demo in widget-showcase
# 5. Delete UX demo

🎨 Architecture Benefits

1. Clear Separation of Concerns

Widgets = Building blocks (adapt to ANY theme)
Themes = Visual styling (apply to ANY widget)

2. Proper Dependency Flow

CORRECT:
Widget → Consumes → Theme Variables
Theme → Defines → Visual Style

WRONG:
Theme → Depends on → Specific Widget

3. AI-Trainable Patterns

// Widget metadata enables AI understanding
const buttonWidget = {
  id: 'button',
  category: 'form',
  themeVariables: [
    '--btn-bg',
    '--btn-color',
    '--btn-border',
    '--btn-hover-bg'
  ],
  properties: [...],
  demo: ButtonDemoComponent
};

// AI can:
// 1. Generate new widgets following pattern
// 2. Apply themes to any widget
// 3. Create custom variations

4. Dynamic Routing Scalability

// Add new widget? Just register it!
widgetRegistry.register(newWidget);
// Route automatically available: /widgets/new-widget

// No need to manually add routes
// No need to update navigation
// No need to modify routing files

5. Theme Independence

// Theme system is PURE
// Doesn't care what widgets exist
// Just provides CSS variables

// Any widget can use theme:
.my-custom-widget {
  background: var(--ux-surface);
  color: var(--ux-text-primary);
  border: var(--ux-border);
}

// Works with ANY theme!

📊 Route Comparison

Old Structure (Confusing)

/ui-builder/
  ├── home
  ├── ux/                     ← What is "ux"?
  │   ├── input              ← Is this a demo or product?
  │   ├── button             ← Mixed with widget-builder?
  │   ├── text-box           ← Broken route!
  │   └── menu               ← Unclear purpose
  ├── themes/                ← Themes mixed with widgets
  │   ├── guide              ← This belongs in themes
  │   ├── editor             ← This too
  │   └── color-showcase     ← But not widget demos
  └── ai/                    ← AI mixed with everything

New Structure (Clear)

/widgets/                    ← ALL widgets here
  ├── (gallery)              ← Browse all widgets
  ├── button                 ← Dynamic route
  ├── input                  ← Dynamic route
  ├── custom-form            ← User-created widget
  └── builder/               ← Widget creation tool
      ├── workspace
      └── edit/:id

/theme/                      ← PURE theme system
  ├── guide                  ← How to use themes
  ├── create                 ← Create new theme
  ├── templates              ← Pre-built themes
  ├── editor                 ← Visual editor
  ├── reference              ← CSS vars docs
  └── advanced-effects       ← Special effects

/ai/                         ← AI integration (separate)
  ├── guide
  ├── tester
  └── examples

/ux/                         ← DEPRECATED
  → redirectTo: '/widgets'
  → Or: Internal design reference only

🧪 Testing Strategy

1. Widget Route Tests

describe('/widgets/', () => {
  it('should load widget gallery');
  it('should handle dynamic widget routes');
  it('should load widget-builder');
  it('should show user-created widgets');
  it('should adapt to theme changes');
});

2. Theme Route Tests

describe('/theme/', () => {
  it('should load theme guide');
  it('should open theme editor');
  it('should list theme templates');
  it('should NOT show widget demos');
});

3. Integration Tests

describe('Widget + Theme Integration', () => {
  it('widget should use theme variables');
  it('changing theme should update widget');
  it('custom theme should work with all widgets');
  it('widget-builder should use current theme');
});

📚 Related Documentation


✅ Success Criteria

  1. Clear Routes: Anyone can understand what each route does
  2. Theme Independence: Widgets work with ANY theme
  3. Dynamic Widgets: New widgets auto-available in showcase
  4. No Confusion: No mixing of concerns
  5. AI-Ready: Metadata enables AI generation
  6. Performance: 200% performant theme switching
  7. Offline-First: Flash persistence everywhere
  8. Beautiful UX: Ferrari/Lambo-level polish

🚀 Next Steps

  1. ✅ Document architecture (this file)
  2. 🔄 Create widget showcase routes
  3. 🔄 Move theme components to /theme/
  4. 🔄 Deprecate /ux/ routes
  5. 🔄 Extract widget patterns
  6. 🔄 Test integration
  7. 🔄 Update navigation
  8. 🔄 Document patterns

Let's build the Ferrari/Lambo of platform builders! 🏎️💨