litedb-org/LiteDB
LiteDB - A .NET NoSQL Document Store in a single data file
Healthy across the board
Permissive license, no critical CVEs, actively maintained — safe to depend on.
Has a license, tests, and CI — clean foundation to fork and modify.
Documented and popular — useful reference codebase to read through.
No critical CVEs, sane security posture — runnable as-is.
- ✓Last commit 8w ago
- ✓9 active contributors
- ✓Distributed ownership (top contributor 49% of recent commits)
Show 3 more →Show less
- ✓MIT licensed
- ✓Tests present
- ⚠No CI workflows detected
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Healthy" badge
Paste into your README — live-updates from the latest cached analysis.
[](https://repopilot.app/r/litedb-org/litedb)Paste at the top of your README.md — renders inline like a shields.io badge.
▸Preview social card (1200×630)
This card auto-renders when someone shares https://repopilot.app/r/litedb-org/litedb on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: litedb-org/LiteDB
Generated by RepoPilot · 2026-05-09 · Source
🤖Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding. - Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/litedb-org/LiteDB shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
🎯Verdict
GO — Healthy across the board
- Last commit 8w ago
- 9 active contributors
- Distributed ownership (top contributor 49% of recent commits)
- MIT licensed
- Tests present
- ⚠ No CI workflows detected
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
✅Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live litedb-org/LiteDB
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale — regenerate it at
repopilot.app/r/litedb-org/LiteDB.
What it runs against: a local clone of litedb-org/LiteDB — the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in litedb-org/LiteDB | Confirms the artifact applies here, not a fork |
| 2 | License is still MIT | Catches relicense before you depend on it |
| 3 | Default branch master exists | Catches branch renames |
| 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code |
| 5 | Last commit ≤ 88 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of litedb-org/LiteDB. If you don't
# have one yet, run these first:
#
# git clone https://github.com/litedb-org/LiteDB.git
# cd LiteDB
#
# Then paste this script. Every check is read-only — no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of litedb-org/LiteDB and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "litedb-org/LiteDB(\\.git)?\\b" \\
&& ok "origin remote is litedb-org/LiteDB" \\
|| miss "origin remote is not litedb-org/LiteDB (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
&& ok "license is MIT" \\
|| miss "license drift — was MIT at generation time"
# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
&& ok "default branch master exists" \\
|| miss "default branch master no longer exists"
# 4. Critical files exist
test -f "LiteDB/LiteDatabase.cs" \\
&& ok "LiteDB/LiteDatabase.cs" \\
|| miss "missing critical file: LiteDB/LiteDatabase.cs"
test -f "LiteDB/Engine/Engine.cs" \\
&& ok "LiteDB/Engine/Engine.cs" \\
|| miss "missing critical file: LiteDB/Engine/Engine.cs"
test -f "LiteDB/Document/BsonDocument.cs" \\
&& ok "LiteDB/Document/BsonDocument.cs" \\
|| miss "missing critical file: LiteDB/Document/BsonDocument.cs"
test -f "LiteDB/Storage/PageManager.cs" \\
&& ok "LiteDB/Storage/PageManager.cs" \\
|| miss "missing critical file: LiteDB/Storage/PageManager.cs"
test -f "LiteDB/Index/IndexManager.cs" \\
&& ok "LiteDB/Index/IndexManager.cs" \\
|| miss "missing critical file: LiteDB/Index/IndexManager.cs"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 88 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~58d)"
else
miss "last commit was $days_since_last days ago — artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) — safe to trust"
else
echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/litedb-org/LiteDB"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
⚡TL;DR
LiteDB is a .NET embedded NoSQL document database that stores all data in a single file, similar to SQLite but for documents. It provides ACID transactions, full-text indexing, BSON serialization, and a MongoDB-like API—all in a single ~450KB DLL with no external dependencies, making it ideal for desktop, mobile, and embedded applications that need local data persistence. Single-repo structure: /LiteDB/ contains the core engine (storage, indexing, query, transactions), /LiteDB.Shell/ provides a CLI REPL, /LiteDB.Benchmarks/ contains performance testing suite across insertion/querying/deletion scenarios, and /ConsoleApp1/ is a development sandbox. The solution uses standard C# project structure with .csproj files for multi-targeting .NET versions.
👥Who it's for
.NET developers (C# / .NET Framework / .NET Standard / .NET Core) building desktop applications, mobile apps, or services that need local NoSQL storage without server infrastructure. Specifically targets developers familiar with MongoDB's API who want that experience in a single-file embedded database.
🌱Maturity & risk
Mature and actively maintained. LiteDB v5 represents a major engine rewrite with significant architectural improvements (multi-reader support, per-collection write locks, new query engine). The project has a public NuGet package with consistent downloads, an official UI tool (LiteDB.Studio), comprehensive wiki documentation, and Discord community. CI/CD via GitHub Actions is active.
Low risk for stable features; moderate risk for cutting-edge features. V5 is a complete storage engine rewrite, so edge cases may exist despite maturity. Single primary maintainer (mbdavid) creates maintenance risk. The benchmarks suite and test infrastructure suggest quality focus, but commit recency data is not visible in the provided file list. Breaking changes between v4 and v5 are documented but require migration effort.
Active areas of work
Active development on v5 features: the benchmarks suite covers new scenarios (compound indexes, DateTime offsets, expression-based property filtering), and the Shell tool is being maintained with command implementations. New SQL-like syntax and partial document loading are recent additions. The pre-release pipeline (publish-prerelease.yml) suggests ongoing beta testing.
🚀Get running
git clone https://github.com/litedb-org/LiteDB.git
cd LiteDB
dotnet build
dotnet test # if test project exists in solution
Or open LiteDB.sln in Visual Studio and build directly.
Daily commands:
# Build the core library
dotnet build LiteDB/LiteDB.csproj
# Run the interactive shell
dotnet run --project LiteDB.Shell/LiteDB.Shell.csproj
# Run benchmarks
dotnet run --project LiteDB.Benchmarks/LiteDB.Benchmarks.csproj --configuration Release
# Use in your own project: add NuGet
Install-Package LiteDB
🗺️Map of the codebase
LiteDB/LiteDatabase.cs— Primary entry point and public API surface for database operations; every contributor must understand the transaction and collection access patterns hereLiteDB/Engine/Engine.cs— Core engine managing pages, transactions, and WAL; fundamental to understanding persistence and ACID guaranteesLiteDB/Document/BsonDocument.cs— BSON serialization and document model abstraction; essential for understanding data representation across the codebaseLiteDB/Storage/PageManager.cs— Manages disk page allocation and caching; critical for performance and understanding the storage layerLiteDB/Index/IndexManager.cs— B-tree index creation and maintenance; key to query optimization and indexed lookupsLiteDB/Utils/Mapper.cs— Object-to-document mapping with reflection; foundational for POCO serialization and property bindingLiteDB/Engine/Services/TransactionService.cs— Transaction isolation and lock management; essential for understanding concurrency and ACID properties
🛠️How to make changes
Add a new BSON data type
- Define the type enum value in BsonType.cs (
LiteDB/Document/BsonType.cs) - Add serialization logic in BsonWriter.cs WriteValue() method (
LiteDB/Document/BsonWriter.cs) - Add deserialization logic in BsonReader.cs ReadValue() method (
LiteDB/Document/BsonReader.cs) - Update BsonDocument value accessors to handle new type (
LiteDB/Document/BsonDocument.cs) - Add mapper conversion in Mapper.cs for POCO property binding (
LiteDB/Utils/Mapper.cs) - Write integration tests in LiteDB.Tests/Document (
LiteDB.Tests/Document/Bson_Tests.cs)
Add a new indexing strategy
- Create new index node class inheriting from IndexNode (
LiteDB/Index/IndexNode.cs) - Implement index creation and lookup logic in IndexManager (
LiteDB/Index/IndexManager.cs) - Add index type to IndexOptions or create new option class (
LiteDB/Index/IndexOptions.cs) - Update QueryCompiler to generate query plans using new index type (
LiteDB/Query/QueryCompiler.cs) - Add benchmark test for index performance (
LiteDB.Benchmarks/Benchmarks/Queries/QueryCompoundIndexBenchmark.cs)
Add a new shell command
- Create command class implementing IShellCommand interface (
LiteDB.Shell/Commands/IShellCommand.cs) - Implement Execute() and GetSyntax() methods with desired functionality (
LiteDB.Shell/Commands/Help.cs) - Register command in ShellProgram's command dispatcher (
LiteDB.Shell/Shell/ShellProgram.cs) - Add help documentation in the Help command (
LiteDB.Shell/Commands/Help.cs)
Implement a new storage persistence feature
- Create service class in Engine/Services for new feature logic (
LiteDB/Engine/Services) - Integrate service into Engine initialization and transaction flow (
LiteDB/Engine/Engine.cs) - Update PageManager if feature affects page allocation or caching (
LiteDB/Storage/PageManager.cs) - Implement WAL recovery logic if feature requires crash recovery (
LiteDB/Engine/Services/WalIndexService.cs) - Add storage/recovery tests in LiteDB.Tests/Database (
LiteDB.Tests/Database/Storage_Tests.cs)
🔧Why these technologies
- .NET Framework / .NET Standard — Enables single-file DLL distribution (<450kb) targeting .NET 4.5 and .NET Core across Windows, Linux, macOS
- BSON binary format — Standard document serialization matching MongoDB compatibility while maintaining compact storage and fast parsing
- B-tree indexing — Provides O(log n) lookups, efficient range queries, and sorted iteration for relational-like index performance
- Write-Ahead Logging (WAL) — Ensures ACID durability and enables crash recovery without full page flushes, improving write throughput
- AES/DES encryption — Protects sensitive data at rest using industry-standard cryptography without external dependencies
- Reflection-based mapping — Eliminates manual serialization code for POCOs and enables dynamic property binding from BSON documents
⚖️Trade-offs already made
-
Single-file datafile instead of multi-file sharding
- Why: Simplifies deployment, backup, and portability for small-to-medium applications
- Consequence: Not suitable for very large datasets (TB+) or distributed scenarios; all data on single machine
-
Embedded engine rather than client-server architecture
- Why: Eliminates network latency and enables serverless operation, reducing operational complexity
- Consequence: Limited to single process (or single machine with careful locking); no remote access or multi-node replication
-
In-process page caching vs. external cache
- Why: Reduces context switches and enables precise cache invalidation tied to transaction lifecycle
- Consequence: Memory usage scales
🪤Traps & gotchas
No .gitignore or Dependencies/Config details visible in the file list, so check for secrets management practices locally. The v5 storage format is not backward-compatible with v4—migrations are manual. The single-file design can cause lock contention if you perform many concurrent writes; understand per-collection locking behavior. No obvious unit test project in the file list (only ConsoleApp1 sandbox), so integration testing may be ad-hoc—verify test infrastructure before contributing.
🏗️Architecture
💡Concepts to learn
- B+ Tree Indexing — LiteDB uses B+ trees for fast range queries and sorted result sets; understanding this structure is essential for optimizing queries and explaining index behavior in benchmarks
- BSON (Binary JSON) — LiteDB serializes documents to BSON format for storage and transport; familiarity with BSON is required to understand data encoding and why certain types (ObjectId, Decimal128) exist
- Write-Ahead Logging (WAL) — LiteDB uses WAL for data recovery after write failures; understanding transaction logs is critical for debugging corruption issues and understanding durability guarantees
- ACID Transactions — LiteDB provides full ACID compliance; knowing isolation levels, durability semantics, and transaction rollback behavior is essential for multi-writer scenarios
- Memory-Mapped I/O (Optional in LiteDB) — LiteDB can use memory-mapped files for faster I/O in certain configurations; understanding this trade-off between speed and crash recovery is important for performance tuning
- Document Model vs. Relational Model — LiteDB is document-oriented (like MongoDB), not relational; this affects how you design schemas, handle joins, and think about data normalization differently than SQL developers expect
- Query Expression Trees (LINQ) — LiteDB supports LINQ queries which compile to its internal query engine; understanding expression tree translation is key to optimizing queries and debugging unexpected behavior
🔗Related repos
mbdavid/LiteDB.Studio— Official UI tool for LiteDB database visualization and management; essential companion for non-CLI workflowsravendb/ravendb— Similar embedded document database for .NET but with more complex features (Lucene indexing, distributed replication); alternative if you need enterprise featuressqlite/sqlite— Spiritual predecessor: single-file embedded SQL database; LiteDB replicates this design philosophy but for NoSQL/documentsmongodb/mongo-csharp-driver— Official MongoDB C# driver; LiteDB's API is intentionally MongoDB-like, so MongoDB users can switch with minimal code changesdotnet/efcore— Entity Framework Core is the standard ORM for .NET; LiteDB offers a lighter alternative for scenarios where ORM overhead is unwanted
🪄PR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add comprehensive benchmarking CI workflow for performance regression detection
LiteDB has an extensive LiteDB.Benchmarks project with benchmarks for insertion, deletion, queries, and generators, but there's no GitHub Actions workflow to run these benchmarks on each PR. This would help catch performance regressions before they're merged. The repo already has publish-prerelease.yml, so adding a benchmark workflow would follow the same pattern.
- [ ] Create .github/workflows/benchmark.yml that runs LiteDB.Benchmarks/Program.cs on PR events
- [ ] Configure the workflow to run against multiple frameworks (.NET 4.5, .NET Standard) as mentioned in README
- [ ] Add step to compare benchmark results against main branch and comment on PRs with performance delta
- [ ] Reference benchmark constants from LiteDB.Benchmarks/Benchmarks/Constants.cs in workflow documentation
Add unit tests for LiteDB.Shell command infrastructure
The LiteDB.Shell project has shell commands (Close.cs, Open.cs, Help.cs, etc.) and shell infrastructure (Display.cs, InputCommand.cs, ShellProgram.cs) but there's no apparent test project for these components. Adding tests would ensure shell command parsing and execution reliability, especially for the critical Open/Close commands.
- [ ] Create LiteDB.Shell.Tests project alongside existing LiteDB.Shell.csproj
- [ ] Add unit tests for IShellCommand implementations (Close.cs, Open.cs, Run.cs, etc.)
- [ ] Add integration tests for InputCommand.cs parsing against real shell input scenarios
- [ ] Add tests for ShellProgram.cs command routing and error handling
Add XML documentation and unit tests for LiteDB.Stress test framework
LiteDB.Stress contains a stress testing framework (TestExecution.cs, ITaskItem.cs, task implementations) with examples (test-01.xml, test-02.xml) but lacks comprehensive documentation and unit tests. New contributors could document the task XML schema and add tests for task parsing/execution to make the stress testing framework more maintainable.
- [ ] Add XML documentation comments to interfaces in LiteDB.Stress/Test/ (ITaskItem.cs, etc.)
- [ ] Create LiteDB.Stress.Tests project with unit tests for XML task parsing in TestExecution.cs
- [ ] Add tests for InsertTaskItem.cs and SqlTaskItem.cs task execution against in-memory database
- [ ] Create schema documentation file explaining test-01.xml/test-02.xml XML element structure
🌿Good first issues
- Add unit tests for
/LiteDB.Benchmarks/Benchmarks/Queries/QueryCompoundIndexBenchmark.csscenarios; currently only benchmarks exist, no corresponding test coverage visible - Implement a
Statuscommand in/LiteDB.Shell/Commands/to display database statistics (file size, collection count, index count) similar to Redis CLI'sINFOcommand - Document the B+ tree index implementation in
/LiteDB/with inline code comments; benchmarks suggest it's heavily used but source documentation is sparse
⭐Top contributors
Click to expand
Top contributors
- @JKamsker — 49 commits
- @pictos — 20 commits
- @mbdavid — 9 commits
- @SpaceCheetah — 9 commits
- @Joy-less — 4 commits
📝Recent commits
Click to expand
Recent commits
c9d78eb— Update README with new build status and badges (JKamsker)de528a6— Add Contributor Covenant Code of Conduct (JKamsker)a029889— Merge pull request #2607 from coldays/add_modulo_opeator (JKamsker)8abcf94— Merge pull request #2572 from JKamsker/bugs/2570-Support-FieldOnly-ValueTypes (JKamsker)38ff333— Add test for both int and double (coldays)f6a1f36— Added arithmetic operators test in Expressions_Scalar_Operator (coldays)b167504— Added modulo operator to BsonValue (coldays)2cc00c7— Merge pull request #2575 from vonzshik/concurrent-mapper-access-unbuild-mapper-return-fix (JKamsker)0412152— Fix returning temporary mapper on concurrent access to BsonMapper (vonzshik)91f6c68— Merge pull request #2569 from JKamsker/bugs/concurrent-access#2 (JKamsker)
🔒Security observations
LiteDB appears to be a reasonably well-structured NoSQL database project with moderate security posture. The main concerns are around deserialization safety (common in document databases), query injection prevention, and data encryption guidance. No hardcoded secrets, exposed credentials, or critical infrastructure misconfigurations were detected in the provided file structure. The project should focus on implementing strict input validation, safe deserialization practices, and comprehensive security documentation for production deployments.
- Medium · Potential SQL Injection via Query Construction —
LiteDB.Benchmarks/Benchmarks/Queries/ and core query processing logic (not visible in provided structure). LiteDB is a NoSQL database, but the file structure indicates it processes queries (evidenced by QueryAllBenchmark.cs, QuerySimpleIndexBenchmarks.cs, etc.). Without examining the actual query parsing code, there's a risk that dynamic query construction could be vulnerable to injection attacks if user input is not properly sanitized or parameterized. Fix: Ensure all query parameters are properly validated and sanitized. Use parameterized queries where applicable. Implement input validation for all user-provided filter expressions. - Medium · Potential Deserialization Security Issues —
Core serialization/deserialization modules (not explicitly visible but inherent to document database design). As a document store with BSON/JSON serialization, LiteDB may deserialize untrusted data from database files or network sources. Unsafe deserialization can lead to Remote Code Execution (RCE) if the deserializer instantiates arbitrary .NET types without proper restrictions. Fix: Implement strict type whitelisting during deserialization. Use custom serialization surrogates to prevent instantiation of dangerous types. Never deserialize data from untrusted sources without validation. - Low · Missing HTTPS/Encryption Guidance in Shell Interface —
LiteDB.Shell/Shell/ShellProgram.cs and LiteDB.Shell/Commands/Open.cs. LiteDB.Shell (a command-line interface) is present, but there's no visible indication of encryption for database connections. While LiteDB is embedded, if networking is exposed, connections should be encrypted. Fix: Document encryption requirements for database files. If network access is supported, enforce TLS/SSL. Provide guidance on securing database file access permissions. - Low · Test Data in Benchmark Projects —
ConsoleApp1/Tools/Faker.cs, ConsoleApp1/Tools/Faker.Names.cs. The Faker.cs and Faker.Names.cs files in ConsoleApp1/Tools suggest generation of test/benchmark data. If this test data generation includes sensitive information patterns, it could pose a risk if accidentally exposed. Fix: Ensure test data generators don't create realistic sensitive information (credentials, PII). Keep benchmark/test code separate from production builds. - Low · No Visible Access Control Mechanisms —
Core LiteDB codebase structure (not visible in detail). The file structure shows no apparent role-based access control (RBAC) or authentication mechanisms documented at the file level. For a database system, this could be a concern in multi-user environments. Fix: Implement user authentication and authorization mechanisms. Document security considerations for database file access. Recommend file-level permissions (OS-level) for production use.
LLM-derived; treat as a starting point, not a security audit.
👉Where to read next
- Open issues — current backlog
- Recent PRs — what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.