Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AngelP17/ForgeMesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

ForgeMesh

The Zero-Cost, Distributed Industrial Historian

Rust License: MIT Status

ForgeMesh is a production-grade, distributed time-series database designed for industrial manufacturing environments. It replaces expensive cloud IoT platforms (Azure IoT, AWS Greengrass) with a zero-cost, masterless, peer-to-peer architecture that runs on Raspberry Pi hardware.

Real-World Context

Built for: Manufacturing facilities with unreliable WAN connectivity (multi-site operations across).

The Problem: When VPN tunnels drop between plants, traditional cloud historians lose data. SCADA systems go blind. Production reports become incomplete.

The Solution: ForgeMesh uses "Local-First" architecture with CRDT (Conflict-free Replicated Data Types) consistency. Data is immutable, cryptographically verifiable (Merkle-DAG), and syncs automatically when connectivity returns. No central server. No cloud bill. No data loss.

Architecture

flowchart TB
 subgraph ForgeMeshNode["πŸ”§ FORGEMESH NODE"]
 direction TB
 subgraph AppLayer["Application Layer"]
 direction LR
 WebUI["🌐 Axum Web UI<br/>Real-time Dashboard"]
 MerkleDAG["πŸ”— Merkle DAG<br/>Storage (SHA3-256)"]
 IrohP2P["πŸ“‘ Iroh P2P<br/>QUIC/Noise + GossipSub"]
 end
 
 subgraph StorageLayer["Storage Layer"]
 Sled["πŸ’Ύ Sled LSM-Tree (Embedded)<br/>Zero-config, ACID-compliant storage"]
 end
 
 WebUI --> Sled
 MerkleDAG --> Sled
 IrohP2P --> Sled
 end
 
 subgraph SisterNodes["🏭 SISTER NODES"]
 Ontario["Ontario Plant"]
 Georgia["Georgia Plant"]
 Texas["Texas Plant"]
 end
 
 ForgeMeshNode <-->|"P2P Sync<br/>Automatic Partition Healing"| SisterNodes
 
 style ForgeMeshNode fill:#1a1a2e,stroke:#16213e,color:#eee
 style AppLayer fill:#0f3460,stroke:#16213e,color:#fff
 style StorageLayer fill:#0f3460,stroke:#16213e,color:#fff
 style SisterNodes fill:#1a1a2e,stroke:#16213e,color:#eee
Loading

Design Principles

  1. Zero-Cost Infrastructure: Runs on existing hardware (Pi 4, old laptops). No AWS/Azure bills.
  2. Cryptographic Integrity: Every data point content-addressed with SHA3-256. Tamper-evident audit trails for compliance.
  3. Offline-First: Write operations succeed locally even with 100% network partition. Sync happens asynchronously.
  4. Staff+ Engineering: Demonstrates distributed systems competency (CRDTs, Merkle trees, epidemic gossip) without microservice complexity.

Quick Start

Installation

# Clone and build (Rust 1.75+ required)
cd forgemesh
cargo build --release
# Or use Just (modern make)
just build

Phase 1: Immutable Storage Engine

# Write sensor data
./target/release/forgemesh-cli write -s ontario-line1-temp -v 24.5
./target/release/forgemesh-cli write -s ontario-line1-temp -v 25.0
# Verify cryptographic chain integrity
./target/release/forgemesh-cli verify -s ontario-line1-temp
# Verified 2 nodes, root 0x9664aff88a978605...
# Run 100k write benchmark
just bench # Validates Phase 1 performance

Phase 2: Industrial Simulation & Analytics

# Generate 30 days of simulated temperature data (1 point/minute)
./target/release/forgemesh-cli generate -s furnace-01 -p 43200 --sensor-type temperature
# Simulate complete production line with multiple sensors
./target/release/forgemesh-cli simulate-line -l "ontario-line1"

Phase 3: Air-Gap Sync (Sneakernet Mode)

# Export to CAR file (Content Addressable Archive)
./target/release/forgemesh-cli export -o backup.car
# CAR format is IPLD-compatible (IPFS/Filecoin standard)
# Transport via USB/email to offline node
./target/release/forgemesh-cli import -f backup.car
# Idempotent: importing twice changes nothing

Phase 4: Web Dashboard & Distributed Mesh

# Start daemon with web UI
just daemon # Starts on http://localhost:8080
# Or manually:
./target/release/forgemesh-cli daemon --port 8080 --node-id ontario-pi-01

Access the dashboard at http://localhost:8080 to see:

  • Real-time time-series charts (Chart.js)
  • Merkle DAG visualization (blockchain-style audit trail)
  • Network topology (mesh node status)
  • Live WebSocket updates when data is written

API Endpoints

# Core Data Endpoints
GET /api/sensors # List all sensors
GET /api/sensor/:id/history # Get sensor history
POST /api/sensor/:id/write # Write new value
GET /api/status # Node status
# Analytics & Simulation
GET /api/sensor/:id/analytics # Real-time statistics (min/max/mean/variance)
POST /api/sensor/:id/simulate # Generate simulated data points
GET /api/line/:id/oee # Manufacturing OEE metrics
GET /api/mesh/topology # Mesh network topology
POST /api/export/:id # Export sensor to CAR format

