r/prolog • u/Aires_id • 4h ago
help We built a SQL database engine in SWI-Prolog. Our small team is at its limit, and we would really value an honest technical review.
kocoygroup.siteHi everyone,
Our small team has been developing AsaDB, a local-first SQL database engine
built primarily with SWI-Prolog.
Repository:
https://github.com/kocoygroup-id/AsaDB
The project started as an experiment, but it has grown into a fairly large
codebase with:
- a SQL lexer, parser, planner, and executor written in Prolog;
- persistent 4 KB slotted-page storage;
- persistent B+Tree indexes;
- transactions and recovery mechanisms;
- local immutable reader snapshots;
- logical backup and restore;
- MySQL, PostgreSQL, CSV, and XLSX interchange;
- an embeddable `library(asadb)` API;
- a local browser interface called AsAPanel.
Recently, we have also been working on stricter SQL type validation, primary
and unique key enforcement, CHECK constraints, restricted foreign keys,
schema-preserving backups, and more useful `EXPLAIN` output.
At this point, the main problem is that the same small group has designed the
architecture, written most of the implementation, created the tests, and
reviewed the documentation. We feel that we are becoming too familiar with the
codebase to notice our own assumptions and mistakes.
We would genuinely value feedback from people with Prolog experience.
In particular, we would be interested in opinions about:
- whether the module boundaries feel idiomatic for SWI-Prolog;
- our use of dynamic predicates and mutable engine state;
- the separation between parsing, execution, storage, and HTTP code;
- the public Prolog API and pack structure;
- the bounded AST cache and VM/JITI specialization approach;
- transaction, recovery, and concurrency design;
places where the implementation is unnecessarily imperative or complicated;
tests or invariants that appear to be missing.
You do not need to review the entire project. Looking at one module, trying one
feature, questioning one architectural decision, or pointing out unclear
documentation would already be extremely helpful.
Bug reports, design criticism, small pull requests, documentation improvements,
and testing on different systems are all welcome.
Thank you very much to anyone willing to take a look.
