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 locationconstholon=awaitsphere.getHolon(lat,lng,7);// City levelconstparent=h3.cellToParent(holon,6);// Region levelconstchildren=h3.cellToChildren(holon,8);// Neighborhood level// Get entire hierarchyconstscales=sphere.getHolonScalespace(holon);// All containing holons
2. 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 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
// Strict validation with custom schema
const sphere = new HoloSphere('validated-data', true);
const measurementSchema = {
type: 'object',
properties: {
id: { type: 'string' },
value: { type: 'number' },
unit: { type: 'string' },
accuracy: { type: 'number' },
timestamp: { type: 'number' }
},
required: ['id', 'value', 'unit'],
additionalProperties: false
};
await sphere.setSchema('measurements', measurementSchema);
// This will succeed
await sphere.put(holon, 'measurements', {
id: 'measure-1',
value: 42.5,
unit: 'celsius',
accuracy: 0.1,
timestamp: Date.now()
});
// This will fail due to schema validation
await sphere.put(holon, 'measurements', {
id: 'measure-2',
value: "invalid", // wrong type
extra: "field" // not allowed
});
new HoloSphere(
appName, // String: Namespace for your application
strict, // Boolean: Enable strict schema validation (default: false)
openaikey // String: Optional OpenAI API key for AI features
)