Skip to content

A lightweight, embedded key-value database written in Go — featuring B-Tree storage, WAL, SQL support, REST & WebSocket APIs.

License

Notifications You must be signed in to change notification settings

rafaelmgr12/litegodb

Repository files navigation

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.

About

A lightweight, embedded key-value database written in Go — featuring B-Tree storage, WAL, SQL support, REST & WebSocket APIs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published