HoloSphere
HoloSphere
HoloSphere is a JavaScript library that provides a spatial data management system using H3 geospatial indexing and GunDB for distributed storage. It enables you to store, validate, and retrieve data organized by geographic location using holonic principles.
What is a Holon?
A holon (from Greek 'holos' meaning whole, with suffix 'on' meaning part) is simultaneously a whole and a part. In HoloSphere, holons are implemented as hierarchical geographic cells that can:
Act as autonomous units (storing their own data)
Be part of larger holons (through H3's hierarchical structure)
Contain smaller holons (through subdivision)
Interact with peer holons (through the distributed network)
Holonic Architecture
HoloSphere implements holonic architecture in two ways:
1. Spatial Hierarchy
// Get holons at different scales for a location
const holon = await sphere.getHolon(lat, lng, 7); // City level
const parent = h3.cellToParent(holon, 6); // Region level
const children = h3.cellToChildren(holon, 8); // Neighborhood level
// Get entire hierarchy
const scales = sphere.getHolonScalespace(holon); // All containing holons2. Data Organization
Use Cases
Localized Structures
Local environmental monitoring
Community event coordination
Neighborhood resource sharing
Municipal service management
Delocalized Structures
Regional data aggregation
Cross-boundary collaboration
Distributed decision making
Resource flow tracking
Hybrid Structures
Adaptive governance systems
Scalable social networks
Emergency response coordination
Supply chain management
Key Benefits
Scalability: Holons can be nested infinitely, allowing systems to scale organically
Autonomy: Each holon manages its own data while participating in larger structures
Flexibility: Systems can be organized both hierarchically and peer-to-peer
Resilience: Distributed storage ensures no single point of failure
Adaptability: Structures can evolve based on changing needs
Installation
Quick Start
Real-World Examples
Environmental Monitoring System
Location-Based Content System
Data Validation Example
API Reference
Constructor
Core Methods
async getHolon(lat, lng, resolution)- Get H3 index for coordinatesasync put(holon, lens, data)- Store dataasync get(holon, lens, key)- Retrieve specific dataasync getAll(holon, lens)- Retrieve all dataasync delete(holon, lens, key)- Delete specific dataasync deleteAll(holon, lens)- Delete all dataasync setSchema(lens, schema)- Set JSON schema for validationasync getSchema(lens)- Get current schemasubscribe(holon, lens, callback)- Listen for changes
Storage Architecture
Data in HoloSphere is organized by:
Holons: H3 geographic indexes
Lenses: Data categories/types
Items: Individual data entries with unique IDs
Dependencies
h3-js: Uber's H3 geospatial indexing
gun: Decentralized database
ajv: JSON Schema validation
openai: AI capabilities (optional)
License
GPL-3.0-or-later
HoloSphere Federation
HoloSphere provides a federation system that allows spaces to share data and messages across different holons. This document outlines the federation functionality and how to use it.
Core Federation Features
Space Federation
Create relationships between spaces with clear source-target connections
Use soul references to maintain a single source of truth
Control data propagation between federated spaces
Manage notification settings for each space
Message Federation
Track messages across federated spaces
Maintain message relationships between original and federated copies
Update messages consistently across all federated spaces
API Reference
Space Federation
federate(spaceId1, spaceId2, password1, password2, bidirectional)
Creates a federation relationship between two spaces.
This sets up:
space1.federation includes space2
space2.notify includes space1
Parameters:
spaceId1: First space ID (source space)spaceId2: Second space ID (target space)password1: Optional password for first spacepassword2: Optional password for second spacebidirectional: Whether to set up bidirectional notifications (default: true, but generally not needed)
Data Propagation
propagate(holon, lens, data, options)
Propagates data to federated spaces.
Parameters:
holon: The holon identifierlens: The lens identifierdata: The data to propagateoptions: Propagation options
Alternatively, you can use auto-propagation:
Message Federation
federateMessage(originalChatId, messageId, federatedChatId, federatedMessageId, type)
Tracks a federated message across different chats.
getFederatedMessages(originalChatId, messageId)
Gets all federated messages for a given original message.
updateFederatedMessages(originalChatId, messageId, updateCallback)
Updates a message across all federated chats.
Usage Example
Soul References
When using the default useReferences: true with propagation:
Only a lightweight reference is stored in the federated space
The reference contains the original item's ID and soul path
When accessed, the reference is automatically resolved to the original data
Changes to the original data are immediately visible through references
This maintains a single source of truth while keeping storage efficient.
Federation Structure
The federation system uses two key arrays to manage relationships:
Last updated
Was this helpful?