惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
Latest news
Latest news
博客园 - 三生石上(FineUI控件)
美团技术团队
aimingoo的专栏
aimingoo的专栏
Google Online Security Blog
Google Online Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Threatpost
Y
Y Combinator Blog
T
Tailwind CSS Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
C
Cyber Attacks, Cyber Crime and Cyber Security
小众软件
小众软件
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tenable Blog
W
WeLiveSecurity
L
LINUX DO - 热门话题
D
Docker
Cyberwarzone
Cyberwarzone
量子位
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
T
The Exploit Database - CXSecurity.com
Engineering at Meta
Engineering at Meta
O
OpenAI News
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
IT之家
IT之家
S
Secure Thoughts
MongoDB | Blog
MongoDB | Blog
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Writing a Tiny Graph Database in Rust (State of the Program #2)
exopto · 2026-06-23 · via DEV Community

Today, June 22, 2026 (wait it's past midnight I mean yesterday), I finally published my first crate to crates.io after over a month of hard work on this tiny idea that just might work: What if you had an in-memory graph database written in Rust, but without enduring the pain of an Arc<Mutex<Box<Rc<RefCell<Weak<RwLock<Cow<Node<T>>>>>>>>>? What if there was no query language? What if there was only one dependency in cargo.toml, and it wasn't serde? And so, I sat down and got to work.

Initial Design

First things first, I had to actually get the idea down before wasting hours fighting the borrow checker. And so I drafted the idea in Python first. It was rushed to completion in a few days as a proof of concept, the major primitive being the Box, acting as a node with graph-level methods being on the same object as static methods or class methods (associated functions). There was also a global box container hiding global state and an Arrow, a thin though bidirectional-enabling edge represented as a tuple (label, reverse_label) with 4 types: child, parent, pointing, and incoming.

A Box was defined by its ID (a UUIDv4), its data (an arbitrary object that would almost certainly fail the JSON serialization that I added with zero checks or custom serialization methods last minute), and four internal lists for children, parents, pointing, and incoming nodes. While a lot would change from this design, I knew leaving the Arrow as explicitly not a first-class-citizen would be helpful, subverting the typical graph database expectation for simplicity. I included many helper methods, allowing one to search any of the arrows with an arbitrary function returning a bool, or find/get data and connect nodes through any of the Arrows conveniently abstracted into a method per operation per arrow.

Of course, while convenient, this was nowhere near production-ready in even the loosest sense of the term, so once I slapped on a super quick README and published to GitHub, I created a new Rust project on a brand new branch, leaving the messiness of Python's dynamic typing and lack of compile-time guarantees behind.

The New Design

I started with a relatively limited knowledge of Rust for a relatively limited project, hoping to just do a simple port while cleaning up the code to remove global state among other things, though I should have known how these things always go at this point. While there was an increase in complexity, I was able to confine it to four useful primitives:

  1. The Graph, which now became the center of the design now that it was explicitly created without any no global state (meaning nodes on the Graph did not know about the graph so their function was relatively limited compared to the graph).
  2. The Node (renamed from Box for obvious reasons), doing anything node-specific not involving the rest of the graph except for the UUIDs directly linked to the node that it does know about, including node creation, setting data, and iterating through neighbors, though both the former and latter gained abstractions in the Graph for convenience.
  3. The Arrow, now capable of custom labels and represented by two &'static strs, with the previous arrow types transformed into constants for simplicity. This was originally an enum before custom arrows became such an important part of the design, but was restructured after much careful deliberating on the design of the database implementation, in a stark contrast to the Python implementation.
  4. The Value, an enum restricting data to easily serializable types, originally housing a custom type with a blanket impl to enable full dynamic typing with From and Into, but obviously that would have been a nightmare later down the road so it was scrapped. Values also host the core of the serialization and deserialization logic, which I decided to hand-roll with O(n) time complexity. More on that later.

The Graph owns nodes, while the Node owns arrows as part of its linked field, which is simply a HashMap. No frills, O(1) insert and getting, that's all you need. The Node has a Value as its data and therefore owns the Values.

Due to the graph's ownership of nodes, there could be some conflicts with borrowing the graph mutably and the nodes immutably, so the interface is ID-centric so that this is never an issue as long as only IDs are carried around. This is a slight performance trade-off and may be revisited in later versions, but for v0.2.0 it's well worth it and makes the API beautifully ergonomic.

Development Purgatory

At this point, I started to work for hours upon hours upon hours each day on Deebee, eating up my life just to figure out the API. Admittedly, my focus was not great at times and procrastination can never be completely avoided (of course), but I continued to work hard, as the project dragged on with me thinking of better ways to structure the code, running my ideas and finished sections through AI to catch logic errors. I won't get into the fine details, but you can see my previous post on my writing of the serializer. I found that a lot of my earlier design decisions I had to revert or change, such as removing the Arrow argument from traversal (although I will add back an arrow-specific version in a future release) to get the find-type methods working all with a similar syntax.

Meanwhile, before sleeping, I routinely read a bit of the Rust Book, having started this project at Chapter 10 and ending it after having finished Chapter 15. The project and the reading combined greatly boosted my Rust skills in such a short time, and made me feel like I was doing something great with my life. This motivated me to keep going, although I began to contemplate each feature too long as if v0.2.0 had to be perfect. I wouldn't call this development hell per se, but it did extend out the project, kind of like a development purgatory. Eventually, all that was left until I could reach development heaven and release was the dreaded deserializer (to convert exported JSON into a Graph, the most complex part of which being converting the Values themselves) that I knew was going to be hard so I kept delaying further and further until there was nothing left to do. I don't know why I decided to hand-roll the serializer and deserializer, but I did.

The Deserializer

Although it took a while, the logic wasn't too bad all in all. Beforehand, I had drafted a small plan to loop through every character of the value to deserialize, but first the data was matched based on the type it must be; e.g., values with quotes on both ends were matched with a match guard to be converted to Value::Text, or brackets became Value::List.

For text, all that needed to be done was to unescape any special characters (like \n and that kind of stuff), which I was able to do relatively easily with a while let, giving me control over the flow of the loop (skipping and getting the data of items using next()), unlike a simple for loop. This allowed me to look into the future after finding backslashes while keeping it completely O(n).

Lists and Maps had their characters matched against brackets, braces, and quotes, each with a counter that counted the number of these characters the current character was nested in, so only splitting the collections at commas that were not nested in anything. Quotes checked for parity to determine whether to close or open, while the other two simply opened on an open bracket/brace and closed on a closed bracket/brace. Although it was late night when I wrote this logic and I was exhausted, I found the code to be quite elegant.

Since this code was so versatile, I could also reuse it for the top-level deserialization outside of Value. After that was done, all I needed to do was to make sure my codebase, which had ballooned in size after the deserializer logic was done, had no logic errors (which I used AI to check for like a true 2026 programmer), write tests (which I again used AI for*), push, navigate merge conflict issues on an empty stomach, and publish my first crate to crates.io!

However, I believe my live development logs tell the story better than I can with any amount of prose.


9:14 PM: I’m at the last and hardest part of the deserializer: Parsing nested arrays (vectors, lists, whatever you wanna call them) and JSON objects (dictionaries, hashmaps, whatever you wanna call them).

10:36 PM: I just lost a lot of time because I had to eat and actually do some socializing, but we’ll see if I can still get it done.

11:17 PM: Oh, that was easier than I thought. Array parsing done. Once I do the JSON object parsing, which is just reusing the same code with a slight difference, I’ll only have to write the actual to_json function on the Graph, and then ask AI to generate some tests for me. Once they all pass, I can commit, push, and publish!

12:11 AM: Value deserialization is finished and finally hopefully there are no bugs. It is too late. Tests are delayed. I have not implemented from_str but I think it is worth implementing before sleeping. Then I will publish to GitHub. That will be it.

12:16 AM: I have zero brainpower left. Deebee is delayed one more day. Coming Monday, I promise.

12:54 PM: After my worst sleep in probably a month (I started trying to sleep at 1:40 and fell asleep at 3:10 and then woke back up at 4:45 and then woke back up at 8:00 and then woke back up at 10:30 and this time couldn’t fall back asleep despite being super tired [trust me, I tried for 40 minutes to fall back asleep]), I’m back and have already thought of a simple method to wrap up the deserializer. O(n) perfection coming!

2:21 PM: I’ve been coding nonstop, and the deserializer is not perfectly efficient, but I have plans. Assuming all the tests work and all, I can publish. Results coming soon!

2:49 PM: A bit of a hiccup (I discovered there is a tiny memory leak with deserialization, please don’t tell anybody), and it’s about time for tests and finishing up the README!

3:19 PM: Tests now pass, everything is done, pushed to GitHub

3:32 PM: Was a little confusing to merge the Git branches but now that’s done and it’s published to crates.io/crates/deebee!


*I know, I know, but it's a hobby project and besides, it seriously did help me catch a deserialization error and I'm not vibe-coding the database itself.