Rustica Engine is a PostgreSQL extension that allows you to run WebAssembly modules in the database securely, turning your database into an API server.
This project is a work in progress and not ready for production use.
- Fast: AoT-compiled WASM (by WAMR/LLVM) and prepared queries
- Secure: strictly sandboxed in bgworker processes
- Native: PostgreSQL types/Datums directly in the guest
- Zero-Copy: operate on network buffers and database pages
Rustica Engine does not use WASI or Component Model, but defines a custom set of FFIs at a finer granularity, providing optimized bindings for various PostgreSQL data types and functions.
Currently, the following programming languages can generate WebAssembly modules suitable for the Rustica Engine:
- Rustica (using MoonGRES backend)
- MoonBit (via MoonGRES extension)
Rustica Engine is also packaged as a standalone command-line application, statically linked with PostgreSQL backend code, which can run the same WebAssembly programs without starting a database server. This is particularly useful for debugging and testing.
This project is configured with a modified Meson, built by uv, and uses Ninja
as the build system. The Makefile provides some convenient command wrappers.
-
Install system dependencies (Arch Linux)
$ sudo pacman -S make gcc ninja uv llvm18 bison flex -
Build extension and run the dev Postgres:
$ make $ make run
-
Install MoonGRES:
$ curl ...TBD... | sh -
Replace the
rustica-enginebundled with MoonGRES with the one freshly built:$ ln -sf $(pwd)/install/bin/rustica-engine ~/.moon/bin/rustica-engine -
Run MoonBit core test suite:
$ cd ~/.moon/lib/core && moon test --target moongres
This project is dual-licensed under:
- Apache License, Version 2.0
- Mulan Permissive Software License, Version 2
You may choose either license to use this project freely, provided that you comply with the terms of the chosen license.
SPDX-License-Identifier: Apache-2.0 OR MulanPSL-2.0