| Crates.io | alec |
| lib.rs | alec |
| version | 1.1.0 |
| created_at | 2026-01-16 11:18:03.350336+00 |
| updated_at | 2026-01-17 12:01:40.010477+00 |
| description | Adaptive Lazy Evolving Compression - Smart codec for IoT sensor data with 90% compression ratio |
| homepage | https://alec-codec.com |
| repository | https://github.com/zeekmartin/alec-codec |
| max_upload_size | |
| id | 2048450 |
| size | 451,079 |
A smart compression codec for bandwidth-constrained environments
Features • Use Cases • Quick Start • Documentation • Contributing
In many environments, every bit counts:
ALEC addresses these challenges with an innovative approach: transmit only what has value.
ALEC doesn't transmit all data — it first sends the decision, then details only if needed.
Without ALEC: [Complete data] ──────────────────────▶ 1000 bytes
With ALEC: [Alert: anomaly detected] ────────────▶ 12 bytes
[Details on demand] ──────────────────▶ 500 bytes (if requested)
Encoder and decoder build a shared dictionary that improves over time.
Week 1: "temperature=22.3°C" ──────────────────────▶ 20 bytes
Week 4: [code_7][+0.3] ───────────────────────────▶ 3 bytes
Computational effort is placed where resources exist.
| Mode | Encoder | Decoder | Use Case |
|---|---|---|---|
| Standard | Light | Heavy | IoT sensors, drones |
| Reversed | Heavy | Light | Broadcast distribution |
Each data point receives a priority that determines its handling:
| Priority | Behavior | Example |
|---|---|---|
| P1 CRITICAL | Immediate send + acknowledgment | Fire alert |
| P2 IMPORTANT | Immediate send | Anomaly detected |
| P3 NORMAL | Standard send | Periodic measurement |
| P4 DEFERRED | On demand only | Detailed history |
| P5 DISPOSABLE | Never sent | Debug logs |
Field sensors monitor moisture, temperature, and nutrients. With ALEC, they run 10 years on battery by transmitting only alerts and anomalies.
A portable ultrasound in a remote area first sends "suspected cardiac anomaly" in 50 bytes. The remote doctor decides if they need the full image.
500 trucks report their position. After a few weeks, the system knows the usual routes and only transmits deviations.
A satellite photographs Earth. It only sends significant changes compared to previous images.
# Clone the repo
git clone https://github.com/zeekmartin/alec-codec.git
cd alec-codec
# Build
cargo build --release
# Run tests
cargo test
use alec::{Encoder, Decoder, Context, RawData};
fn main() {
// Create encoder and decoder with shared context
let mut ctx_emitter = Context::new();
let mut ctx_receiver = Context::new();
let encoder = Encoder::new();
let decoder = Decoder::new();
// Simulate measurements
for i in 0..100 {
let data = RawData::new(20.0 + (i as f64 * 0.1), i);
// Encode
let message = encoder.encode(&data, &ctx_emitter);
ctx_emitter.observe(&data);
// ... transmit message ...
// Decode
let decoded = decoder.decode(&message, &ctx_receiver).unwrap();
ctx_receiver.observe(&decoded);
println!("Original: {:.1}, Size: {} bytes",
data.value, message.len());
}
}
➡️ Complete getting started guide
| Document | Description |
|---|---|
| Architecture | Technical overview |
| Applications | Detailed use cases |
| Getting Started | Getting started guide |
| Protocol Reference | Protocol specification |
| Security | Security considerations |
| API Reference | Interfaces and APIs |
| FAQ | Frequently asked questions |
| Glossary | Glossary of terms |
Results on reference dataset (temperature sensor, 24h, 1 measurement/min):
| Metric | Without context | After warm-up | Target |
|---|---|---|---|
| Compression ratio | 0.65 | 0.08 | < 0.10 ✅ |
| P1 Latency | 45ms | 42ms | < 100ms ✅ |
| Encoder RAM | 12KB | 28KB | < 64KB ✅ |
Contributions are welcome! See:
# Typical workflow
1. Fork the repo
2. Create a branch: git checkout -b feature/my-feature
3. Follow the appropriate template in prompts/
4. Submit a PR
ALEC is dual-licensed:
Free for open source projects, research, and personal use. You must open-source your code if you distribute ALEC or use it in a network service.
[dependencies]
alec = "1.0"
For proprietary use without open-source obligations. Starting at $500/year for startups.
See LICENSE for details.
ALEC draws inspiration from:
Made with ❤️ for a world where every bit counts