Foundation Libraries Review - November 2025

Comprehensive audit of singularity, editor-web, and modularity libraries

🔍 Foundation Libraries Review - November 2025

Last Updated: November 14, 2025
Status: 🎯 FOUNDATION AUDIT COMPLETE
Purpose: Understand current capabilities and integration paths


🎯 EXECUTIVE SUMMARY

This document audits the three critical foundational libraries that support the modular-universe builder:

  1. singularity-lib - Logic blocks and flows (smallest reusable units)
  2. editor-web-lib - Visual page editor (content creation)
  3. modularity-lib - Module creation and packaging (module factory)

Key Finding: All three libraries are operational but need better integration with the universal module system and modular-universe builder.


⚡ SINGULARITY-LIB REVIEW

Location: libs/libs-structural/singularity-lib/
Purpose: Create reusable logic blocks and flows that power functionality across the platform

📊 Current State

Status: ✅ OPERATIONAL - Well-structured, needs integration enhancement

Core Components:

singularity-lib/
├── components/
│   ├── logic-builder/              # Visual logic block builder
│   │   ├── logic-block.component   # Individual block rendering
│   │   ├── logic-canvas.component  # Canvas for connecting blocks
│   │   └── logic-sidebar.component # Block palette
│   ├── flow-composer/              # Flow composition tool
│   ├── singularity-dashboard/      # Main dashboard
│   └── ai-assistance/              # AI-powered generation
│
├── services/
│   ├── logic-execution-engine      # Execute logic blocks/flows
│   ├── flow-composition            # Compose blocks into flows
│   ├── flow-attachment             # Attach flows to modules
│   ├── logic-ai                    # AI code generation
│   └── widget-flow-executor        # Execute flows from widgets
│
├── templates/
│   ├── api-block-templates         # HTTP, REST API blocks
│   ├── business-logic-blocks       # Business rules
│   ├── database-block-templates    # DB operations
│   ├── flow-control-blocks         # If/loop/switch
│   ├── math-block-templates        # Math operations
│   ├── platform-block-templates    # Platform-specific
│   ├── string-block-templates      # String manipulation
│   ├── trigger-block-templates     # Event triggers
│   └── ui-control-blocks           # UI interactions
│
└── state/
    └── singularity.state.ts        # Flash-state management

✅ Strengths

  1. Rich Block Library - 100+ pre-built logic blocks
  2. Visual Canvas - Drag-and-drop flow composition
  3. Execution Engine - Real-time block execution
  4. AI Integration - AI-powered flow generation
  5. Storage Integration - Uses flash-persistence
  6. Widget Integration - Can attach flows to widgets

⚠️ Integration Gaps

  1. Module Attachment - Flow attachment to universal modules needs enhancement
  2. Storage Schema - Flow storage not fully aligned with universe-scoped data
  3. Module Browser - Flows not discoverable in module browser
  4. Cross-Tool Navigation - Routes commented out due to circular dependency

🎯 Required Enhancements

1. Universe-Scoped Storage

Current:

// Generic storage
storage.put('flow:123', flowData);

Needed:

// Universe-scoped storage
storage.putInUniverse(spaceId, universeId, 'flow:123', flowData);

// Flow as module
const flowModule: UniversalModule = {
  id: 'flow-123',
  name: 'Order Processing Flow',
  type: 'flow',
  universeId: 'universe-456',
  config: {
    blocks: [...],
    connections: [...]
  }
};

2. Module Registry Integration

Needed:

// Register flows as installable modules
@ModuleDecorator({
  id: 'order-processing-flow',
  name: 'Order Processing Flow',
  type: 'flow',
  category: 'Business Logic',
  embeddableComponents: [],
  publicActions: ['execute', 'validate', 'test']
})
export class OrderProcessingFlowModule implements BrowserModuleContract {
  manifest: ModuleManifest = { /* ... */ };
  
  async execute(input: any): Promise<any> {
    // Execute flow
  }
}

3. Attachment API Enhancement

Current:

