AI News HubLIVE
In-site rewrite4 min read

Monlite Simple Infrastructure for AI Agent

Monlite is an open-source project that consolidates multiple backend services (database, cache, queue, vector search, full-text search, cron) into a single SQLite file. Designed for local apps, CLIs, and AI agents, it requires no Docker or complex setup—just an npm install. Key features include document collections, vector search, full-text search, cache, queue, cron, and cloud sync.

SourceHacker News AIAuthor: emadjumaah

Notifications You must be signed in to change notification settings

Fork 2

Star 19

BranchesTags

Open more actions menu

Folders and files

NameName

Last commit message

Last commit date

Latest commit

History

75 Commits

75 Commits

.github/workflows

.github/workflows

bench

bench

demo

demo

docs

docs

examples

examples

packages

packages

python

python

src

src

tests

tests

.gitignore

.gitignore

.prettierignore

.prettierignore

.prettierrc.json

.prettierrc.json

CHANGELOG.md

CHANGELOG.md

LICENSE

LICENSE

README.md

README.md

eslint.config.js

eslint.config.js

package.json

package.json

pnpm-lock.yaml

pnpm-lock.yaml

pnpm-workspace.yaml

pnpm-workspace.yaml

tsconfig.json

tsconfig.json

tsup.config.ts

tsup.config.ts

vitest.config.ts

vitest.config.ts

Repository files navigation

Stop spinning up Docker stacks. Documents, vectors, full-text search, cache, queue, and cron — in one SQLite file, with a zero-dependency TypeScript core.

import { createDb } from "@monlite/core";

const db = createDb("./app.db");

That's it. No server. No migrations. No configuration. Everything below lives in app.db.

📖 Docs · 🎮 Live demo — monlite running in your browser · 💻 GitHub

Replace your entire local stack with one file

Most local apps, CLIs, and AI agents juggle the same set of services. monlite collapses all of them into a single .db file:

You were running monlite gives you

MongoDB / Mongoose @monlite/core — document collections, typed queries, reactive watch()

Redis (cache) @monlite/kv — synchronous cache, atomic locks, TTLs

BullMQ + Redis @monlite/queue — durable job queue, retries, backoff, dedupe

Qdrant / Pinecone @monlite/vector — vector search, findSimilar(), hybrid RAG

Elasticsearch / Typesense @monlite/fts — full-text search, FTS5, search()

Cron server @monlite/cron — persisted scheduled jobs

MongoDB Atlas sync @monlite/sync — local-first replication to MongoDB / PostgreSQL / MySQL

One npm install per feature. One .db file for all of them. Backup = cp app.db backup.db.

The AI agent backend — without Docker

A coding agent, RAG pipeline, or autonomous worker typically needs MongoDB for memory, Redis for cache and locks, Qdrant for semantic search, and BullMQ for the task queue.

With monlite, that entire stack is one file:

import { createDb } from "@monlite/core"; import { kv } from "@monlite/kv"; import { createVectorStore } from "@monlite/vector"; import { createQueue } from "@monlite/queue"; import { createCron } from "@monlite/cron";

const db = createDb("./agent.db");

// Memory / state — document collections const memories = db.collection("memories"); await memories.create({ data: { agentId: "a1", content: "user prefers dark mode" } });

// Semantic recall — vector search over embeddings const store = createVectorStore(db); store.ensureCollection("memory", { dimensions: 384, indexedFields: ["agentId"] }); const recall = store.search("memory", { vector: queryEmb, topK: 5, where: { agentId: "a1" } });

// Exactly-once job claim — cross-process compare-and-swap const claimed = await jobs.findOneAndUpdate({ where: { status: "pending", type: "summarize" }, data: { $set: { status: "active" }, $inc: { version: 1 } }, returnDocument: "after", }); // 8 workers race. Exactly one wins. The rest get null.

// Cache + atomic locks — set-if-absent const lock = kv(db); const acquired = lock.setNX("lock:job:42", 1, { ttl: 30_000 }); // true = you own it

// Durable task queue — retries, backoff, dead-letter const queue = createQueue(db, { maxAttempts: 3 }); queue.process("embed", async (job) => await embed(job.payload.text), { concurrency: 4 });

// Scheduled work — persisted across restarts const cron = createCron(db); cron.schedule("nightly-cleanup", "0 3 * * *", () => queue.add("cleanup", {}));

