# MoonChunk Technical Design

## Goal

MoonChunk provides reusable MoonBit primitives for content-defined chunking,
manifest generation, chunk reuse planning, and integrity verification. The
project targets backup tools, cache systems, file synchronization pipelines,
artifact replication, and object storage gateways that need stable chunk
boundaries after insertions or small edits.

## Scope

- Content-defined chunking over byte streams
- Streaming and batch chunking APIs
- Deterministic digest and Merkle root generation
- Canonical manifest encoding and decoding
- Chunk reuse and upload planning between versions
- In-memory chunk storage and restore helpers
- Integrity verification and proof checking
- Reference CLI demonstrating the end-to-end flow

## Non-goals

- No transport protocol
- No cloud storage backend
- No encryption or authentication layer
- No distributed metadata service
- No OS-specific deployment tooling

## Module structure

- `types.mbt`: shared public data model
- `digest.mbt`: digest and Merkle primitives
- `chunker.mbt`: chunk boundary detection and streaming chunker
- `manifest.mbt`: manifest construction and canonical encoding
- `sync.mbt`: diff plan, restore, and in-memory chunk store
- `verify.mbt`: integrity reports and proof verification
- `analytics.mbt`, `inventory.mbt`, `benchmark.mbt`: analysis helpers
- `cmd/main`: runnable end-to-end example

## Maintenance value

The project is intentionally packaged as a general-purpose MoonBit module with
separated responsibilities, test coverage, CI automation, and publishable
package metadata so it can continue evolving beyond the hackathon as a reusable
foundation for storage and synchronization systems.
