How hasnainrabbani/moniepoint-kv-springboot works
Project type and purpose
• This is a stand-alone, HTTP-based key–value store service implemented in Java Spring Boot.
• It exposes CRUD endpoints, persists data on disk in a Bitcask-style append-only log plus in-memory index, and runs embedded in Tomcat (packaged as JAR or Docker image).
Main components
• Client / External Tools
– REST client (curl, Postman), or Swagger UI
• API Layer
– Embedded Tomcat (Spring Web)
– KvController (handles HTTP GET/PUT/DELETE/POST)
• Service Layer
– KvService interface + KvServiceImpl (business logic: validation, batch operations)
• Store Layer (Bitcask implementation)
– BitcaskStore class (append log files + in-memory index)
– SegmentFile (manages individual data files on disk)
– Utils & CRC check (data integrity)
• Background Compaction
– Scheduled or trigger-based compaction process within BitcaskStore
• Configuration
– KvConfig / KvProperties (application.yml, env vars, CLI args)
• Persistence
– Local file system directory (kv.dataDir) containing segment files
• Deployment
– Docker container or direct JAR on JVM
Relationships and data flows
1. Client → HTTP request → Embedded Tomcat
2. Tomcat → DispatcherServlet → KvController
3. KvController → calls KvServiceImpl
4. KvServiceImpl → invokes BitcaskStore methods (put, get, delete, range)
5. BitcaskStore
• Appends new records to segment files on disk
• Updates in-memory index (key → file offset)
• Reads data by looking up index, then fetching from segment file
6. Compaction thread monitors thresholds → rewrites active segment files → updates index
7. Service returns to Controller → Controller returns HTTP response → Client
8. Configuration flows at startup: application.yml/env vars/CLI → KvConfig
Architectural patterns & design principles
• Layered architecture (Controller → Service → Store)
• Dependency Injection (Spring) for config, services
• Single responsibility: separate controller, business logic, storage util
• Append-only log + in-memory index (Bitcask design)
• Background compaction / eventual consistency of on-disk files