A detailed blueprint for building CloudSync in independent stages, ensuring that every component is testable even if others are incomplete.
- In-memory metadata store
- File + chunk metadata structures
- Append-only operation log
- Checkpoint writer
- Pure Go unit tests using
go test - Create file, chunk, verify metadata integrity
- Test log replay and checkpoint reload
- None
/RegisterAgentgRPC- JWT issuing & validation
- PostgreSQL writes (agent identity)
- gRPC test client in Go
- Use
sqlmockor a local Docker PostgreSQL for DB tests
- Metadata module
- PostgreSQL
- Store agent health
- Track last-seen timestamp
- Offline detection logic
- Simulate heartbeat RPC requests
- Validate online/offline state transitions
- Agent registration
- Metadata module
registercommandstartcommand- Heartbeat loop
- Create a FakeMaster gRPC server returning static responses
- Run CLI against FakeMaster
- gRPC contracts
- Split file into 64MB chunks
- Compute SHA-256 checksums
- Pure Go tests
- Validate chunk size, checksum correctness, boundary cases
- None
InitiateUploadUploadChunkFinalizeUpload- Chunk placement logic
- Create FakeAgent that pretends to store chunks
- Master interacts with FakeAgent
- Full upload pipeline works end-to-end
- Chunking library
- Metadata module
- Heartbeats
- Detect under-replicated chunks
- Re-replication scheduler
- Checksum verification & corruption detection
- FakeAgent that says chunk is missing
- Test replication queue logic
- Test offline agent triggering re-replication
- Heartbeats
- Upload workflow
- Docker Compose for: master + PostgreSQL + N agents
- Upload → distribute chunks → kill agent → re-replicate
- Full system simulation
- Load test with 10+, 50+, 100 agents
- Entire system built
- ✅ Metadata Store
- ✅ gRPC API Basics
- ✅ Agent Registration + Auth
- ✅ Heartbeats
- 🔜 Chunking
- 🔜 Upload Workflow
- 🔜 Replication Logic
- 🔜 Docker Simulation
| Component | Test Type | Requires Real Agents? | Requires DB? |
|---|---|---|---|
| Metadata Store | Unit | ❌ | ❌ |
| Registration | gRPC Test Client | ❌ | ✔️ |
| Heartbeats | Simulated RPC | ❌ | ❌ |
| Agent CLI | Fake Master | ❌ | ❌ |
| Chunking | Unit | ❌ | ❌ |
| Upload Workflow | Fake Agents | ❌ | ❌ |
| Replication | Fake Agents | ❌ | ❌ |
| End-to-end | Docker | ✔️ | ✔️ |
This plan ensures:
- Every part can be tested independently
- No waiting for entire system to be built
- Each stage gives confidence before integration
- Development becomes predictable, modular, and scalable
Let me know if you want a FOLDER_STRUCTURE.md or full skeleton code for each stage!