// Attach flow to widget
flowAttachmentService.attachFlowToWidget(widgetId, flowId);

Needed:

// Attach flow to universal module
flowAttachmentService.attachFlowToModule(
  moduleId: string,
  flowId: string,
  trigger: 'onInit' | 'onClick' | 'onChange' | 'onSubmit'
);

// Attach flow to section (in modular-universe)
flowAttachmentService.attachFlowToSection(
  sectionId: string,
  flowId: string,
  trigger: string
);

4. Cross-Tool Navigation

Proposed Routes:

// From modular-universe section config
→ /space/:spaceSlug/singularity/flows?context=section&id=section-123

// From module detail
→ /space/:spaceSlug/singularity/flows?context=module&id=module-456

// From widget config
→ /space/:spaceSlug/singularity/flows?context=widget&id=widget-789

📋 Action Items for Singularity


📝 EDITOR-WEB-LIB REVIEW

Location: libs/libs-structural/editor-web-lib/
Purpose: Visual page editor for creating beautiful content pages

📊 Current State

Status: ✅ OPERATIONAL - Powerful editor, needs module integration

Core Components:

editor-web-lib/
├── components/
│   ├── editor-main/              # Main editor orchestrator
│   ├── editor-canvas/            # Visual editing canvas
│   ├── editor-workspace/         # Full workspace with tools
│   ├── widget-library/           # Widget palette
│   ├── widget-builder/           # Create custom widgets
│   ├── editor-preview/           # Preview mode
│   └── flow-binding-panel/       # Bind flows to widgets
│
├── services/
│   ├── page-layout.service       # Page layout management
│   ├── widget-registry.service   # Widget registration
│   ├── widget-builder.service    # Widget creation
│   └── theme-bridge.service      # Theme integration
│
├── state/
│   ├── pages-structured.state    # Page state management
│   └── widgets-structured.state  # Widget state
│
└── actions/
    ├── save-current-page         # Save page
    ├── export-page-as-json       # Export functionality
    └── open-page-in-editor       # Open existing page

✅ Strengths

  1. Visual Editor - Drag-and-drop page building
  2. Widget System - Rich widget library
  3. Layout Management - Flexible page layouts
  4. Theme Integration - Uses theme-system
  5. Preview Mode - Real-time preview
  6. Export/Import - JSON-based page serialization

⚠️ Integration Gaps

  1. Universe Context - Pages not scoped to specific universe
  2. Module Assignment - Pages not assignable to modular-universe sections
  3. Storage Schema - Page storage not aligned with universal module system
  4. Section Awareness - Editor doesn't know about modular-universe sections

🎯 Required Enhancements

1. Universe-Scoped Pages

Current:

// Generic page storage
pageService.savePage(pageId, pageData);

Needed:

// Universe-scoped page as module
const pageModule: UniversalModule = {
  id: 'page-home',
  name: 'Home Page',
  type: 'page',
  universeId: 'universe-123',
  parentId: 'section-456', // Parent section in modular-universe
  config: {
    layout: pageLayout,
    widgets: widgets,
    flows: attachedFlows
  }
};

// Save as module
moduleService.install(universeId, pageModule, sectionId);

2. Section Integration

Needed:

// Open editor in context of section
editorService.openPageInSection({
  universeId: 'universe-123',
  sectionId: 'section-456',
  pageId: 'page-home' // or null for new page
});

// When saving, update section assignment
const section: SectionConfig = {
  id: 'section-456',
  contentType: 'page',
  assignedModuleId: 'page-home',
  // ... other config
};

3. Module Browser Integration

Needed:

// Pages appear in module browser as type='page'
const pageManifest: ModuleManifest = {
  id: 'page-home',
  name: 'Home Page',
  type: 'page',
  category: 'Content',
  access: {
    visibility: 'public',
    audience: 'space-builder',
    showInBrowser: true,
    showInSelector: true
  },
  embeddableComponents: [],
  publicActions: ['edit', 'preview', 'export']
};

4. Navigation Context

Proposed Routes:

// From modular-universe section
→ /space/:spaceSlug/editor?universe=123&section=456&page=home

// From module browser (create new page)
→ /space/:spaceSlug/editor?universe=123&section=456&mode=create

// Standalone page editing
→ /space/:spaceSlug/editor/pages/:pageId

📋 Action Items for Editor-Web


🧩 MODULARITY-LIB REVIEW

Location: libs/libs-structural/modularity-lib/
Purpose: Module creation wizard and packaging system

📊 Current State

Status: ✅ OPERATIONAL - Good foundation, UX needs improvement

Core Components:

modularity-lib/
├── components/
│   ├── modularity-dashboard/      # Main dashboard
│   ├── module-creation-wizard/    # Step-by-step creation
│   ├── module-builder/            # Visual module builder
│   ├── ai-module-builder/         # AI-powered generation
│   ├── module-detail/             # Module detail page
│   ├── template-selector/         # Module templates
│   ├── deploy-config/             # Deployment settings
│   └── marketplace-page/          # Module marketplace
│
├── services/
│   ├── modularity.service         # Core service
│   ├── module-generator.service   # Generate modules
│   ├── module-packager.service    # Package for export
│   ├── module-storage.service     # Storage operations
│   ├── ai-module-generation       # AI generation
│   └── unified-module-manager     # Manage all modules
│
└── models/
    └── unified-module.models.ts   # Module type definitions

✅ Strengths

  1. Creation Wizard - Step-by-step module creation
  2. AI Generation - AI-powered module building
  3. Templates - Pre-built module templates
  4. Packaging - Export modules for reuse
  5. Marketplace - Share modules (foundation)

⚠️ Integration Gaps

  1. Disconnected UX - Wizard feels separate from modular-universe
  2. Module Types - Not fully aligned with universal module types
  3. Visual Builder - ui-canvas-builder needs work
  4. Flow Integration - Not connected to singularity flows
  5. Page Integration - Not connected to editor-web pages

🎯 Required Enhancements

1. Unified Module Creation

Current Flow:

User → Modularity Dashboard → Wizard → Create → Done (but where does it go?)

Needed Flow:

User → Module Browser → "Create New Module" →
  ↓
Module Type Selection:
  - Page → Open editor-web-lib (with universe context)
  - Flow → Open singularity-lib (with universe context)
  - Navigation → Template + config wizard
  - Feature → Wizard with flow attachment
  - Galaxy/World → Open modular-universe builder
  - Widget → Open widget-builder (to be created)
  ↓
Module Created → Appears in module browser → Assignable to sections

2. Type-Specific Builders

Needed Routing Matrix:

const MODULE_CREATION_ROUTES = {
  'page': '/space/:spaceSlug/editor?mode=create&universe=:universeId',
  'flow': '/space/:spaceSlug/singularity/flows?mode=create&universe=:universeId',
  'galaxy': '/space/:spaceSlug/modular-universe?type=galaxy&mode=create',
  'world': '/space/:spaceSlug/modular-universe?type=world&mode=create',
  'navigation': '/space/:spaceSlug/modularity/builder?type=navigation',
  'feature': '/space/:spaceSlug/modularity/builder?type=feature',
  'widget': '/space/:spaceSlug/widgets/builder?mode=create'
};

3. Module Browser Integration

Needed:

// Modularity creates module → Registers with ModuleRegistry → Appears in browser
moduleRegistryService.registerModule(manifest);

// Module immediately available in section-config-panel
// No need to reload or navigate away

4. Enhanced Wizard

Proposed Steps:

Step 1: Module Type (visual cards with icons)
  - Structural: Galaxy, World, Page
  - Functional: Navigation, Feature, Widget
  - Logic: Flow, Custom

Step 2: Basic Info
  - Name, Description, Icon
  - Universe scope (if applicable)

Step 3: Configuration (type-specific)
  - Galaxy: Route, layout preferences
  - Page: Template selection → Opens editor
  - Flow: → Opens singularity
  - Navigation: Position, menu items
  - Feature: → Wizard with flow attachment

Step 4: Initial Structure (for galaxy/world)
  - Add children
  - Define relationships

Step 5: Review & Create
  - Summary
  - Create module
  - Auto-register with ModuleRegistry

📋 Action Items for Modularity


🔗 INTEGRATION STRATEGY

Cross-Library Communication

/**
 * Unified Module Creation Flow
 */

// 1. User clicks "Create Module" in module-browser
→ Opens modularity wizard

// 2. User selects module type
→ Wizard determines routing

// 3. Type-specific routing
if (type === 'page') {
  → navigate to editor-web with universe context
  → editor creates page
  → editor saves as UniversalModule
  → editor registers with ModuleRegistry
  → page appears in module-browser
}

if (type === 'flow') {
  → navigate to singularity with universe context
  → singularity creates flow
  → singularity saves as UniversalModule
  → singularity registers with ModuleRegistry
  → flow appears in module-browser
}

if (type === 'galaxy' || type === 'world') {
  → navigate to modular-universe
  → modular-universe creates structure
  → saves as UniversalModule
  → registers with ModuleRegistry
}

// 4. Module available everywhere
→ Module-browser shows new module
→ Section-config-panel can assign it
→ Space-builder can reuse it

Storage Schema Unification

Current (Inconsistent):

// Singularity
storage.put('flow:123', flowData);

// Editor-web
storage.put('page:456', pageData);

// Modularity
storage.put('module:789', moduleData);

Needed (Unified):

// All as universal modules
storage.putInUniverse(spaceId, universeId, 'module:flow-123', flowModule);
storage.putInUniverse(spaceId, universeId, 'module:page-456', pageModule);
storage.putInUniverse(spaceId, universeId, 'module:navigation-789', navModule);

// Query by type
const pages = await storage.queryModulesByType(universeId, 'page');
const flows = await storage.queryModulesByType(universeId, 'flow');

Service Layer Integration

Needed: UnifiedModuleCreationService

@Injectable()
export class UnifiedModuleCreationService {
  
  /**
   * Create module with type-specific routing
   */
  async createModule(
    type: ModuleType,
    universeId: string,
    context?: { sectionId?: string; parentId?: string }
  ): Promise<UniversalModule> {
    
    // Route to appropriate builder
    const route = this.getBuilderRoute(type, universeId, context);
    this.router.navigate([route]);
    
    // Return promise that resolves when module is created
    return this.awaitModuleCreation();
  }
  
  /**
   * Get builder route based on type
   */
  private getBuilderRoute(
    type: ModuleType,
    universeId: string,
    context?: any
  ): string {
    const routes = {
      'page': `/space/${this.spaceSlug}/editor`,
      'flow': `/space/${this.spaceSlug}/singularity/flows`,
      'galaxy': `/space/${this.spaceSlug}/modular-universe`,
      'world': `/space/${this.spaceSlug}/modular-universe`,
      'navigation': `/space/${this.spaceSlug}/modularity/builder`,
      'feature': `/space/${this.spaceSlug}/modularity/builder`,
      'widget': `/space/${this.spaceSlug}/widgets/builder`
    };
    
    const base = routes[type] || routes['page'];
    const params = new URLSearchParams({
      universe: universeId,
      type: type,
      mode: 'create',
      ...(context?.sectionId && { section: context.sectionId })
    });
    
    return `${base}?${params}`;
  }
}

📊 IMPLEMENTATION PRIORITY

Phase 1: Storage Unification (Week 1)

Phase 2: Module Registry Integration (Week 2)

Phase 3: Cross-Tool Navigation (Week 3)

Phase 4: Enhanced Integration (Week 4)


🎯 SUCCESS METRICS

Technical Integration

User Experience

Platform Cohesion


📚 RELATED DOCUMENTS


Status: ✅ REVIEW COMPLETE
Next Action: Implement storage unification
Owner: Development Team
Last Updated: November 14, 2025