A simple, ephemeral key-value store implemented in Go designed with REST in mind
- Thread-safe in-memory storage with concurrent read/write support
- HTTP REST API for easy client integration
- API Key Authentication with secure token generation and validation
- Configurable server settings via command-line flags
- Gracefully handles interruptions and poweroff signals
- Go (any stable version should work)
-
Clone the repository:
git clone https://github.com/q4ow/qkrn cd qkrn
-
Build the application:
make build # or go build -o bin/qkrn ./cmd/qkrn
-
Run the server:
./bin/qkrn # or make run
The server starts on localhost:8080
by default. You can configure it using command-line flags:
./bin/qkrn --help
Usage of ./bin/qkrn:
...
qkrn supports optional API key authentication:
# Start with authentication enabled and auto-generate API key
./bin/qkrn --auth-enabled
# Start with specific API key
./bin/qkrn --auth-enabled --api-key "your-secure-api-key"
# Start without authentication (default)
./bin/qkrn
Store a key-value pair:
# Without authentication
curl -X PUT http://localhost:8080/kv/hello \
-H "Content-Type: application/json" \
-d '{"value":"world"}'
# With authentication
curl -X PUT http://localhost:8080/kv/hello \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value":"world"}'
Retrieve a value:
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://localhost:8080/kv/hello
List all keys:
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://localhost:8080/keys
Delete a key:
curl -X DELETE \
-H "Authorization: Bearer YOUR_API_KEY" \
http://localhost:8080/kv/hello
qkrn/
├── cmd/qkrn/ # Main application entry point
├── internal/ # Private application code
│ ├── api/ # HTTP API server
│ ├── auth/ # Authentication middleware and utilities
│ ├── config/ # Configuration management
│ └── store/ # Key-value store implementation
├── pkg/types/ # Public types and interfaces
├── docs/ # Documentation
├── scripts/ # Utility scripts
└── bin/ # Build artifacts
Unit tests:
make test
API integration tests:
# Terminal 1: Start the server
make run
# Terminal 2: Run API tests
make test-api
The project follows Go best practices:
- Code is formatted with
go fmt
- Code is vetted with
go vet
- Comprehensive unit tests
- Thread-safe concurrent operations
- Proper error handling
CI can only do so much, please be nice in your pull requests :)
This is just the beginning, I have much more planned for the future of qkrn:
- Multi-node replication - Data replication across multiple nodes
- Node discovery - Automatic peer discovery and cluster formation
- Consensus algorithm - Implement Raft for consistency
- Persistent storage - Add disk-based storage options
- Advanced features - Authentication, encryption, monitoring
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and other make targets
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details. yet another key/value store