Back to Docs
πŸ–₯️

Edge Computing

Run ALEC on edge gateways to decode, filter, and re-encode sensor data locally. Reduce cloud bandwidth by 95%+ with intelligent edge processing.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         CLOUD                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              ALEC Decoder (aggregated)               β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–²
                              β”‚ Compressed (P1-P3 only)
                              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      EDGE GATEWAY                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚
β”‚  β”‚ Decoder  β”‚  β”‚  Filter  β”‚  β”‚ Encoder  β”‚                  β”‚
β”‚  β”‚ (local)  β”‚β†’ β”‚ Aggregateβ”‚β†’ β”‚ (cloud)  β”‚                  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–²              β–²              β–²
         β”‚              β”‚              β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
    β”‚ Sensor  β”‚    β”‚ Sensor  β”‚    β”‚ Sensor  β”‚
    β”‚  ALEC   β”‚    β”‚  ALEC   β”‚    β”‚  ALEC   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Local Decode

Decode sensor messages locally for real-time monitoring and alerting.

Filter & Aggregate

Remove noise, aggregate readings, apply business logic at the edge.

Re-encode for Cloud

Send only significant data to cloud with fresh compression context.

Edge Gateway Code

use alec::{Encoder, Decoder, Context, Priority, Config};
use std::collections::HashMap;

struct EdgeGateway {
    sensors: HashMap<String, Context>,
    cloud_encoder: Encoder,
}

impl EdgeGateway {
    fn new() -> Self {
        Self {
            sensors: HashMap::new(),
            cloud_encoder: Encoder::new(&mut Context::new()),
        }
    }
    
    fn process_sensor(&mut self, sensor_id: &str, raw_bytes: &[u8]) {
        // Get or create context for this sensor
        let ctx = self.sensors
            .entry(sensor_id.to_string())
            .or_insert_with(Context::new);
        
        let decoder = Decoder::new(ctx);
        let value = decoder.decode(raw_bytes).unwrap();
        
        // Local processing / filtering
        if self.should_forward(sensor_id, value) {
            // Re-encode for cloud with aggregated context
            let msg = self.cloud_encoder.encode(value, Priority::Auto);
            self.send_to_cloud(sensor_id, msg);
        }
    }
    
    fn should_forward(&self, sensor_id: &str, value: f64) -> bool {
        // Edge logic: filter noise, aggregate, detect anomalies
        // Only forward significant changes
        true
    }
}

Deployment

Docker (ARM64 / Raspberry Pi)

FROM rust:1.75-slim as builder
WORKDIR /app
COPY . .
RUN cargo build --release --target aarch64-unknown-linux-gnu

FROM debian:bookworm-slim
COPY --from=builder /app/target/aarch64-unknown-linux-gnu/release/edge-gateway /usr/local/bin/
CMD ["edge-gateway"]

Supported Platforms

ARM64
  • β€’ Raspberry Pi 4/5
  • β€’ NVIDIA Jetson
  • β€’ AWS Graviton
x86_64
  • β€’ Intel NUC
  • β€’ Industrial PCs
  • β€’ Cloud VMs

Edge Processing Strategies

1. Priority Filtering

Forward only P1-P3 messages to cloud. Store P4-P5 locally for batch upload or on-demand retrieval.

2. Temporal Aggregation

Collect 1-minute readings, send 15-minute averages to cloud. Keep full resolution locally.

3. Anomaly Detection

Run ML models at edge. Forward predictions and anomalies, not raw sensor data.