Foundation interfaces and types for the Starfleet ecosystem - A MIT-licensed contract for building importers, providers, and plugins.
The Starfleet SDK provides the core TypeScript interfaces, Go bindings, and JSON Schema definitions that enable interoperability across the entire Starfleet ecosystem. Whether you're building importers for infrastructure diagrams, providers for live metrics, or custom plugins for 3D visualization, this SDK defines the contracts you need.
Starfleet is a comprehensive platform for creating interactive 3D visualizations of infrastructure and systems. Think of it as "Infrastructure as Diagrams" with real-time data integration.
- 🎯 Type-safe contracts - Comprehensive TypeScript interfaces and Go structs
- 🔌 Plugin architecture - Standardized interfaces for importers, providers, and animation hooks
- 📐 3D scene modeling - Complete scene graph with nodes, edges, transforms, and materials
- 🎨 Material system - PBR-ready materials with textures and animations
- 📊 Live data integration - Real-time metrics and monitoring data support
- ✅ JSON Schema validation - Validate scene files in any language
- 🌐 Multi-language support - TypeScript and Go bindings included
| Language | Package | Description |
|---|---|---|
| TypeScript | @starfleet/sdk |
Core Scene types, plugin interfaces, utility helpers |
| Go | github.com/hyperdrive-technology/starfleet-sdk-go |
Generated structs and helper functions |
| JSON Schema | /schema/scenefile.schema.json |
Validation schema for any toolchain |
- SceneFile: Top-level container with metadata and scene graph
- SceneNode: Individual elements (servers, databases, containers, etc.)
- SceneEdge: Connections and relationships between nodes
- Transform: 3D positioning, rotation, and scale
- Material: PBR materials with colors, textures, and properties
- Importer: Transform external data sources (Terraform, K8s, etc.) into SceneFiles
- Provider: Supply live data and metrics to scene nodes (Prometheus, Datadog, etc.)
- AnimationHook: Custom animation behaviors for scene elements
npm install @starfleet/sdkimport {
SceneFile,
createTransform,
createMaterial,
generateId,
validateScene,
Importer,
Provider
} from '@starfleet/sdk';
// Create a simple infrastructure scene
const scene: SceneFile = {
version: '0.1.0',
metadata: {
name: 'My Infrastructure',
description: 'A sample infrastructure scene',
author: 'Your Name'
},
scene: {
nodes: [
{
id: generateId(),
type: 'server',
name: 'Web Server',
transform: createTransform(
{ x: 0, y: 0, z: 0 } // position
),
material: createMaterial({
color: { r: 0.2, g: 0.8, b: 0.2, a: 1 }
}),
status: 'healthy',
metadata: {
cpu: '85%',
memory: '12GB'
}
}
],
edges: []
}
};
// Validate the scene
const validation = validateScene(scene);
if (!validation.valid) {
console.error('Scene validation failed:', validation.errors);
}import { Importer, ImportResult } from '@starfleet/sdk';
class TerraformImporter implements Importer {
id = 'terraform-importer';
name = 'Terraform Infrastructure Importer';
description = 'Imports Terraform state into 3D scenes';
supportedFormats = ['.tfstate', '.tf'];
async import(input: string): Promise<ImportResult> {
const tfData = JSON.parse(input);
// Transform Terraform resources into SceneNodes
const nodes = tfData.resources.map(resource => ({
id: resource.name,
type: resource.type,
name: resource.name,
transform: createTransform({
x: Math.random() * 10,
y: 0,
z: Math.random() * 10
}),
material: createMaterial({
color: getColorForResourceType(resource.type)
}),
metadata: resource.instances[0]?.attributes || {}
}));
return {
scene: {
version: '0.1.0',
metadata: {
name: 'Terraform Infrastructure',
importedBy: this.id,
importedAt: new Date().toISOString()
},
scene: { nodes, edges: [] }
},
warnings: [],
errors: []
};
}
async validate(input: string): Promise<boolean> {
try {
JSON.parse(input);
return true;
} catch {
return false;
}
}
}import { Provider, MetricsQuery, MetricsResult } from '@starfleet/sdk';
class PrometheusProvider implements Provider {
id = 'prometheus-provider';
name = 'Prometheus Metrics Provider';
description = 'Provides metrics from Prometheus';
private baseUrl: string = '';
private connected = false;
async connect(config: any): Promise<void> {
this.baseUrl = config.url;
// Test connection
const response = await fetch(`${this.baseUrl}/-/healthy`);
if (!response.ok) {
throw new Error('Failed to connect to Prometheus');
}
this.connected = true;
}
async disconnect(): Promise<void> {
this.connected = false;
}
isConnected(): boolean {
return this.connected;
}
async query(query: MetricsQuery): Promise<MetricsResult[]> {
const results: MetricsResult[] = [];
for (const nodeId of query.nodeIds || []) {
for (const metricName of query.metricNames || []) {
// Query Prometheus for this metric
const promQuery = `${metricName}{instance="${nodeId}"}`;
const response = await fetch(
`${this.baseUrl}/api/v1/query?query=${encodeURIComponent(promQuery)}`
);
const data = await response.json();
results.push({
nodeId,
metricName,
dataPoints: data.data.result.map((r: any) => ({
timestamp: new Date(r.value[0] * 1000),
value: parseFloat(r.value[1]),
tags: r.metric
})),
unit: getUnitForMetric(metricName)
});
}
}
return results;
}
async healthCheck(): Promise<boolean> {
if (!this.connected) return false;
try {
const response = await fetch(`${this.baseUrl}/-/healthy`);
return response.ok;
} catch {
return false;
}
}
}go mod init your-project
go get github.com/hyperdrive-technology/starfleet-sdk-gopackage main
import (
"fmt"
"time"
"github.com/hyperdrive-technology/starfleet-sdk-go"
)
func main() {
// Create a scene with some infrastructure nodes
scene := starfleet.NewSceneFile("My Infrastructure")
// Add a server node
server := starfleet.SceneNode{
ID: "server-1",
Type: "server",
Name: "Web Server",
Transform: starfleet.NewTransform(),
Material: starfleet.NewMaterial(),
Status: "healthy",
Metadata: map[string]interface{}{
"cpu": "85%",
"memory": "12GB",
},
}
scene.AddNode(server)
// Add a database node
database := starfleet.SceneNode{
ID: "db-1",
Type: "database",
Name: "Primary Database",
Transform: starfleet.NewTransformWithPosition(5, 0, 0),
Material: starfleet.NewMaterial(),
Status: "healthy",
}
scene.AddNode(database)
// Connect them with an edge
edge := starfleet.SceneEdge{
ID: "conn-1",
Source: "server-1",
Target: "db-1",
Type: "data-connection",
Width: 0.1,
Style: "solid",
}
scene.AddEdge(edge)
fmt.Printf("Created scene with %d nodes and %d edges\n",
scene.GetNodeCount(), scene.GetEdgeCount())
}starfleet-sdk/
├── schema/
│ └── scenefile.schema.json # JSON Schema for validation
├── ts/
│ ├── src/
│ │ └── index.ts # TypeScript interfaces and utilities
│ ├── dist/ # Built packages (generated)
│ ├── package.json
│ └── tsconfig.json
├── go/
│ ├── models.go # Go struct definitions
│ ├── models_test.go # Go tests
│ └── go.mod
├── examples/
│ ├── basic-usage/ # Basic usage examples
│ └── README.md # Examples documentation
├── .github/
│ └── workflows/
│ └── publish.yml # CI/CD for publishing packages
├── CHANGELOG.md
├── LICENSE
└── README.md
A Starfleet scene file is a JSON document that represents a 3D infrastructure visualization:
{
"version": "0.1.0",
"metadata": {
"name": "Production Infrastructure",
"description": "Our main production environment",
"author": "DevOps Team",
"created": "2024-01-15T10:00:00Z",
"tags": ["production", "aws", "kubernetes"]
},
"scene": {
"nodes": [
{
"id": "web-server-1",
"type": "server",
"name": "Web Server",
"transform": {
"position": { "x": 0, "y": 0, "z": 0 },
"rotation": { "x": 0, "y": 0, "z": 0 },
"scale": { "x": 1, "y": 1, "z": 1 }
},
"geometry": {
"type": "box",
"parameters": { "width": 2, "height": 1, "depth": 1 }
},
"material": {
"color": { "r": 0.2, "g": 0.8, "b": 0.2, "a": 1 },
"metalness": 0.1,
"roughness": 0.7
},
"status": "healthy",
"metadata": {
"cpu": "85%",
"memory": "12GB",
"instance_type": "t3.large"
}
}
],
"edges": [
{
"id": "connection-1",
"source": "web-server-1",
"target": "database-1",
"type": "data-connection",
"color": { "r": 0.5, "g": 0.5, "b": 0.5, "a": 0.8 },
"width": 0.1,
"style": "solid"
}
]
}
}The SDK is designed to work seamlessly with other Starfleet components:
- starfleet - Main monorepo with CLI and React components
- starfleet-gateway - Go service for metrics aggregation
- starfleet-importer-tf - Terraform infrastructure import
- starfleet-provider-otel - OpenTelemetry metrics provider
- starfleet-provider-hyperdrive - Real-time data bridge
Importers transform external data sources into Starfleet scene files:
- Implement the
Importerinterface - Define supported file formats
- Parse input data and create SceneNodes/SceneEdges
- Return a complete SceneFile with metadata
Providers supply live data to scene nodes:
- Implement the
Providerinterface - Handle connection lifecycle (connect/disconnect)
- Query external systems for metrics
- Return standardized MetricsResult data
Animation hooks add custom behaviors to scenes:
- Implement the
AnimationHookinterface - Handle frame updates and node/edge changes
- Update scene properties based on data or time
cd ts
npm install
npm run build
npm testcd go
go mod tidy
go build
go testThis project follows Semantic Versioning.
Breaking changes to the core interfaces will result in a major version bump. All ecosystem packages should pin to the same major version of the SDK to ensure compatibility.
We welcome contributions! Please see our contributing guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes (ensure tests pass)
- Update documentation if needed
- Submit a pull request
MIT - See LICENSE for details.
Built with ❤️ by the Hyperdrive Technology team.