System Documentation

ThebeDB

Immutable Dual-Store Database for Blockchain Applications

Generated March 20, 2026 Go 1.25 BadgerDB · SQLite / PostgreSQL JupiterMetaLabs

🗄️ What is ThebeDB?

ThebeDB is a purpose-built database system for blockchain applications, developed by JupiterMetaLabs. It solves a problem that most blockchain systems face: you need two completely different databases at the same time — one to store data permanently and tamper-proof (like a ledger), and another to make that data easy to search and analyse (like a regular database). Most systems bolt these two things together awkwardly. ThebeDB handles both in a single, unified package.

Think of it like a bank's bookkeeping system: transactions are written into a permanent, append-only ledger that can never be altered, but a separate set of indexed records lets accountants run reports, look up accounts, and answer questions quickly. ThebeDB provides exactly this — writes go to an immutable log, reads come from a smart SQL mirror that keeps itself up to date automatically.

What It Does

Immutable Ledger

Every piece of data written to ThebeDB is stored permanently in an append-only log. Nothing can be edited or deleted — exactly what blockchain integrity requires.

SQL Query Layer

A background process automatically mirrors the ledger into a structured SQL database (SQLite or PostgreSQL), so you can run complex queries, joins, and analytics without touching the immutable store.

Self-Healing Projections

If the SQL mirror is ever deleted or corrupted, ThebeDB can rebuild the entire queryable state from scratch by replaying the immutable log. The source of truth is always the ledger.

Blockchain Explorer API

A built-in REST API lets any browser or application browse blocks, look up transactions, and inspect account activity — all in real time.

Backpressure Control

If the system falls behind processing new data, ThebeDB automatically slows down incoming writes rather than crashing — keeping the system stable under load.

Pluggable Profiles

The system supports swappable "profiles" — modules that define how raw blockchain data is interpreted and stored in SQL. This makes it adaptable to different chain formats and business rules.

⚙️ How It Works (Plain English)

Here is the lifecycle of data through ThebeDB, step by step:

1

Data Arrives

A blockchain node sends a new block (or transaction) to ThebeDB. This could be via a direct Go function call or through the system's API.

2

Backpressure Check

Before accepting the write, ThebeDB checks whether the query mirror is keeping up. If it's too far behind, the write is rejected with a "system overload" signal so the caller knows to slow down and retry.

3

Written to the Immutable Log

If all is well, the data is serialized and appended to the KV ledger (BadgerDB) with a unique sequence number. This is extremely fast — BadgerDB is optimized for high-throughput writes. The data is now permanently recorded.

4

The Projector Wakes Up

A background worker (the Projector) continuously polls the ledger for new entries. Every 100 ms it checks whether new records have arrived since it last ran.

5

Data is Transformed into SQL

The Projector reads the new record, passes it through the active "profile" (the jmdt_explorer profile for JupiterMetaDN), which parses the raw bytes into structured blocks, transactions, and participants, then inserts them into SQL tables inside a single database transaction.

6

Available for Queries

Within milliseconds, the new block is queryable via the Explorer REST API. A web dashboard (React) and any external client can now look it up by block number, hash, transaction hash, or account address.

🔗 What It Connects To

  • 💎
    BadgerDB Embedded key-value store that serves as the immutable ledger. Runs inside the same process — no separate server needed.
  • 🗃️
    SQLite (default) or PostgreSQL The queryable SQL mirror. SQLite runs in the same process; PostgreSQL is available for production deployments needing multi-client access.
  • 🌐
    Explorer Web UI A React-based frontend (built with Vite) served directly by ThebeDB at port 8080. Lets users browse blocks, transactions, and accounts in a browser.
  • 📊
    Prometheus (optional) Docker Compose includes a Prometheus instance for collecting metrics and monitoring system health in production.
  • 📡
    OpenTelemetry Distributed tracing and logging infrastructure wired in via the ion logging library and OTLP exporters, for observability in complex deployments.

👥 Who Should Care About What

Role What matters to you
Product / Business ThebeDB provides a tamper-proof audit trail for all blockchain activity, plus a live explorer interface for ops teams and end users. Data is never lost — even if the query database is wiped, everything can be recovered from the ledger.
Blockchain Engineers You interact with the db.Append(record) API to submit blocks and transactions. Watch for ErrSystemOverload and implement exponential backoff. The CQRS separation means writes never block on query performance.
Backend / Platform Engineers The Go library exposes clean interfaces for the KV store, SQL engine, and profile system. Profiles are the main extension point — you can add new ones to support different chain namespaces without touching core code.
DevOps / Infrastructure A docker-compose.yml provides PostgreSQL and Prometheus. The binary is configured via a simple YAML file. For production, switch the SQL driver from SQLite to PostgreSQL for concurrent read access.
Frontend / UI Five REST endpoints under /api/ expose blocks, transactions, and accounts as JSON. All responses are CORS-enabled. The React web UI in /web is a working reference implementation you can extend.