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:

  1. Act as autonomous units (storing their own data)

  2. Be part of larger holons (through H3's hierarchical structure)

  3. Contain smaller holons (through subdivision)

  4. 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 holons

2. Data Organization

Use Cases

  1. Localized Structures

    • Local environmental monitoring

    • Community event coordination

    • Neighborhood resource sharing

    • Municipal service management

  1. Delocalized Structures

    • Regional data aggregation

    • Cross-boundary collaboration

    • Distributed decision making

    • Resource flow tracking

  1. Hybrid Structures

    • Adaptive governance systems

    • Scalable social networks

    • Emergency response coordination

    • Supply chain management

Key Benefits

  1. Scalability: Holons can be nested infinitely, allowing systems to scale organically

  2. Autonomy: Each holon manages its own data while participating in larger structures

  3. Flexibility: Systems can be organized both hierarchically and peer-to-peer

  4. Resilience: Distributed storage ensures no single point of failure

  5. 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 coordinates

  • async put(holon, lens, data) - Store data

  • async get(holon, lens, key) - Retrieve specific data

  • async getAll(holon, lens) - Retrieve all data

  • async delete(holon, lens, key) - Delete specific data

  • async deleteAll(holon, lens) - Delete all data

  • async setSchema(lens, schema) - Set JSON schema for validation

  • async getSchema(lens) - Get current schema

  • subscribe(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 space

  • password2: Optional password for second space

  • bidirectional: 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 identifier

  • lens: The lens identifier

  • data: The data to propagate

  • options: 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:

  1. Only a lightweight reference is stored in the federated space

  2. The reference contains the original item's ID and soul path

  3. When accessed, the reference is automatically resolved to the original data

  4. 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?