---
title: "Golphin — Parth Kapoor"
description: "A key-value database built from scratch in Go"
canonical: "https://parthkapoor.me/builds/golphin"
---

# Golphin

> A key-value database built from scratch in Go

Golphin is a learning project to understand how databases work by building one by hand in Go. It is currently a Bitcask-shaped key-value store: append-only segment files on disk, an in-memory index from key to location, and compaction by copying live records into a fresh segment and renaming it.

The code is layered as cli -> db -> {index, segments} -> fs, where segments own raw byte storage and the index owns key-to-location lookups, with Db as the only component that knows both. The index was recently rebuilt from a plain binary search tree onto a hand-written generic AVL tree, since a plain BST degenerates on sorted key inserts; benchmarks are tracked in CI on every push. The stated long-term goal is an embedded, SQLite-shaped relational database once ordered range scans over the storage engine are solid.

- Status: work in progress
- Language: Go
- Started: Aug 2026
- Source: https://github.com/parthkapoor-dev/golphin

## Highlights

- Append-only segmented log storage with copy-and-rename compaction
- In-memory index rebuilt on a hand-written generic AVL tree, replacing an earlier plain BST
- Index snapshots persisted to disk with a marker-verified recovery fallback
- Ordered range queries over the index, with benchmarks tracked in CI and published to a public dashboard
- Roadmap (per project docs) targets a TUI, a background daemon, and eventually an embedded SQL engine

## Stack

- **Language**: Go
- **Storage Engine**: Append-only log, Segment compaction, Custom AVL-tree index
- **Tooling**: CLI, GitHub Actions CI, Benchmark dashboard

All builds: [https://parthkapoor.me/builds](https://parthkapoor.me/builds.md)
