constellation-overwatch

module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2025 License: MIT

README ΒΆ

Constellation Overwatch

Constellation Overwatch

Open source Edge C4ISR Server Mesh for drone/robotic communication, telemetry streaming, and real-time command & control.



About

Constellation Overwatch is a distributed, event-driven C4ISR (Command, Control, Communications, and Intelligence) server mesh for managing fleets of autonomous systems including drones, robots, IoT sensors, and edge computing devices. Built on NATS JetStream for reliable, low-latency messaging with atomic operations and durable streams.

⚠️ Warning: This software is under active development. While functional, it may contain bugs and undergo breaking changes. Use caution with production deployments and ensure you have proper backups.

Features and Roadmap

  • Real-time Pub/Sub Messaging for low-latency communication between edge devices and control systems
  • Durable Event Streams using NATS JetStream for reliable message delivery and persistence
  • Multi-Entity Fleet Support for managing drones, robots, sensors, and other autonomous systems
  • RESTful API with bearer token authentication for secure HTTP access
  • Embedded NATS Server providing self-contained messaging with no external dependencies
  • High-Frequency Telemetry streaming with efficient handling of sensor data
  • Real-time Web Dashboard powered by Server-Sent Events (SSE) and Datastar framework
  • Type-Safe Templates using Templ for reactive Go-based web components
  • libSQL Database with auto-initialization and schema management
  • Event-Driven Architecture with workers for entities, commands, telemetry, and events

The following features are on our current roadmap:

  • Enhanced SSE Integration with PatchElements and PatchSignal for KV watcher on /overwatch
  • Interactive Maps using Mapbox or MapLibre web components with global KV watcher
  • Video Stream Proxy for 1:n video streaming to web UI
  • TLS 1.3 Encryption for enhanced NATS security
  • Unified API Layer consolidating REST and SSE endpoints
  • Logging Stream UI for centralized log viewing
  • WebSocket Support for alternative real-time communication
  • Kubernetes Deployment manifests and Helm charts
  • Prometheus Metrics integration for observability
  • Edge Client SDKs for Go, Python, and Rust

Architecture

API Service Diagram

graph LR
    subgraph "Client Layer"
        C1[Web Dashboard]
        C2[Mobile App]
        C3[CLI Tools]
        C4[Edge Devices]
    end
    
    subgraph "API Gateway"
        API[REST API<br/>:8080]
        AUTH[Bearer Auth<br/>Middleware]
    end
    
    subgraph "Core Services"
        OS[Organization<br/>Service]
        ES[Entity<br/>Service]
    end
    
    subgraph "Data Layer"
        DB[(libSQL/Turso DB)]
        NATS[(NATS JetStream<br/>CONSTELLATION_GLOBAL_STATE KV:entity_id)]
    end
    
    subgraph "NATS Streams"
        S1[CONSTELLATION_ENTITIES]
        S2[CONSTELLATION_EVENTS]
        S3[CONSTELLATION_TELEMETRY]
        S4[CONSTELLATION_COMMANDS]
    end
    
    C1 & C2 & C3 --> API
    C4 <--> NATS
    API --> AUTH
    AUTH --> OS & ES
    OS & ES --> DB
    ES --> NATS
    NATS --> S1 & S2 & S3 & S4
    
    style API fill:#4CAF50
    style NATS fill:#2196F3
    style DB fill:#FF9800

Data Flow Sequence Diagram