No Docker. No .env files with connection strings. No Redis setup. One file, node serve.mjs.

Real-time reactivity — local Firebase

collection.watch() delivers a live result set that re-emits only when a relevant change lands. Row-level matching, no spurious re-renders. Works with changes from @monlite/sync too.

// Initial snapshot → then re-fires only when an admin is added/changed/removed const stop = users.watch( { where: { roles: { has: "admin" } } }, ({ results, added, removed }) => renderAdminList(results), );

Pair with @monlite/sync and your local database becomes a live replica of MongoDB or PostgreSQL — fully offline capable, syncs when reconnected.

A proper query language — not a toy

monlite has a Mongo/Prisma-style query API. Typed collections get compile-time checked where/orderBy and return types that narrow with select.

interface Order { customerId: string; items: { sku: string; qty: number }[]; status: "pending" | "shipped" | "returned"; total: number; }

const orders = db.collection("orders");

// elemMatch — query inside arrays of objects await orders.findMany({ where: { items: { elemMatch: { sku: "WIDGET-A", qty: { gte: 5 } } } }, });

// Regex — case-insensitive pattern matching await orders.findMany({ where: { status: { regex: "^pend", mode: "insensitive" } } });

// Aggregation pipeline — GROUP BY, $lookup joins, $unwind await orders.aggregate([ { $match: { status: "shipped" } }, { $group: { _id: "$customerId", spent: { $sum: "$total" } } }, { $sort: { spent: -1 } }, { $limit: 10 }, ]);

// Atomic async transactions — await inside, all-or-nothing await db.transactionAsync(async (tx) => { const account = await tx.findFirst({ where: { _id: "acc-1" } }); if (account.balance = 22.5) npm install @monlite/core

For Node 18/20, or to avoid the experimental flag:

npm install @monlite/core better-sqlite3

Add packages as you need them:

npm install @monlite/vector # semantic search npm install @monlite/fts # full-text search npm install @monlite/kv # cache + locks npm install @monlite/queue # job queue npm install @monlite/cron # scheduler npm install @monlite/sync # cloud sync (MongoDB / PostgreSQL / MySQL) npm install @monlite/wasm # browser support

Why not just use…

SQLite directly? You could — but you'd be writing the document layer, the query translator, the FTS integration, the vector extension wiring, the change feed, the sync engine, and all the TypeScript types yourself. monlite is that work, already done and tested.

MongoDB + Redis + Qdrant? For local / edge / desktop / single-machine work, you're paying the operational cost of three separate services to solve one problem. monlite puts them all in one file, with one API, and zero infrastructure.

Firebase / Supabase? Great for shared cloud state. Not so great when you need to work offline, ship a CLI tool, build a desktop app, or keep data on-device. monlite is local-first; @monlite/sync handles the cloud part when you need it.

Documentation

Full guide at the documentation site:

Getting started · Core API

Packages: vector · fts · kv · queue · cron · sync · wasm

Guides: AI-agent backend · production · migrations · custom sync adapters

Reference: file format · Python · benchmarks

Runnable demos are in examples/.

Status

Production-ready and published. Current versions: @monlite/core 2.6.2, @monlite/sync 1.3.0, @monlite/vector 0.5.1, @monlite/fts 0.5.0, @monlite/kv 0.2.0, @monlite/queue 0.3.0, @monlite/cron 0.1.1, @monlite/wasm 0.2.2. The 2.x API is frozen.

Vector and full-text indexing are linear at scale — bulk-ingesting 100K vectors or documents stays fast (no O(n²) re-index), so it comfortably backs 10K–100K-document RAG.

The live demo showcases every package — documents, full-text (FTS5), vector/semantic search, cache, queue, and cron — running 100% in the browser on SQLite-WASM, with semantic embeddings computed on-device via Transformers.js.

The Python port (pip install monlite) currently ships documents + kv, with the rest of the package family in progress.

License

MIT

About

Documents, vectors, cache, queue, and cron in one SQLite file. The local backend for AI agents.

monlite.dev

Topics

typescript

sqlite

full-text-search

document-database

embedded-database

job-queue

ai-agents

rag

vector-search

local-first

Resources

Readme

License

MIT license

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

19 stars

Watchers

0 watching

Forks

2 forks

Report repository

Releases

No releases published

Packages 0

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

TypeScript 93.0%

Python 5.7%

JavaScript 1.3%