Performance Benchmarks

Metric Value Hardware
Write Throughput 15,000+ ops/sec MacBook Pro M1
Write Throughput 3,200 ops/sec Raspberry Pi 4
Binary Size <15 MB (stripped) ARM64
RAM Usage <50 MB Idle
Latency (p99) <2 ms Local SSD

Technical Validation

"Demo" Script

Run this to prove all four architectural phases work:

# Terminal 1: Start daemon
just daemon &
# Terminal 2: Demonstrate capabilities
just sample # Phase 1: Write & verify chain
just export-test # Phase 2: CAR file export/import
curl http://localhost:8080/api/status # Phase 3: HTTP API
# Phase 4: Simulation & Analytics
./target/release/forgemesh-cli simulate-line -l "demo-line"
curl http://localhost:8080/api/sensor/demo-line-temp/analytics

Test Results

βœ… 10 tests passed in forgemesh-core
 - simulation::tests::test_temperature_range
 - simulation::tests::test_vibration_drift
 - simulation::tests::test_batch_generation
 - analytics::tests::test_stats_calculation
 - analytics::tests::test_anomaly_detection
 - analytics::tests::test_oee_calculation
 - types::tests::test_hash_determinism
 - types::tests::test_parent_chain
 - store::tests::test_put_get
 - merkle::tests::test_verify_chain

Project Structure

forgemesh/
+-- crates/
| +-- forgemesh-core/ # Phase 1: Merkle-DAG storage engine
| | +-- src/store.rs # Sled LSM abstraction
| | +-- src/merkle.rs # Hash chain verification
| | +-- src/types.rs # DataNode (immutable, hashed)
| | +-- src/simulation.rs # Industrial sensor simulation (temp/pressure/vibration)
| | +-- src/analytics.rs # Edge analytics (stats, anomaly detection, OEE)
| |
| +-- forgemesh-sync/ # Phase 2: CAR export/import, delta sync
| | +-- src/car.rs # IPLD CAR format implementation
| | +-- src/delta.rs # Merkle tree diff calculation
| |
| +-- forgemesh-p2p/ # Phase 3: Iroh networking, CRDTs
| | +-- src/crdt.rs # Vector clocks, LWW registers
| | +-- src/gossip.rs # Epidemic broadcast protocol
| |
| +-- forgemesh-web/ # Axum web server + dashboard
| | +-- src/lib.rs # Core routes + WebSocket
| | +-- src/api.rs # Analytics/simulation API endpoints
| |
| +-- forgemesh-cli/ # Binary target
| +-- src/main.rs # CLI + daemon entry points
| +-- src/bulk_ops.rs # Bulk data generation with progress bars
|
+-- Justfile # Build automation
+-- Cargo.toml # Workspace manifest
+-- EXTENSIONS.md # Feature roadmap & implementation status

Configuration

No YAML/JSON config files. All configuration via CLI flags:

forgemesh-cli daemon \
 --db-path /data/forgemesh \
 --node-id ontario-line1 \
 --port 8080

Environment variables for production:

FORGEMESH_LOG_LEVEL=info
FORGEMESH_P2P_BOOTSTRAP=/dns4/bootstrap.forgemesh.local/tcp/8777

Manufacturing Integration

Protocol Support

  • Modbus TCP: Read PLCs directly (via modbus crate integration)
  • MQTT: Bridge existing IoT sensors
  • OPC UA: Industrial automation standard (planned)

SCADA Integration

REST API endpoints compatible with:

  • Ignition SCADA (HTTP bindings)
  • Grafana (JSON datasource plugin)
  • Node-RED (HTTP request nodes)

Example curl for SCADA:

curl http://localhost:8080/api/sensor/line1-temp/history?limit=1
# Returns latest value for HMI display

Why This Matters

Traditional Industrial IoT Stack:

  • Azure IoT Hub: ~1,000ドル/month per site
  • VPN infrastructure: 500ドル/month
  • Data loss during outages: Incalculable
  • Total: 18,000ドル/year for 3 sites

ForgeMesh:

  • Hardware: 3x Raspberry Pi 4 (150ドル total, one-time)
  • Networking: P2P over existing LAN/internet (free)
  • Data durability: 100% (local-first + sync)
  • Total: 0ドル/year

Plus: You own your data. No cloud lock-in. Works during internet outages. Cryptographic audit trails for FDA/ISO compliance.

Roadmap

  • Phase 1: Immutable storage with Merkle verification
  • Phase 2: CAR file export/import (air-gap sync)
  • Phase 3: Web dashboard with real-time charts
  • Phase 4: Industrial simulation & edge analytics (10 tests passing)
  • Phase 4.5: Full Iroh P2P mesh networking
  • Phase 5: Modbus/OPC UA protocol adapters
  • Phase 6: Federated querying across mesh nodes

See EXTENSIONS.md for detailed feature roadmap.

License

MIT - See LICENSE file.

Author

Angel L. Pinzon Systems Engineer | Industrial IoT | Rust LinkedIn | GitHub


Built for manufacturing engineers who need reliability, not cloud bills.

About

Production-grade distributed industrial historian

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /