DragonFire Developer Portal

DragonFire Core SDK Documentation

Version 1.2.0

Overview

The DragonFire Core SDK provides direct access to the fundamental components of the DragonFire ecosystem. This SDK serves as the foundation for interacting with DragonFire's advanced mathematical and geometric computing infrastructure.

Key Features

  • Direct access to the DragonFire Kernel for fractal execution and processing
  • Integration with the distributed Cache system for millisecond-level synchronization
  • Utilization of DragonHeart's harmonic processing capabilities
  • Access to zero-latency geometric compute nodes via DragonCube
  • Interface with the holographic system shell through DragonXOS
  • Seamless integration with Dragon Wallets for secure identity and transactions
DragonFire Architecture Diagram
DragonFire Core Architecture

Installation

Install the DragonFire Core SDK using your preferred package manager:

npm install @dragonfire/core-sdk
yarn add @dragonfire/core-sdk

Or include it directly in your HTML:

<script src="https://cdn.dragonfire.ai/sdk/core-sdk-1.2.0.js"></script>

Initialization

To use the Core SDK, you first need to initialize it with your API credentials:

import { DragonFireCore } from '@dragonfire/core-sdk';

// Initialize the core SDK
const core = new DragonFireCore({
  apiKey: 'YOUR_API_KEY',
  region: 'us-west',
  securityLevel: 'high',
  logLevel: 'error',
  timeout: 30000
});

// Connect to DragonFire services
await core.connect();

Configuration Options

Parameter Type Default Description
apiKey string Required Your DragonFire API key
region string 'us-west' Server region ('us-west', 'us-east', 'eu', 'asia')
securityLevel string 'standard' Security level ('standard', 'high', 'maximum')
logLevel string 'error' Logging level ('debug', 'info', 'warn', 'error')
timeout number 30000 Request timeout in milliseconds
retryStrategy object { maxRetries: 3, initialDelay: 300, maxDelay: 3000 } Retry strategy configuration

Core Components

The DragonFire Core SDK provides access to several fundamental components that form the foundation of the DragonFire ecosystem:

Kernel

The fractal execution layer that powers all DragonFire services, providing optimized mathematical processing pathways.

Learn More

Cache

Millisecond-level distributed memory synchronization system for ultra-low latency data access across services.

Learn More

DragonHeart

Harmonic processing engine utilizing fundamental mathematical constants (Pi, Phi, √2, √3) for optimized computation.

Learn More

DragonCube

Zero-latency geometric compute node with 3x3x3 cube architecture and 7-dimensional center state vectors.

Learn More

DragonXOS

Holographic system shell that coordinates all DragonFire components and provides a unified interface.

Learn More

Kernel

The DragonFire Kernel is the fractal execution layer that powers all DragonFire services. It provides optimized mathematical processing pathways using phi-resonant patterns.

// Access the Kernel
const kernel = core.kernel;

// Execute a fractal operation
const result = await kernel.execute({
  pattern: 'phi',                    // Mathematical pattern (phi, pi, sqrt2, sqrt3, e)
  dimensions: 7,                     // Processing dimensions (3-13)
  operation: 'transform',            // Operation type
  data: [1, 1, 2, 3, 5, 8, 13],      // Input data
  options: {
    precision: 'high',               // Processing precision
    optimizationLevel: 'maximum',    // Optimization level
    returnFormat: 'array'            // Return format
  }
});

// Process data streams
const stream = kernel.createStream({
  pattern: 'phi',
  dimensions: 7,
  continuousProcessing: true
});

stream.on('data', (processedData) => {
  console.log('Processed data:', processedData);
});

stream.write([1, 1, 2, 3, 5]);
stream.write([8, 13, 21, 34, 55]);

// Close the stream when done
stream.end();

Mathematical Patterns

The Kernel supports several mathematical patterns for optimized processing:

  • phi: Golden Ratio (φ = 1.618...) - Optimal for balanced operations
  • pi: Pi (π = 3.14159...) - Best for circular and cyclical data
  • sqrt2: Square Root of 2 (√2 = 1.414...) - Optimal for binary operations
  • sqrt3: Square Root of 3 (√3 = 1.732...) - Optimal for triangular operations
  • e: Euler's Number (e = 2.718...) - Best for exponential growth calculations

For detailed information on Kernel functions and capabilities, see the complete Kernel documentation.

Cache

The DragonFire Cache provides millisecond-level distributed memory synchronization across services. It enables ultra-low latency data access with fractal-optimized storage patterns.

// Access the Cache
const cache = core.cache;

// Store data in cache
await cache.set('user_profile_123', {
  name: 'Alice',
  preferences: { theme: 'dark', language: 'en' }
}, {
  ttl: 3600,                   // Time-to-live in seconds
  pattern: 'fractal',          // Storage pattern (fractal, linear, network)
  priority: 'high',            // Cache priority
  sync: true                   // Synchronize across nodes
});

// Retrieve data from cache
const userData = await cache.get('user_profile_123');

// Store multiple items
await cache.mset([
  { key: 'key1', value: 'value1', ttl: 3600 },
  { key: 'key2', value: 'value2', ttl: 7200 }
], { pattern: 'fractal' });

// Retrieve multiple items
const multiData = await cache.mget(['key1', 'key2']);

// Delete cache item
await cache.delete('user_profile_123');

// Clear cache region
await cache.clear({ pattern: 'user_*' });

Cache Patterns

The Cache supports different storage patterns for optimized data access:

  • fractal: Recursive pattern with geometric optimization (default)
  • linear: Traditional key-value storage
  • network: Graph-based storage for relational data
  • temporal: Time-optimized storage for sequential data

For detailed information on Cache functions and capabilities, see the complete Cache documentation.

DragonHeart

DragonHeart is a harmonic processing engine that utilizes fundamental mathematical constants (Pi, Phi, √2, √3) for optimized computation. It enables advanced pattern recognition and transformation capabilities.

// Access DragonHeart
const heart = core.heart;

// Process data with harmonic patterns
const harmonicResult = await heart.process({
  sequence: [1, 1, 2, 3, 5, 8, 13],   // Input sequence
  pattern: 'fibonacci',                // Sequence pattern
  resonance: 'phi',                    // Resonance pattern
  dimensions: 7,                       // Processing dimensions
  options: {
    precision: 'maximum',              // Processing precision
    iterationLimit: 100,               // Maximum iterations
    convergenceTolerance: 0.0001       // Convergence tolerance
  }
});

// Find pattern resonance
const resonanceResult = await heart.findResonance({
  data: [1.2, 3.5, 8.1, 14.7, 21.3],
  patterns: ['phi', 'pi', 'sqrt2', 'sqrt3', 'e'],
  threshold: 0.85
});

// Transform data using harmonic mapping
const transformedData = await heart.transform({
  source: sourceData,
  sourcePattern: 'logarithmic',
  targetPattern: 'exponential',
  harmonicBase: 'phi'
});

Harmonic Processing

DragonHeart excels at identifying and working with mathematical patterns in data:

  • Pattern Recognition: Identifies underlying mathematical patterns in data
  • Harmonic Transformation: Converts between different mathematical representations
  • Phi-Resonant Processing: Optimizes calculations using golden ratio relationships
  • Multi-Dimensional Analysis: Processes data across multiple mathematical dimensions

For detailed information on DragonHeart functions and capabilities, see the complete DragonHeart documentation.

DragonCube

DragonCube provides zero-latency geometric compute nodes with a 3x3x3 cube architecture and 7-dimensional center state vectors. It enables high-performance geometric calculations and transformations.

// Access DragonCube
const cube = core.cube;

// Initialize a compute cube
const computeCube = await cube.initialize({
  dimensions: 3,                 // Physical cube dimensions
  centerDimensions: 7,           // Center state vector dimensions
  optimizationPattern: 'phi',    // Optimization pattern
  architecture: 'octahedral'     // Computation architecture
});

// Execute a geometric operation
const result = await computeCube.execute({
  operation: 'transform',
  input: inputData,
  transformationType: 'jitterbug',
  parameters: {
    rotationAngle: Math.PI / 4,
    scaling: 1.5,
    iterations: 3
  }
});

// Perform a dimensional mapping
const mappedData = await computeCube.mapDimensions({
  sourceData: sourceData,
  sourceDimensions: 3,
  targetDimensions: 7,
  mappingFunction: 'harmonic'
});

// Close the compute cube when done
await computeCube.close();

Geometric Architectures

DragonCube supports multiple geometric computation architectures:

  • octahedral: 8 triangular faces with harmonic relationships
  • tetrahedral: 4-point system with balanced processing
  • icosahedral: 20-face system with high geometric precision
  • dodecahedral: 12-face phi-based system for harmonic processing

For detailed information on DragonCube functions and capabilities, see the complete DragonCube documentation.

DragonXOS

DragonXOS is the holographic system shell that coordinates all DragonFire components and provides a unified interface. It manages system resources, component communication, and operation scheduling.

// Access DragonXOS
const xos = core.xos;

// Get system status
const systemStatus = await xos.getSystemStatus();
console.log('System status:', systemStatus);

// Register a component
await xos.registerComponent({
  id: 'custom-processor',
  type: 'processor',
  capabilities: ['transform', 'analyze'],
  resources: {
    memory: '256MB',
    cpu: 0.5
  }
});

// Create a processing flow
const flow = await xos.createFlow({
  name: 'data-processing-flow',
  steps: [
    { component: 'input', operation: 'read', output: 'raw-data' },
    { component: 'kernel', operation: 'process', input: 'raw-data', output: 'processed-data' },
    { component: 'custom-processor', operation: 'transform', input: 'processed-data', output: 'final-result' }
  ],
  options: {
    parallelExecution: true,
    optimizationLevel: 'high'
  }
});

// Execute the flow
const result = await flow.execute({
  inputData: sourceData,
  parameters: {
    transformType: 'geometric',
    precision: 'high'
  }
});

// Get system metrics
const metrics = await xos.getMetrics({
  components: ['kernel', 'cache', 'heart'],
  timeRange: '1h',
  resolution: '1m'
});

System Management

DragonXOS provides comprehensive system management capabilities:

  • Component Coordination: Manages communication between all DragonFire components
  • Resource Allocation: Optimizes resource distribution based on workload
  • Flow Creation: Enables creation of multi-step processing pipelines
  • Metrics and Monitoring: Provides detailed insights into system performance

For detailed information on DragonXOS functions and capabilities, see the complete DragonXOS documentation.

Wallet Integration

The Core SDK provides seamless integration with Dragon Wallets for secure identity management and financial transactions.

import { DragonFireCore } from '@dragonfire/core-sdk';
import { WalletClient } from '@dragonfire/wallet-client';

// Initialize the core SDK
const core = new DragonFireCore({
  apiKey: 'YOUR_API_KEY',
  region: 'us-west'
});
await core.connect();

// Initialize the wallet client with core
const wallet = new WalletClient(core, {
  securityLevel: 'high',
  vectorDimension: 7
});

// Create a wallet
const walletInfo = await wallet.createWallet({
  name: 'Primary Wallet',
  attributes: { purpose: 'development' }
});

// Execute a wallet operation through core
const transactionResult = await core.executeWalletOperation({
  operation: 'transfer',
  walletId: walletInfo.id,
  parameters: {
    recipient: 'recipient-wallet-id',
    amount: 100,
    currency: 'USD',
    memo: 'Test transfer'
  }
});

Core-Wallet Integration Benefits

Integrating wallets through the Core SDK provides several advantages:

  • Optimized Routing: Transactions use geometry-optimized pathways
  • Enhanced Security: Core security protocols protect wallet operations
  • Performance Boost: Direct access to low-level compute resources
  • Unified Authentication: Single authentication flow for all services

For detailed information on wallet integration, see the complete Wallet Integration documentation.

Error Handling

The Core SDK provides a comprehensive error handling system that helps identify and resolve issues during operation.

try {
  // Attempt a core operation
  const result = await core.kernel.execute({
    pattern: 'phi',
    dimensions: 7,
    operation: 'transform',
    data: inputData
  });
} catch (error) {
  // Handle specific error types
  if (error.code === 'KERNEL_EXECUTION_ERROR') {
    console.error('Kernel execution failed:', error.message);
    console.error('Operation:', error.details.operation);
    console.error('Pattern:', error.details.pattern);
    
    // Attempt recovery with alternative pattern
    try {
      const recoveryResult = await core.kernel.execute({
        pattern: 'pi', // Try alternative pattern
        dimensions: 7,
        operation: 'transform',
        data: inputData
      });
      console.log('Recovery successful with pi pattern');
    } catch (recoveryError) {
      console.error('Recovery failed:', recoveryError.message);
    }
  } else if (error.code === 'CONNECTION_ERROR') {
    console.error('Connection issue:', error.message);
    await core.reconnect();
  } else {
    console.error('Unknown error:', error);
  }
}

Common Error Codes

Error Code Description Recommended Action
AUTH_FAILED Authentication failed due to invalid API key Verify API key and permissions
CONNECTION_ERROR Unable to establish connection to DragonFire services Check network connection and try reconnecting
KERNEL_EXECUTION_ERROR Error executing operation in the Kernel Verify input data and operation parameters
CACHE_OPERATION_FAILED Cache operation failed Check cache key and value format
HEART_PROCESSING_ERROR Error during DragonHeart processing Verify sequence data and pattern compatibility
CUBE_INITIALIZATION_ERROR Error initializing DragonCube Check dimension parameters and availability
XOS_COMPONENT_ERROR Error with DragonXOS component operation Verify component registration and resources
WALLET_OPERATION_FAILED Wallet operation failed Check wallet credentials and parameters

Code Examples

Basic Data Processing

import { DragonFireCore } from '@dragonfire/core-sdk';

async function processData() {
  // Initialize the core SDK
  const core = new DragonFireCore({
    apiKey: 'YOUR_API_KEY',
    region: 'us-west'
  });
  await core.connect();
  
  // Prepare sample data
  const sampleData = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
  
  // Process with Kernel
  const kernelResult = await core.kernel.execute({
    pattern: 'phi',
    dimensions: 7,
    operation: 'transform',
    data: sampleData
  });
  console.log('Kernel processing result:', kernelResult);
  
  // Store in Cache
  await core.cache.set('fibonacci-sequence', sampleData, {
    ttl: 3600,
    pattern: 'fractal'
  });
  console.log('Data stored in cache');
  
  // Process with DragonHeart
  const heartResult = await core.heart.process({
    sequence: sampleData,
    pattern: 'fibonacci',
    resonance: 'phi'
  });
  console.log('Heart processing result:', heartResult);
  
  // Disconnect when done
  await core.disconnect();
}

processData().catch(console.error);

Multi-Component Workflow

import { DragonFireCore } from '@dragonfire/core-sdk';

async function runComplexWorkflow(inputData) {
  // Initialize the core SDK
  const core = new DragonFireCore({
    apiKey: 'YOUR_API_KEY',
    region: 'us-west'
  });
  await core.connect();
  
  try {
    // Step 1: Initialize a DragonCube
    const computeCube = await core.cube.initialize({
      dimensions: 3,
      centerDimensions: 7,
      optimizationPattern: 'phi'
    });
    
    // Step 2: Transform input data geometrically
    const transformedData = await computeCube.execute({
      operation: 'transform',
      input: inputData,
      transformationType: 'jitterbug'
    });
    
    // Step 3: Cache the intermediate result
    await core.cache.set('workflow-intermediate', transformedData, {
      ttl: 1800,
      pattern: 'fractal'
    });
    
    // Step 4: Process with DragonHeart
    const processedData = await core.heart.process({
      sequence: transformedData,
      pattern: 'harmonic',
      resonance: 'phi'
    });
    
    // Step 5: Create a system flow with DragonXOS
    const flow = await core.xos.createFlow({
      name: 'final-processing-flow',
      steps: [
        { component: 'input', operation: 'read', output: 'raw-data' },
        { component: 'processor', operation: 'analyze', input: 'raw-data', output: 'analyzed-data' },
        { component: 'output', operation: 'format', input: 'analyzed-data', output: 'final-result' }
      ]
    });
    
    // Step 6: Execute the flow with the processed data
    const finalResult = await flow.execute({
      inputData: processedData,
      parameters: {
        precision: 'high',
        outputFormat: 'structured'
      }
    });
    
    // Close resources
    await computeCube.close();
    
    return finalResult;
  } catch (error) {
    console.error('Workflow error:', error);
    throw error;
  } finally {
    // Ensure proper disconnection
    await core.disconnect();
  }
}

// Example usage
const sampleData = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];

runComplexWorkflow(sampleData)
  .then(result => console.log('Workflow completed:', result))
  .catch(error => console.error('Workflow failed:', error));

Wallet Integration Example

import { DragonFireCore } from '@dragonfire/core-sdk';
import { WalletClient } from '@dragonfire/wallet-client';

async function integratedWalletExample() {
  // Initialize the core SDK
  const core = new DragonFireCore({
    apiKey: 'YOUR_API_KEY',
    region: 'us-west'
  });
  await core.connect();
  
  // Initialize wallet client with core
  const wallet = new WalletClient(core, {
    securityLevel: 'high',
    vectorDimension: 7
  });
  
  try {
    // Create or load a wallet
    let userWallet;
    try {
      userWallet = await wallet.loadWallet('existing-wallet-id');
      console.log('Loaded existing wallet:', userWallet.id);
    } catch (error) {
      userWallet = await wallet.createWallet({
        name: 'New Integrated Wallet',
        attributes: { purpose: 'demonstration' }
      });
      console.log('Created new wallet:', userWallet.id);
    }
    
    // Process data with kernel
    const dataToProcess = [1, 1, 2, 3, 5, 8, 13];
    const processedData = await core.kernel.execute({
      pattern: 'phi',
      dimensions: 7,
      operation: 'transform',
      data: dataToProcess
    });
    
    // Store processed result in cache
    const cacheKey = `wallet:${userWallet.id}:processed-data`;
    await core.cache.set(cacheKey, processedData, {
      ttl: 3600,
      pattern: 'fractal'
    });
    
    // Create a transaction record
    const transactionResult = await wallet.createTransaction({
      recipient: 'recipient-wallet-id',
      amount: processedData[0], // Use processed data in transaction
      currency: 'USD',
      memo: 'Integrated workflow transaction'
    });
    
    // Store transaction in DragonXOS flow
    const flow = await core.xos.createFlow({
      name: 'transaction-recording-flow',
      steps: [
        { component: 'wallet', operation: 'verify', output: 'verified-tx' },
        { component: 'logger', operation: 'record', input: 'verified-tx', output: 'log-entry' },
        { component: 'notification', operation: 'send', input: 'log-entry', output: 'notification' }
      ]
    });
    
    await flow.execute({
      inputData: {
        transaction: transactionResult,
        walletId: userWallet.id
      }
    });
    
    return {
      walletId: userWallet.id,
      processedData: processedData,
      transactionId: transactionResult.id
    };
  } catch (error) {
    console.error('Integration error:', error);
    throw error;
  } finally {
    await core.disconnect();
  }
}

integratedWalletExample()
  .then(result => console.log('Integration successful:', result))
  .catch(error => console.error('Integration failed:', error));