Structural Libraries
Foundational libraries that power GoGrab Space applications
📚 Structural Libraries
Structural Angular libraries that provide essential functionality for all GoGrab Space applications.
This section documents the structural libraries that form the backbone of the GoGrab Space ecosystem, providing reusable components, services, and utilities that power our applications.
🎯 What Are Structural Libraries?
Structural libraries are shared, standalone Angular libraries that:
- 🔧 Provide Reusable Functionality - Components, services, and utilities used across multiple apps
- 📦 Standalone Architecture - Modern Angular 20+ standalone components
- 🔌 Easy Integration - Simple imports via TypeScript path aliases
- ⚡ Optimized Performance - Tree-shakeable and production-ready
- 🎨 Consistent Patterns - Follow our architectural best practices
📖 Available Libraries
🌌 Singularity Library ⭐ PRIMARY LIBRARY
The flagship library for hierarchical content visualization and management.
Key Features:
- Visual Constellation View - Interactive space-themed interface
- Flash Persistence - Zero-config automatic state persistence
- Smart Storage - Intelligent multi-adapter storage system
- Reactive State - Angular signals-based state management
- Type-Safe - Full TypeScript support
Components:
SpaceEditorComponent- Main editor interfaceGalaxyDetailComponent- Galaxy managementUniverseDetailComponent- Universe organizationSpaceOverviewComponent- High-level overview
Services:
SpaceMapFlashStateService- Reactive state with auto-persistenceSpaceMapStorageService- Legacy NGXS bridgeSpaceMapAdapterService- Storage adapter managementWorldIntegrationService- Cross-world operations
Use Cases:
- Content hierarchy visualization
- Site architecture mapping
- Documentation organization
- Multi-platform content management
🏗️ Library Architecture
Dependency Flow
┌─────────────────────────────────────┐
│ Applications (gograb-space, etc.) │
└────────────────┬────────────────────┘
↓
┌─────────────────────────────────────────────────┐
│ Structural Libraries (singularity-lib) │
└────────────────┬─────────────────────────────┘
↓
┌───────────────────────────────────────────────┐
│ Shared Systems │
│ • @storage-system │
│ • @theme-system │
└─────────────────────────────────────┘
Import Pattern
// Import from path alias
import {
SpaceEditorComponent,
SpaceMapFlashStateService,
PageNode,
GalaxyGroup
} from '@space-map-lib';
// Use in your component
@Component({
standalone: true,
imports: [SpaceEditorComponent],
template: '<space-editor></space-editor>'
})
export class MyComponent {
private spaceState = inject(SpaceMapFlashStateService);
worlds = this.spaceState.worlds;
galaxies = this.spaceState.galaxies;
}
🎯 Why Use Structural Libraries?
For Application Developers
✅ Reduced Development Time
- Pre-built, tested components ready to use
- No need to reinvent common functionality
- Focus on business logic, not infrastructure
✅ Consistent Experience
- Unified design language across applications
- Predictable behavior and APIs
- Standardized patterns and practices
✅ Easy Maintenance
- Updates propagate to all consuming apps
- Bug fixes benefit entire ecosystem
- Centralized documentation and testing
For Library Maintainers
✅ Single Source of Truth
- One place to maintain core functionality
- Easier to add features and fix bugs
- Clear ownership and responsibility
✅ Better Testing
- Isolated testing of library code
- Comprehensive test coverage
- Faster test execution
✅ Clear Dependencies
- Explicit dependency graph
- Easier to track and manage
- Better build optimization
🔧 Integration Best Practices
1. Use TypeScript Path Aliases
// ✅ DO: Use path alias
import { SpaceEditorComponent } from '@space-map-lib';
// ❌ DON'T: Use relative paths
import { SpaceEditorComponent } from '../../../../libs/space-map-lib/src/...';
2. Import Only What You Need
// ✅ DO: Tree-shakeable imports
import { SpaceEditorComponent } from '@space-map-lib';
// ❌ DON'T: Wildcard imports
import * as SpaceMapLib from '@space-map-lib';
3. Follow Standalone Component Patterns
// ✅ DO: Use standalone imports
@Component({
standalone: true,
imports: [SpaceEditorComponent, CommonModule]
})
export class MyComponent {}
// ❌ DON'T: Use NgModules
@NgModule({
imports: [SpaceMapLibModule]
})
export class MyModule {}
4. Leverage Dependency Injection
// ✅ DO: Use inject() function
export class MyComponent {
private spaceState = inject(SpaceMapFlashStateService);
}
// ✅ ALSO OK: Constructor injection
export class MyComponent {
constructor(private spaceState: SpaceMapFlashStateService) {}
}
🚀 Building Structural Libraries
Development Commands
# Build the library
npx nx build space-map-lib
# Run tests
npx nx test space-map-lib
# Lint code
npx nx lint space-map-lib
# Build all core libs
npx nx run-many --target=build --projects=space-map-lib,other-lib
Publishing Pattern
Core libraries are built as part of the monorepo and referenced via TypeScript path aliases. No separate publishing step required!
📊 Library Metrics
Space Map Library
- Components: 4 major UI components
- Services: 8 core services
- Models: 10+ TypeScript interfaces
- Lines of Code: ~4,500 (well-documented)
- Test Coverage: Comprehensive unit tests
- Dependencies: Minimal external dependencies
🔗 Related Documentation
System Integration
- Storage System - Intelligent storage architecture
- Flash Persistence - Auto-persistence system
- Theme System - Design and styling system
Application Usage
- Space Map App - Reference implementation
- GoGrab Space - All GoGrab Space applications
Development Guides
- Library Conversion - How to convert apps to libraries
- Cross-App Usage - Sharing code across applications
💡 Future Libraries
Planned structural libraries for the GoGrab Space ecosystem:
🎨 Cosmic UI Kit
Reusable UI components with space-themed styling:
- Cosmic buttons and cards
- Nebula backgrounds
- Starfield effects
- Glass morphism utilities
🔄 Sync Engine
Real-time synchronization across devices:
- Multi-tab coordination
- Cloud backup integration
- Conflict resolution
- Offline support
📊 Analytics Core
Unified analytics and monitoring:
- User interaction tracking
- Performance metrics
- Error monitoring
- Usage patterns
📚 Structural libraries provide the foundation for building amazing GoGrab Space applications!
Leverage these well-tested, production-ready components to accelerate your development and ensure consistency across the entire platform.