sequenceDiagram
    participant D as Drone/Robot
    participant N as NATS JetStream
    participant KV as KV Store<br/>(CONSTELLATION_GLOBAL_STATE)
    participant W as Workers<br/>(Entity/Telemetry/Event)
    participant A as API Service
    participant DB as libSQL DB
    participant UI as Web UI<br/>(SSE)

    Note over D,UI: Entity Registration Flow
    UI->>A: POST /api/v1/entities
    A->>DB: INSERT entity
    A->>N: Publish entity.created event
    A->>KV: Sync entity to KV[entity_id]
    A-->>UI: Return Entity
    N->>W: EntityWorker processes event
    W->>DB: Log entity creation
    W-->>UI: SSE update (if subscribed)

    Note over D,UI: Telemetry Publishing Flow
    D->>N: Publish to constellation.telemetry.{org_id}.{entity_id}
    N->>N: Store in CONSTELLATION_TELEMETRY stream
    N->>W: TelemetryWorker receives message
    W->>KV: Update entity state with latest telemetry
    KV-->>UI: KV watcher triggers SSE update
    UI->>UI: Datastar patches UI elements

    Note over D,UI: Real-time State Sync
    D->>N: Publish status/position update
    N->>W: EventWorker processes update
    W->>DB: Update entity record
    W->>KV: Sync to KV[entity_id]
    KV-->>UI: SSE PatchElements with new state

    Note over D,UI: Command Flow
    UI->>A: POST command
    A->>N: Publish to constellation.commands.{org_id}.{entity_id}
    N->>N: Store in CONSTELLATION_COMMANDS stream
    N->>D: CommandWorker delivers command
    D->>N: Publish command.ack
    N->>W: Process acknowledgment
    W->>KV: Update command status
    KV-->>UI: SSE notification

    Note over D,UI: Web Dashboard Live Updates
    UI->>A: GET /sse/stream (SSE connection)
    A->>N: Subscribe to constellation.>
    loop Real-time Updates
        N->>A: New message on any subject
        A->>UI: SSE PatchElements (Datastar)
        UI->>UI: Update DOM without reload
    end

Getting Started

Please see the Quick Start Guide below for detailed usage examples.

πŸ“‹ Prerequisites
  • Go 1.24 or higher
  • Task - Task runner (optional, recommended)
⚑ Quick Start

Clone the repository and start the server:

# Clone the repository
git clone https://github.com/Constellation-Overwatch/constellation-overwatch.git
cd constellation-overwatch

# Install dependencies
go mod download

# Run in development mode (recommended)
task dev

# OR run directly
go run ./cmd/microlith/main.go

The server will start:

  • API Server & Web UI: http://localhost:8080
  • Embedded NATS: nats://localhost:4222
πŸ› οΈ Installation (Task Runner)

Install Task for enhanced development workflow:

# macOS
brew install go-task/tap/go-task

# Linux
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin

# Windows (using Scoop)
scoop install task
🌐 Web Dashboard

Access the real-time web interface at http://localhost:8080

Features:

  • View organizations and entities in real-time
  • Monitor NATS streams and key-value stores
  • Create and manage fleet entities
  • Watch live telemetry data

Technology Stack:

  • Templ - Type-safe Go HTML templates
  • Datastar - Hypermedia framework for reactive UI
  • Server-Sent Events (SSE) - Real-time data streaming

Development Mode:

task dev  # Auto-rebuilds templ templates on changes
🐳 Docker Deployment

Build and run with Docker:

# Build image
task docker-build

# Run with Docker Compose
task docker-run

# Stop service
task docker-stop

Configuration

Create a .env file in the project root (copy from .env.example):

cp .env.example .env

Configuration options:

  • API_BEARER_TOKEN - Bearer token for API authentication (default: reindustrialize-dev-token)
  • PORT - HTTP server port (default: 8080)
  • DB_PATH - libSQL database path (default: ./db/constellation.db)
  • NATS_PORT - NATS server port (default: 4222)
  • NATS_DATA_DIR - NATS data directory (default: ./data/overwatch)
  • WEB_UI_PASSWORD - Password for Web UI access (leave empty to disable)

Example .env file:

API_BEARER_TOKEN=reindustrialize-dev-token
PORT=8080
DB_PATH=./db/constellation.db
NATS_PORT=4222
NATS_DATA_DIR=./data/overwatch
WEB_UI_PASSWORD=your-secure-password

Web UI Authentication

The Web UI supports optional password-based authentication. When WEB_UI_PASSWORD is set in your .env file, users must authenticate before accessing the dashboard.

To enable Web UI authentication:

# In your .env file
WEB_UI_PASSWORD=your-secure-password

