An open API service indexing awesome lists of open source software.

https://github.com/danielgerlag/blackis


https://github.com/danielgerlag/blackis

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

# Blackis

A high-performance Redis-compatible in-memory data structure server implemented in Rust, featuring a modern web interface for data management.

## Features

### Redis Protocol Compatibility
- **String Operations**: GET, SET, DEL, EXISTS with TTL support
- **List Operations**: LPUSH, RPUSH, LPOP, RPOP, LLEN, LINDEX, LRANGE, and more
- **Hash Operations**: HSET, HGET, HDEL, HLEN, HGETALL, HMGET, and more
- **Set Operations**: SADD, SREM, SMEMBERS, SCARD, SISMEMBER, SPOP, SUNION, SINTER, SDIFF, SSCAN
- **Sorted Set Operations**: ZADD, ZREM, ZRANGE, ZREVRANGE, ZCARD, ZSCORE, ZRANK
- **Pub/Sub**: PUBLISH, SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE
- **Database Operations**: SELECT (0-15), SCAN, KEYS, TYPE, PING, INFO
- **Utility Commands**: FLUSHALL, FLUSHDB, EXPIRE, PERSIST, TTL

### Modern Web Interface
- **Redis Commander-like UI** built with React and Material-UI
- **Key Browser** with search, filtering, and type detection
- **Specialized Editors** for different data types (strings, lists, hashes, sets, sorted sets)
- **Command Interface** with execution history
- **Real-time Updates** when data is modified
- **Multi-database Support** (Redis databases 0-15)

### Architecture
- **High Performance**: Built in Rust with async/await and Tokio
- **Persistent Storage**: RocksDB backend for data durability
- **Dual Interface**: Both Redis protocol (port 6379) and HTTP API (port 8080)
- **Memory Efficient**: Optimized data structures and storage layout
- **Concurrent**: Thread-safe operations with proper locking

## Quick Start

### Prerequisites
- Rust 1.70+ with Cargo
- Node.js 18+ and npm (for web interface development)

### Installation

```bash
# Clone the repository
git clone https://github.com/yourusername/blackis.git
cd blackis

# Build and run (production mode)
cargo run

# The server will start:
# - Redis protocol server on 127.0.0.1:6379
# - HTTP API and web interface on 127.0.0.1:8080
```

### Usage

#### Using Redis CLI
```bash
# Connect with any Redis client
redis-cli -h 127.0.0.1 -p 6379

# Basic operations
127.0.0.1:6379> SET mykey "Hello World"
OK
127.0.0.1:6379> GET mykey
"Hello World"

# List operations
127.0.0.1:6379> LPUSH mylist "item1" "item2"
(integer) 2
127.0.0.1:6379> LRANGE mylist 0 -1
1) "item2"
2) "item1"

# Set operations
127.0.0.1:6379> SADD myset "member1" "member2" "member3"
(integer) 3
127.0.0.1:6379> SMEMBERS myset
1) "member1"
2) "member2"
3) "member3"
```

#### Using Web Interface
1. Open your browser to `http://localhost:8080`
2. Browse keys by type and database
3. Create, edit, and delete data using the intuitive interface
4. Execute raw Redis commands in the command interface
5. View server statistics and configuration

## Development

### Building from Source
```bash
# Build the Rust backend
cargo build --release

# Build the React frontend
cd web
npm install
npm run build
cd ..

# Run with built frontend
cargo run
```

### Development Mode
For active development with hot reload:

```bash
# Terminal 1: Start the Rust server (API only)
cargo run

# Terminal 2: Start the React dev server
cd web
npm run dev
# Access at http://localhost:3000 (proxies API calls to :8080)
```

### Architecture Overview

```
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Redis Client │───▶│ Redis Protocol │───▶│ │
│ (port 6379) │ │ Server │ │ │
└─────────────────┘ └──────────────────┘ │ │
│ Storage │
┌─────────────────┐ ┌──────────────────┐ │ Engine │
│ Web Browser │───▶│ HTTP Server │───▶│ (RocksDB) │
│ (port 8080) │ │ + React UI │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
```

### Project Structure
```
blackis/
├── src/
│ ├── commands/ # Redis command implementations
│ ├── network/ # Redis protocol and HTTP servers
│ ├── protocol/ # RESP (Redis Serialization Protocol)
│ ├── storage/ # RocksDB storage layer
│ ├── pubsub/ # Pub/Sub messaging system
│ └── config/ # Configuration management
├── web/ # React web interface
│ ├── src/components/ # React components
│ ├── src/services/ # API integration
│ └── dist/ # Built assets
└── data/ # RocksDB data files
```

## Configuration

Environment variables:
- `BLACKIS_DB_PATH`: Database storage path (default: `./data`)
- `BLACKIS_REDIS_ADDR`: Redis server bind address (default: `127.0.0.1:6379`)
- `BLACKIS_HTTP_ADDR`: HTTP server bind address (default: `127.0.0.1:8080`)

## Performance

Blackis is designed for high performance:
- **Zero-copy** operations where possible
- **Async I/O** with Tokio for maximum concurrency
- **Efficient serialization** with optimized data layouts
- **RocksDB backend** for fast persistent storage
- **Memory-mapped** file I/O for large datasets

## Compatibility

Blackis implements a significant subset of Redis commands and behavior:
- Compatible with standard Redis clients
- Supports Redis Serialization Protocol (RESP)
- Multi-database support (SELECT 0-15)
- TTL and expiration handling
- Pub/Sub messaging patterns
- Atomic operations and transactions

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Development Guidelines
- Follow Rust best practices and use `cargo fmt`
- Add tests for new functionality
- Update documentation for API changes
- Ensure web interface works with backend changes

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

Created by Daniel Gerlag.

## Acknowledgments

- Inspired by Redis and its ecosystem
- Built with modern Rust async ecosystem (Tokio, Axum)
- Web interface powered by React and Material-UI
- Storage provided by RocksDB