Open Source Document Database · .NET 9

Store
JSON.
Query it like
SQL.

A single-file embedded database for C# apps. Mainframe-inspired direct addressing, familiar SQL syntax, and production-grade replication — without the operational weight of MongoDB.

Version 0.1.0
License MIT
Runtime .NET 9
Dependencies Zero
10M
Documents proven on a laptop
210K
Point lookups / sec
48
Tests, all green
0
External dependencies

Why DocumentForge

Three designs coexisted for thirty years: SQLite for embedded relational data, MongoDB for JSON at scale, and the venerable mainframe TPF systems running airline reservations. DocumentForge takes the best of each and ships as a single .NET library.

01

JSON-native, SQL-fluent

Write SELECT * FROM orders WHERE passenger.lastName = 'Smith'. JOINs, GROUP BY, aggregations, composite indexes — the syntax every developer already knows.

02

Sub-millisecond lookups

Direct-address location map means every document has a known physical address. 210,000 QPS for indexed point lookups on a single laptop, even at 10M docs.

03

LINQ API for C# devs

db.Collection<Order>("orders").Where(o => o.Pnr == "ABC").FirstOrDefault(). Strongly typed, captured variables work, no SQL strings required.

04

Crash safety built in

Write-ahead recovery log with CRC32 per record. Per-page checksums detect silent corruption. Crash recovery on every restart.

05

Replication & auto-failover

Logical replication with sequence numbers and catchup. Follower auto-promotes on leader silence. Planned handover for zero-data-loss datacenter moves.

06

Consistent-hash sharding

Scale horizontally across N nodes. Online rebalance with zero downtime — clients read and write throughout the migration. Add or drop shards safely.

Ten lines to production

Open a file, insert a JSON document, run a SQL query. There is no server to install, no connection string to configure, no schema to migrate.

using DocumentForge.Engine;

// Open or create a database file
using var db = DocumentForgeDb.OpenOrCreate("airline.dfdb");

// Insert a document
db.Insert("orders", @"{
    ""pnr"": ""ABC123"",
    ""passenger"": { ""lastName"": ""Smith"" },
    ""flights"": [{ ""flightNumber"": ""AA100"" }]
}");

// Create indexes
db.CreateIndex("orders", "pnr", "idx_pnr", unique: true);
db.CreateIndex("orders", "passenger.lastName", "idx_ln");

// Query with SQL
var result = db.Execute("SELECT * FROM orders WHERE pnr = 'ABC123'");
Console.WriteLine(result.Documents[0].ToJson());

Built for the realistic middle

A laptop comfortably holds 10 million documents with five indexes, sustaining 40,000+ inserts per second and 160,000+ indexed reads per second — verified in the included benchmark. Sharding extends this linearly across commodity nodes. Online rebalance moves data between shards while clients keep reading and writing.

DocumentForge isn't trying to be the biggest database. It's trying to be the one you reach for when you want JSON flexibility, SQL familiarity, and an operational footprint that fits in your head.

Ecosystem

LIB

DocumentForge NuGet

Add to any .NET 9 project. Open a file, start querying. No external dependencies.

API

REST server (built in)

dfdb serve stands up a node per shard with one command. JSON-in/JSON-out. Each node reads a small node.json config (or takes CLI flags).

CLI

dfdb binary

One self-contained executable with every feature: serve, query, repl, cluster, health, rebalance, seed. Ships as a 47 MB file with the runtime bundled — no .NET required on the target machine.

UI

Admin web UI

Separate Next.js app. Dashboard, query console, collections browser, cluster topology builder — no command line required.

Status: DocumentForge is a learning-focused open-source project demonstrating how a modern document database can be built from the ground up in ~6,500 lines of C#. 48 tests, a NuGet package, a single-file dfdb binary, a Next.js admin UI, and ten documentation pages (including a full CLI reference). Use it for embedded scenarios, prototypes, small-to-medium production workloads, and understanding how databases actually work.