When enabled:

  • Accessing any protected route redirects to /login
  • Sessions are stored in-memory with 24-hour expiration
  • Logout is available at /logout

To disable Web UI authentication:

Leave WEB_UI_PASSWORD empty or unset. The dashboard will be accessible without login.

API Authentication

All REST API endpoints (/api/v1/*) require Bearer token authentication:

curl -H "Authorization: Bearer reindustrialize-dev-token" \
     http://localhost:8080/api/v1/organizations

Quick Start Examples

πŸš€ API Quickstart with curl

Once the server is running, provision an organization and create entities:

Step 1: Set your API token

export TOKEN="reindustrialize-dev-token"  # or your custom token from .env

Step 2: Create an organization

curl -s -X POST http://localhost:8080/api/v1/organizations \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Fleet",
    "org_type": "civilian",
    "description": "Test drone fleet"
  }'

Allowed org_type values: military, civilian, commercial, ngo

Example Response:

{
  "success": true,
  "data": {
    "org_id": "ae9c65d0-b5f3-4cec-8ffa-68ff1173e050",
    "name": "My Fleet",
    "org_type": "civilian",
    "metadata": "{}",
    "created_at": "2025-10-22T11:34:29.195678-05:00",
    "updated_at": "2025-10-22T11:34:29.195678-05:00"
  }
}

Step 3: Register entities to the organization

Extract the org_id from the response above:

export ORG_ID='ae9c65d0-b5f3-4cec-8ffa-68ff1173e050'
curl -s -X POST "http://localhost:8080/api/v1/entities?org_id=$ORG_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Drone-001",
    "entity_type": "aircraft_multirotor",
    "description": "Primary vegetation inspection drone",
    "metadata": {
      "model": "DJI-M300",
      "serial": "ABC123456"
    }
  }'

Example Response:

{
  "success": true,
  "data": {
    "entity_id": "5458eec0-b0e3-4290-8db5-17936dbbfc64",
    "org_id": "ae9c65d0-b5f3-4cec-8ffa-68ff1173e050",
    "entity_type": "aircraft_multirotor",
    "status": "unknown",
    "priority": "normal",
    "is_live": false
  }
}

Step 4: Query and manage entities

# Extract entity_id from response
export ENTITY_ID='5458eec0-b0e3-4290-8db5-17936dbbfc64'

# List all entities in organization
curl -s "http://localhost:8080/api/v1/entities?org_id=$ORG_ID" \
  -H "Authorization: Bearer $TOKEN" | jq

# Get specific entity details
curl -s "http://localhost:8080/api/v1/entities?org_id=$ORG_ID&entity_id=$ENTITY_ID" \
  -H "Authorization: Bearer $TOKEN" | jq

# Update entity status
curl -s -X PUT "http://localhost:8080/api/v1/entities?org_id=$ORG_ID&entity_id=$ENTITY_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "active",
    "metadata": {
      "location": "lat:37.7749,lon:-122.4194",
      "battery": "85%"
    }
  }' | jq

API Endpoints

Organizations

  • POST /api/v1/organizations - Create organization
  • GET /api/v1/organizations - List organizations
  • GET /api/v1/organizations?org_id=xxx - Get organization

Entities

  • POST /api/v1/entities?org_id=xxx - Create entity
  • GET /api/v1/entities?org_id=xxx - List entities
  • GET /api/v1/entities?org_id=xxx&entity_id=yyy - Get entity
  • PUT /api/v1/entities?org_id=xxx&entity_id=yyy - Update entity
  • DELETE /api/v1/entities?org_id=xxx&entity_id=yyy - Delete entity

Health Check

  • GET /health - Service health status

NATS Subjects

Entity Events

  • constellation.entities.{org_id}.created
  • constellation.entities.{org_id}.updated
  • constellation.entities.{org_id}.deleted
  • constellation.entities.{org_id}.status

Telemetry

  • constellation.telemetry.{org_id}.{entity_id}

Commands

  • constellation.commands.{org_id}.{entity_id}
  • constellation.commands.{org_id}.broadcast

Project Structure

constellation-overwatch/
β”œβ”€β”€ cmd/
β”‚   └── microlith/              # Main application entry point
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ handlers/               # API-specific handlers (health, orgs, entities)
β”‚   β”œβ”€β”€ middleware/             # HTTP middleware (auth, CORS, logging)
β”‚   β”œβ”€β”€ services/               # Business logic services (entities, organizations)
β”‚   └── router.go               # API router definition
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ service.go              # Database service with auto-initialization
β”‚   β”œβ”€β”€ schema.sql              # libSQL database schema
β”‚   └── constellation.db        # libSQL database (auto-created)
β”œβ”€β”€ pkg/
β”‚   β”œβ”€β”€ ontology/               # Core domain models and entity types
β”‚   β”œβ”€β”€ shared/                 # Shared types, constants, and NATS subjects
β”‚   └── services/
β”‚       β”œβ”€β”€ embedded-nats/      # Embedded NATS JetStream server
β”‚       β”œβ”€β”€ logger/             # Centralized logging service
β”‚       β”œβ”€β”€ workers/            # Background event processors (entity, command, telemetry, event)
β”‚       └── web/                # Web UI and SSE services
β”‚           β”œβ”€β”€ handlers/       # Web-specific handlers (pages, datastar, overwatch)
β”‚           β”œβ”€β”€ datastar/       # Datastar framework integration
β”‚           β”œβ”€β”€ templates/      # Templ templates (*.templ files)
β”‚           β”œβ”€β”€ static/         # Static assets (CSS, JS, images)
β”‚           β”œβ”€β”€ router.go       # Web router and API mounting
β”‚           β”œβ”€β”€ server.go       # HTTP server lifecycle
β”‚           └── sse_handler.go  # Server-Sent Events handler
β”œβ”€β”€ prd/
β”‚   └── design/                 # Product requirements and design docs
β”‚       β”œβ”€β”€ API.md              # API specification
β”‚       β”œβ”€β”€ CLIENT_DESIGN.md    # Client design documentation
β”‚       β”œβ”€β”€ CONSTELLATION_TAK_ONTOLOGY.md  # Entity ontology definitions
β”‚       └── VENDOR_CAMERA.md    # Camera vendor specifications
β”œβ”€β”€ tests/
β”‚   └── publish-simulations/    # NATS publish simulation tests
β”œβ”€β”€ bin/                        # Compiled binaries (auto-generated)
β”œβ”€β”€ data/                       # NATS JetStream data directory (auto-generated)
β”œβ”€β”€ logs/                       # Application logs (auto-generated)
└── nats.conf                   # NATS server configuration

Development

πŸ”¨ Building and Running
# Development mode (auto-rebuild templ templates)
task dev

# Generate templ templates
task templ-generate

# Watch templ files for changes
task templ-watch

# Build the binary
task build
# OR manually: go build -o bin/overwatch ./cmd/microlith

# Run the binary
task run
# OR manually: ./bin/overwatch

# Run tests
go test ./...

# Format code
go fmt ./...

# Run go vet
go vet ./...

# List all available tasks
task --list

Security

EXPERIMENTAL πŸ”’ NATS Authentication

Enable NATS authentication with environment variables:

NATS_AUTH_ENABLED=true
NATS_USER=your_username
NATS_PASSWORD=your_password

When enabled, all NATS clients must authenticate using these credentials.

πŸ” TLS Encryption

Enable TLS 1.3 for NATS connections:

Step 1: Generate certificates (development)

task generate-certs

Step 2: Configure environment variables

NATS_TLS_ENABLED=true
NATS_TLS_CERT=/path/to/server.crt
NATS_TLS_KEY=/path/to/server.key

Contributing

We welcome contributions to Constellation Overwatch! Please check out our contribution guidelines to get started.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Go best practices and conventions
  • Add tests for new features
  • Update documentation as needed
  • Run go fmt ./... and go vet ./... before committing
  • Ensure all tests pass with go test ./...

License

This project is licensed under the MIT License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Constellation Overwatch by you shall be licensed as MIT, without any additional terms or conditions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL