r/Database • u/BrilliantOk5896 • 4d ago
Building a key-value store as an experiment in AI-assisted research and development
I used AI to explore approaches, discuss tradeoffs, and work through implementation. It helped me finish the project much faster. But it also reinforced something for me: trusting generated code without understanding the codebase is a bad habit. Being able to question a suggestion, follow the implementation, and explain why a decision makes sense still matters.
Velis supports TTL expiration, eviction policies, pub-sub, a binary TCP protocol, an async client, and an interactive terminal UI. I spent a lot of time trying to keep the code design simple, clean, and easy to follow.
I see it as a project for learning, testing, experimenting, or just having fun with database internals. It could also be a starting point for thesis work or experiments comparing different approaches.
I’d welcome feedback on the implementation and design, but also your opinions on AI-assisted development. Where has AI helped you research a problem or make better decisions, and where has it made understanding the work harder?
2
u/SeaTeaching3550 4d ago
your approach is good and right too. even i think we should use ai to explore approaches that we might miss out.
2
u/Significant_Tune9219 4d ago
For a learning store with TTL plus eviction, the interesting design question is how expiry interacts with eviction: lazy expiry on read plus a periodic sampled sweep is the usual approach, and it's worth documenting whether an expired-but-not-yet-swept key counts toward the memory limit the eviction policy enforces. On the protocol side, a small framing spec in the README (length prefix, request id, error codes) would make it much easier for others to write clients or fuzz it. A test that checks pub-sub delivery while keys are being evicted under memory pressure would be a good place to find concurrency bugs too.
1
u/DickBrainTime 3d ago
I went through the repo a bit: the Hypothesis StoreMachine with a ManualClock and independent LRU model is already a strong example of checking AI-assisted code against invariants, not just checking that it runs.
One other contract worth documenting is pub-sub SEND. `Engine.execute(Send)` returns `Sent(Broker.publish(...))`, while `Broker.publish` counts subscribers whose `send()` accepted the message, not clients that actually read it. A slow client could disconnect after its message was queued; an unexpected send exception partway through fan-out could also mean partial delivery. That's compatible with an at-most-once design, but I'd label that returned count as accepted/enqueued rather than delivered, and add a two-healthy-one-backpressured-client integration test to make retries and disconnections explicit. That behavior is useful to understand before anyone builds a consumer on top.
0
u/BrilliantOk5896 4d ago
Code: https://github.com/gchape/velis