---
title: "kestrel: SQL database engine in Kotlin | VulCode"
description: "kestrel is a relational database engine written from scratch in Kotlin: a SQL parser, B-tree storage, an executor, transactions and a CLI."
url: "https://vulcode.com/en/portfolio/other/kestrel"
lang: "en"
---

[Other](https://vulcode.com/en/portfolio/other)

# kestrel

SQL database engine in Kotlin

A relational database engine written from scratch in Kotlin. It takes SQL queries from the command line, keeps data on disk and protects writes from being lost on a sudden power-off.

## About the project

kestrel is a relational database engine written from scratch in Kotlin: a SQL parser, B-tree storage, an executor, transactions and a CLI. The parser understands SQL queries and the executor runs them on data held in a B-tree, a structure that makes it quick to find a record on disk. Transactions rely on a WAL (a write-ahead log that protects data in a crash). The engine runs real SQL queries and is covered by a full test suite.

## The challenge

Writing a database from scratch means facing what is usually hidden: how to keep data on disk, how to parse SQL and how not to lose a write on a sudden power-off. In kestrel each of these had to be solved by hand.

## What we did

- Its own SQL parser

- An executor that runs the queries

- Data storage based on a B-tree

- Transactions with a WAL that protects writes in a crash

- A CLI for working with the database and a full test suite

## Related projects

- Project
  ### sift
  A program in Haskell that checks whether a logical formula can be satisfied. The solver comes with a propositional-logic toolkit and a parser for files in the DIMACS format.
  [Project](https://vulcode.com/en/portfolio/other/sift)

- Project
  ### fml
  A small programming language from the ML family, written from scratch in F#. A program goes the whole way in it: from source text, through type checking, to a computed result.
  [Project](https://vulcode.com/en/portfolio/other/fml)

- Project
  ### lumen
  A scripting language with dynamic typing, implemented in Kotlin. It has its own bytecode compiler and its own virtual machine that executes that code.
  [Project](https://vulcode.com/en/portfolio/other/lumen)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)

## Tell us what you want to build.

A free quote comes back within an hour during working hours. You talk to the person who writes the code.

[Free quote](https://vulcode.com/en/quote) [Free consultation](https://vulcode.com/en/consultation)

- [hello@vulcode.com](mailto:hello@vulcode.com)

- [+48 576 043 920](tel:+48576043920)

- [discord.gg/vulcode](https://discord.gg/vulcode)
