Squish the Stack

Rampart is a complete JavaScript application platform — HTTP server, SQL database with full-text search, vector search, key-value store, networking, crypto, and more — all in a single, tiny footprint. This entire site runs on a Raspberry Pi Zero (the original $5 one). It's fast, portable, and free to use, modify, and redistribute.

Install the latest Rampart:

$ curl -fsSL https://get.rampart.dev/ | sh

macOS, Linux, Raspberry Pi & FreeBSD — other download options →

We're not kidding about the tiny footprint. Here's the Rampart HTTP server with many modules loaded:

Rampart RAM usage screenshot

Drop a module into the standard web server and you have a hybrid search API over your own data — keywords and meaning fused in a single SQL statement, no external services. Code at load time runs once; the exported function runs per request.

// run once: rampart build.js
var Sql    = require("rampart-sql");
var totext = require("rampart-totext");

var webRoot = "/path/to/web_server";
var root    = webRoot + "/html";                       // your document root
var sql     = Sql.connect(webRoot + "/data/docs", true);   // create the db

// one row per document: Text is the keyword side, Vec the vector side
sql.exec("create table docs (Url varchar(96), Title varchar(64), " +
         "Text varchar(16000), Vec varvecF16)");

// the embedding model -- one .gguf file, no service to run
sql.set({ llamaEmbed: webRoot + "/data/models/all-minilm-l6-v2_f16.gguf" });

rampart.utils.walkDir(root, function (path, type) {
    if (type !== "file" || !/\.(html?|pdf|docx?|txt)$/i.test(path)) return;
    var text  = totext.convertFile(path);
    var title = path.replace(/.*\//, "");
    // chunkembed() splits the document and embeds every chunk as
    // "title + chunk" -- all of them stored in this one row
    sql.exec("insert into docs values (?, ?, ?, chunkembed(?, '', ?))",
        [ path.slice(root.length), title, text, text, title ]);
});

// fusion ranks two candidate lists, so each side gets an index.
// 'hnsw' works at any size; the default (IVFPQ) trains on ~10k+ vectors.
sql.exec("create metamorph inverted index docs_Text_mmix on docs(Text)");
sql.exec("create vector index docs_Vec_vx on docs(Vec) with backend 'hnsw'");
// place in web_server/apps -- available at http://localhost:8088/apps/search.json in default server
var Sql = require("rampart-sql");
var sql = Sql.connect(serverConf.dataRoot + "/docs");

// the same model that built the table, loaded once per thread
sql.set({ llamaEmbed: serverConf.dataRoot + "/models/all-minilm-l6-v2_f16.gguf" });
sql.set({ likeprows: 100, likevRows: 300 });   // candidates fused per side

// the above code runs once; the module.exports function runs on each request
module.exports = function (req) {
    var q = req.query.q;
    // One statement, both retrievers: 'likep' matches keywords, 'likev'
    // embeds the query and matches meaning, and the engine merges the two
    // ranked lists by Reciprocal Rank Fusion -- rows arrive deduplicated
    // and already in fused order, so no ORDER BY.  abstract() snips the
    // chunk that won; $krank and $vrank are each side's own score, and a
    // 0 there means the other side is what found this row.
    var res = sql.query(
        "select $rank score, $krank krank, $vrank vrank, Url, Title, " +
        "abstract(Text, 400, 'querybest', ?, Vec) Snip " +
        "from docs where Text likep ? or Vec likev ?",
        [ q, q, q ], { maxRows: 20 });
    return { json: res.rows };
};

// $ curl 'http://localhost:8088/apps/search.json?q=how+to+cache+query+results'
//   [{"score":32788,"krank":768,"vrank":57754,"Url":"/caching.html",
//     "Title":"Query result caching","Snip":"...Rampart caches prepared..."},
//    {"score":16129,"krank":0,"vrank":14323,"Url":"/fulltext.html", ...}]

The usual stack

  • nginx — reverse proxy
  • Node / Python — app server
  • PostgreSQL — database
  • Elasticsearch — search
  • Redis — cache

5+ services, GBs of RAM, containers to wire together — plus a node_modules of 1,000+ third-party packages to install, lock, and audit.

Rampart

  • one install
  • HTTP · SQL · full-text
  • vector · key-value · crypto
  • threads · and more

One process, tens of MB — get more done with less hardware. A curated, first-party module set: no node_modules, no lockfile, no supply chain.

What's Inside

Full-Text Search with SQL

Powered by Texis, the same engine behind eBay's auction search and hundreds of other large sites. Unlike Elasticsearch, there's no separate search cluster to run — full-text search lives inside the SQL database, with real-time indexing and concept-based natural-language queries. Includes a CSV parser for easy data migration.

docs →

Vector & Semantic Search New

Vector indexes built right into rampart-sql: FAISS (IVFPQ) and usearch (HNSW) power approximate nearest-neighbor search over millions of vectors. Generate embeddings right in SQL with embed() via rampart-langtools (llama.cpp) — semantic search and RAG with no external services.

docs →

HTTP, HTTPS & WebSockets

Multi-threaded server built on libevhtp and libevent2. Static-content performance is competitive with nginx — in a single process that also runs full-text search, websockets and a full range of applications while consuming considerably less resources than Node.

docs →

Document Text Extraction New

Extract plain text from DOCX, PPTX, XLSX, ODT, EPUB, PDF, RTF, LaTeX, man pages, HTML, Markdown, and more. Transparent gzip decompression and magic-byte detection. Built for feeding search engines and semantic pipelines.

docs →

Threading

True multi-threaded JavaScript. Each thread runs its own isolated interpreter. Variables are shared via a clipboard with async callbacks — as easy as setTimeout() but actually parallel. Real OS threads on every core, so CPU-bound work runs in parallel without blocking the event loop — with your globals already in scope, no worker setup.

docs →

Batteries-Included Utilities

A deep, C-backed standard library (rampart-utils): a powerful printf with ANSI color, JSON, base64 and URL/HTML encoding; POSIX file and process I/O (exec, fork, daemon, file watching); date/timezone parsing, hashing, URL parsing, buffers, and a scriptable REPL.

docs →

… and everything else you'd expect

External Projects
  • Langtools — AI embeddings, FAISS vector indexing, and tokenization via llama.cpp*
  • Webview — Cross-platform desktop apps with HTML/CSS/JS and native rendering*
  • Rampart Iroh — P2P networking with encrypted QUIC, pub/sub, and blob transfer*
  • Iroh Webproxy — Expose remote web servers locally via encrypted P2P tunnels*
  • Lang Derivs — Suffix matching rules for multilingual full-text search**
  • WebDAV — Full WebDAV server with web file manager, media playback, and document editing
  • Webshield — Text and image obfuscation to protect content from scraping
  • Self-Hosted Search — Personal search engine from your browsing history via browser extension
  • Wikipedia Search — Full-text keyword and semantic search across Wikipedia articles
  • Rampart Docs — Documentation source with integrated search and typeahead

* included in binary distribution   ** partially included (English only) with script to download more.

Why Rampart?

The modern web stack is heavy. By the time you've configured Node, a database, a search engine, and a cache layer, you've burned a day (or more) and a pile of RAM. We wanted something different — a single download that gives you SQL with full-text search, an HTTP server, a key-value store, crypto, threading, and everything else you need to build real applications. Setup measured in minutes, not days.

We chose the Duktape JavaScript engine over V8 because V8 is a RAM and CPU pig. Our philosophy: do everything difficult in C and let JavaScript be the fun-glue. Nearly every module is coded in C, making the whole thing extremely portable. We include a fast transpiler as well as Babel so you get ES2015+ syntax automatically transpiled behind the scenes.

User machines, phones, and IoT devices need to serve their primary purpose without impediment. Rampart stays out of the way. Dedicate a machine or cluster to a Rampart task and you'll get a lot more done with a lot less investment.

Who Are We?

Moat Crossing Systems LLC — a couple of guys who between them have built software that's served many billions of pages of database-backed content on the internet. It started in January 2020 with a phone call where we were complaining about how un-fun web development had become and how resource-heavy everything seemed. Someone said: "If we could full-text index Wikipedia and serve it on a Raspberry Pi Zero, we'd have something unique." So that's what we did.

We hope you'll give it a try. Reach out here or at if you have questions.

The Raspberry Bush

Here's our fancy server farm before it was racked at the ISP. Four Pi Zeros (mirrors of each other, just in case) and two Pi 4s for faster dev builds. The bush sits behind Nginx on an old Xeon for certificate management.

Raspberry Pi server farm

We have no particular bias toward the Pi. The whole point is to demonstrate how much Rampart can do with minimal resources — so you can extrapolate how fast it'll be on real hardware.

         |>>            |>>
       __|__          __|__
      \  |  /         \   /
       | ^ |          | ^ |
     __| o |__________| o |__
    [__|_|__|(rp)|  | |______]
____[|||||||||||||__|||||||||]____
RAMPART