# Systems Architecture & Engineering Disciplines — LightCavalry

## 1. Edge-Native Distributed Systems
We architect services directly onto Cloudflare's global edge network of 330+ locations, removing origin bottlenecks and central region single-points-of-failure.
- Sub-10ms global client edge termination.
- Zero-cold-start compute via V8 isolates.
- Global single-writer coordination with Durable Objects.

## 2. Distributed Consensus (Raft)
Our Raft implementation provides deterministic state machine replication across geographically partitioned nodes.
- Randomized election timers (150–300ms) prevent split-vote deadlocks.
- Two-phase commit log entries require quorum acknowledgment before state application.
- Snapshotting and log truncation bound storage footprints.

## 3. Conflict-Free Replicated Data Types (CRDTs)
For systems requiring multi-region writes or offline-first operation without distributed locking:
- State-based PN-Counters and OR-Sets.
- Semilattice join guarantees commutative, associative, and idempotent merging.

## 4. Storage Engines (LSM-Tree)
High-throughput write paths engineered for edge SQLite / Durable Objects storage:
- Sequential disk I/O with in-memory skiplist Memtables.
- Write-Ahead Logging (WAL) ensures crash durability.
- Multi-tier SSTable compaction with Bloom filters minimizes read amplification.

## 5. Tail Latency & Resilience (HdrHistogram)
- Bounding the p99.99th percentile under load.
- Non-blocking backpressure queues with explicit shed policies.
- Zero-mock load simulation with real packet drops and artificial latency injections.
