Universe Structure

Comprehensive guide to the Universe hierarchy, type systems, and interface definitions

Universe Structure

Overview

The Universe Structure is the foundational architecture for organizing applications within the editor2 platform. It provides a semantic, hierarchical system that maps directly to routing, layouts, and widget rendering.

This document serves as the single source of truth for understanding how universes, galaxies, worlds, and pages relate across all parts of the monorepo.


Visual Hierarchy

                           ┌─────────────────────────────────┐
                           │     PLATFORM-ROOT (The Sun)     │
                           │  User Label: "Universe Core"    │
                           │      Type: platform-root        │
                           └───────────────┬─────────────────┘
                                           │
              ┌────────────────────────────┼────────────────────────────┐
              │                            │                            │
              ▼                            ▼                            ▼
    ┌─────────────────┐          ┌─────────────────┐          ┌─────────────────┐
    │     GALAXY      │          │     GALAXY      │          │     GALAXY      │
    │  Admin Portal   │          │   Shop Portal   │          │   Dashboard     │
    │  Route: /admin  │          │  Route: /shop   │          │  Route: /dash   │
    │  Layout: split- │          │  Layout: top-   │          │  Layout: dash-  │
    │     sidebar     │          │      nav        │          │     board       │
    └────────┬────────┘          └────────┬────────┘          └─────────────────┘
             │                            │
    ┌────────┴────────┐          ┌────────┴────────┐
    │                 │          │                 │
    ▼                 ▼          ▼                 ▼
┌─────────┐     ┌─────────┐  ┌─────────┐     ┌─────────┐
│  WORLD  │     │  WORLD  │  │  WORLD  │     │  WORLD  │
│ Members │     │ Settings│  │Products │     │  Cart   │
│ /members│     │/settings│  │/products│     │  /cart  │
└────┬────┘     └─────────┘  └────┬────┘     └─────────┘
     │                            │
┌────┴────────────────┐     ┌────┴────────────────┐
│         │           │     │         │           │
▼         ▼           ▼     ▼         ▼           ▼
┌──────┐┌──────┐┌──────┐  ┌──────┐┌──────┐┌──────┐
│ PAGE ││ PAGE ││ PAGE │  │ PAGE ││ PAGE ││ PAGE │
│MODULE││MODULE││MODULE│  │MODULE││MODULE││MODULE│
│ List ││Detail││ Form │  │ List ││Detail││ Form │
│  ""  ││ :id  ││ /new │  │  ""  ││ :id  ││ /new │
└──────┘└──────┘└──────┘  └──────┘└──────┘└──────┘

Semantic Hierarchy (3 Levels)

Level Type User Label Purpose Route Layout Widgets
0 platform-root Universe Core The central sun / - NO
1 galaxy Galaxy Application Section /admin YES NO
2 world World Feature Group /members Optional NO
3 page-module Page Actual Page /:id Grid YES

Level Definitions

Platform Root (displayed as "Universe Core" to users)

Galaxy (Application Section)

World (Feature Group)

Page-Module (Actual Page)


Type Systems & Mappings

Type System Overview (Session 32.2 - Unified)

All type systems now use the SAME names - no conversion needed:

┌─────────────────────────────────────────────────────────────────────────┐
│                    UNIFIED TYPE SYSTEM (Session 32.2)                    │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  CosmicNodeType    =    ModuleType    =    CoreModuleType                │
│  (Canvas/Visual)        (Module Def)        (Core Logic)                 │
│                                                                          │
│  platform-root     =    platform-root  =    platform-root                │
│  galaxy            =    galaxy         =    galaxy                       │
│  world             =    world          =    world                        │
│  page-module       =    page-module    =    page-module                  │
│  page (deprecated) =    page           =    page                         │
│                                                                          │
│  User-facing labels: "Universe Core", "Galaxy", "World", "Page"          │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Mapping Table

Type User Label Description
platform-root Universe Core The central sun - root of platform
galaxy Galaxy Application section with layout
world World Feature group (groups pages)
page-module Page Actual page with widgets
page (Deprecated) DEPRECATED - use page-module

Type Mapping (Now 1:1)

Located in architect-module-converter.service.ts:

// Session 32.2: Direct 1:1 mappings - no conversion needed
private moduleTypeToNodeType(moduleType: ModuleType): CosmicNodeType {
  if (moduleType === 'platform-root') return 'platform-root';
  if (moduleType === 'galaxy') return 'galaxy';
  if (moduleType === 'world') return 'world';
  if (moduleType === 'page-module') return 'page-module';
  if (moduleType === 'page') return 'page';  // @deprecated
  // Fallback mappings for legacy types...
  return 'page-module';
}

Interface Sources

Core Models Library

Path: @libs/libs-foundational/core-models/src/lib/types/

File Interface Purpose
modules/modules.types.ts ModuleType Module type union
modules/modules.types.ts CoreModuleType Core module type union
modules/universal-module.types.ts UniversalModule Complete module definition
multiverse.types.ts Universe, Galaxy, Planet Legacy multiverse concepts
space-map/space-entities.types.ts GalaxyGroup, UniverseGroup Space map entities

Universe Architect Library

Path: @libs/libs-space/universe-architect/src/lib/types/

File Interface Purpose
cosmic-node.types.ts CosmicNodeType Canvas node type union
cosmic-node.types.ts CosmicNode Node instance on canvas
cosmic-node.types.ts CosmicNodeTypeConfig Visual/behavior config
cosmic-node.types.ts COSMIC_NODE_CONFIGS Config for each type
connection.types.ts NodePort Connection ports

Interface Definitions

ModuleType (Core Models)

// libs/libs-foundational/core-models/src/lib/types/modules/modules.types.ts

export type CoreModuleType =
  | 'platform-root'    // Universe core
  | 'galaxy'           // Application section
  | 'world'            // Feature group
  | 'page-module'      // Actual page (Session 32.2)
  | 'page'             // @deprecated
  | 'data'
  | 'content'
  | 'form'
  | 'workflow'
  | 'integration'
  | 'utility';

export type ModuleType = CoreModuleType | /* other types */;

CosmicNodeType (Universe Architect)

// libs/libs-space/universe-architect/src/lib/types/cosmic-node.types.ts

export type CosmicNodeType =
  | 'platform-root'    // The sun (User Label: "Universe Core")
  | 'galaxy'           // Application section
  | 'world'            // Feature group
  | 'page-module'      // Actual page
  | 'page';            // @deprecated

UniversalModule (Core Models)

// libs/libs-foundational/core-models/src/lib/types/modules/universal-module.types.ts

export interface UniversalModule {
  id: string;
  name: string;
  moduleType: ModuleType;
  description?: string;
  route?: string;
  parentId?: string;

  // Page-module specific
  pageId?: string;              // References Page document

  // Galaxy specific
  layout?: {
    template: 'split-sidebar' | 'dashboard' | 'top-nav' | 'content-only';
    regions?: Record<string, LayoutRegion>;
  };

  // World specific
  metadata?: {
    entityId?: string;          // e.g., 'member'
    entityPlural?: string;      // e.g., 'members'
  };

  children?: UniversalModule[];
  createdAt: string;
  updatedAt: string;
}

CosmicNode (Universe Architect)

// libs/libs-space/universe-architect/src/lib/types/cosmic-node.types.ts

export interface CosmicNode {
  id: string;
  type: CosmicNodeType;
  label: string;
  description?: string;
  position: CanvasPosition;
  parentId: string | null;
  childIds: string[];
  route?: string;
  pageId?: string;              // For page-module nodes
  moduleId?: string;
  icon?: string;
  color?: string;
  isExpanded: boolean;
  isLocked: boolean;
  inputs?: NodePort[];
  outputs?: NodePort[];
  createdAt: string;
  updatedAt: string;
  metadata?: Record<string, unknown>;
}

Visual Configuration

Node Appearance

Type User Label Icon Color Size Animation
platform-root Universe Core fa-sun #fbbf24 (gold) 200x200 pulse
galaxy Galaxy fa-solar-system #8b5cf6 (purple) 160x160 orbit
world World fa-globe #14b8a6 (teal) 120x120 spin
page-module Page fa-file-alt #3b82f6 (blue) 80x80 glow
page (Deprecated) fa-file #64748b (gray) 80x80 glow

Color Palette (COSMIC_COLORS)

export const COSMIC_COLORS = {
  // Node colors
  sunCore: '#fbbf24',           // platform-root (Universe Core)
  galaxyCore: '#8b5cf6',        // galaxy
  worldSurface: '#14b8a6',      // world
  pageModuleSurface: '#3b82f6', // page-module
  deprecatedPage: '#64748b',    // page (deprecated)

  // Connection colors
  hierarchyLine: '#6366f1',
  routeLine: '#22c55e',
  dataFlowLine: '#f59e0b',
  dependencyLine: '#ef4444',

  // Backgrounds
  void: '#000000',
  deepSpace: '#0a0a1a',
  nebulaDark: '#0f172a',
  nebulaLight: '#1e293b'
};

Integration with Modular-Universe

How Nodes Map to Runtime

Universe Architect (Design Time)          Modular Universe (Runtime)
─────────────────────────────────         ─────────────────────────────
Galaxy: "Admin" ──────────────────────►   CanvasSection with template
  │                                         ├── Region: sidebar (NavModule)
  │                                         └── Region: main (router-outlet)
  │
  └── World: "Members" ───────────────►   Route group + shared context
        │
        ├── Page-Module: "List" ──────►   PageModuleRendererComponent
        │     pageId: "member-list"         └── Renders DataTable widget
        │
        └── Page-Module: "Detail" ────►   PageModuleRendererComponent
              pageId: "member-detail"       └── Renders EntityCard widget

Layout Templates

Template Regions Use Case
split-sidebar sidebar, main Admin panels
top-nav header, main, footer Public sites
dashboard header, sidebar, main Analytics
content-only main Simple apps

File Locations Summary

Core Type Definitions

libs/libs-foundational/core-models/src/lib/types/
├── modules/
│   ├── modules.types.ts              # ModuleType, CoreModuleType
│   └── universal-module.types.ts     # UniversalModule interface
├── multiverse.types.ts               # Universe, Galaxy, Planet
└── space-map/
    └── space-entities.types.ts       # GalaxyGroup, UniverseGroup

Canvas/Visual Types

libs/libs-space/universe-architect/src/lib/
├── types/
│   ├── cosmic-node.types.ts          # CosmicNodeType, CosmicNode, COSMIC_NODE_CONFIGS
│   └── connection.types.ts           # NodePort, Connection types
└── services/
    └── architect-module-converter.service.ts  # Type conversion logic

AI Generation

libs/libs-ai/gograb-ai/src/lib/services/
└── ai-module-generator.service.ts    # Generates hierarchy from prompts

apis/backend-ai-api/src/app/workflow/services/
└── vibe-workflow-orchestrator.service.ts  # Orchestrates generation flow

Deprecation Notes

page Type

Planet Interface


Quick Reference

Creating a New Module Hierarchy

  1. Galaxy (Application Section)

    • Set moduleType: 'galaxy'
    • Define layout.template
    • Set root route (e.g., /admin)
  2. World (Feature Group)

    • Set moduleType: 'world'
    • Set parentId to galaxy
    • Define metadata.entityId
    • Set relative route (e.g., members)
  3. Page-Module (Actual Page)

    • Set moduleType: 'page-module'
    • Set parentId to world
    • Set pageId to reference Page document
    • Define route segment (e.g., :id)

Type Checking

// Check if node can have children
const config = COSMIC_NODE_CONFIGS[node.type];
const canHaveChildren = config.behavior.canHaveChildren;
const allowedChildTypes = config.behavior.allowedChildTypes;

Version History

Session Changes
31 Initial universe structure documentation
32.2 Added page-module type, updated semantic hierarchy, type consistency fixes