litegodb

module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2025 License: MIT

README

LiteGoDB

LiteGoDB is a lightweight key-value database written in Go, featuring a B-Tree storage engine, write-ahead logging (WAL), SQL-like command support, and a REST/WebSocket interface.

Features

  • B-Tree-based key-value storage engine
  • Write-Ahead Logging (WAL) for durability and crash recovery
  • SQL-like query support: INSERT, SELECT, DELETE
  • REST API and WebSocket interface
  • Native Go client
  • CLI client (litegodbc)
  • Docker-ready for local or containerized deployment

Getting Started

Run with Docker
git clone https://github.com/rafaelmgr12/litegodb.git
cd litegodb
docker compose up --build

This will start the LiteGoDB server at http://localhost:8080

API Usage

Insert a key-value pair
curl -X POST http://localhost:8080/sql \
  -H "Content-Type: application/json" \
  -d '{"query":"INSERT INTO users VALUES (1, '\''rafael'\'')"}'
Retrieve a value by key
curl -X POST http://localhost:8080/sql \
  -H "Content-Type: application/json" \
  -d '{"query":"SELECT * FROM users WHERE `key` = 1"}'

Native Go Usage

import "github.com/rafaelmgr12/litegodb/pkg/litegodb"

db, _ := litegodb.Open("config.yaml")
db.Put("users", 1, "rafael")
value, found, _ := db.Get("users", 1)

Testing

Run all unit and integration tests:

go test ./...

CLI (litegodbc)

The CLI client connects to a LiteGoDB server via HTTP.

go run cmd/litegodbc/main.go --url http://localhost:8080
> INSERT INTO users VALUES (1, 'joao');
> SELECT * FROM users WHERE `key` = 1;

Project Structure

litegodb/
├── cmd/
│   ├── server/        # REST/WebSocket server entrypoint
│   └── litegodbc/     # CLI client
├── internal/
│   └── storage/       # B-Tree engine, disk manager, WAL
├── pkg/
│   └── litegodb/      # Public Go API interface
├── config.yaml        # Server configuration
├── Dockerfile         # Container build config
└── docker-compose.yml # Local dev environment

Contributing

Contributions are welcome! Feel free to fork the repository, submit issues, or open pull requests.

License

MIT License — see the LICENSE file for details.

Directories

Path Synopsis
cmd
litegodb command
server command
internal
storage/disk
The `FileDiskManager` struct in the `disk` package provides methods for managing disk storage of pages in a file-based system.
The `FileDiskManager` struct in the `disk` package provides methods for managing disk storage of pages in a file-based system.
pkg
litegodb
Package litegodb provides configuration management and initialization for the lightweight key-value database.
Package litegodb provides configuration management and initialization for the lightweight key-value database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL