The Serverless SQL Platform Built for Speed, Scale, and Developers.
The Serverless SQL Platform Built for Speed, Scale, and Developers.
- What is Fluxbase?
- Key Features
- API Reference
- Ingestion Worker
- Real-Time Subscriptions
- Performance
- Client Integration Examples
- Monitoring & Observability
- Project Structure
- Contributing
- License
Fluxbase is a serverless SQL platform that wraps your relational databases in a developer-friendly REST API β complete with a high-performance async ingestion pipeline and real-time subscription capabilities.
It enables multi-dialect database execution (PostgreSQL and MySQL) with strict tenant isolation and a zero-trust security model, so you can focus on building features instead of managing infrastructure.
| Feature | Description |
|---|---|
| ποΈ Native SQL Execution | Execute raw SQL on bare-metal PostgreSQL or MySQL drivers β no heavy ORM abstractions. |
| π High-Throughput Ingestion | Dedicated ingestion pipeline capable of writing 80,000+ rows/second asynchronously. |
| π‘ Real-Time Data Streaming | Stream row-level events (INSERT, UPDATE, DELETE) to clients over resilient Server-Sent Events (SSE). |
| π Security-First Architecture | Built-in AST-based SQL validation, JWT-claim RLS mapping, and scoped API key authorization. |
| π Multi-Dialect Support | First-class support for both PostgreSQL and MySQL with dialect-aware query generation. |
| π Observability | Prometheus metrics endpoint + preconfigured Grafana dashboard out of the box. |
All requests require a project-scoped API key passed via the Authorization header:
Authorization: Bearer <your-api-key>Base URL:
https://api.fluxbase.dev
Executes an arbitrary SQL query under the project's namespace.
Request Body:
{
"query": "SELECT * FROM users WHERE active = true LIMIT 5"
}Response:
{
"success": true,
"result": {
"rows": [
{ "id": "018f4a2b-...", "name": "Alice" }
],
"columns": ["id", "name"]
}
}Error Response:
{
"success": false,
"error": {
"code": "QUERY_FORBIDDEN",
"message": "DROP statements are not permitted."
}
}Queues one or more rows for high-speed asynchronous ingestion. The table is created automatically if it does not exist.
Request Body:
{
"table": "events",
"rows": [
{ "event_name": "page_view", "path": "/home" },
{ "event_name": "click", "path": "/pricing" }
]
}Response:
{
"success": true,
"queued": 2,
"batchId": "batch_12345"
}Establishes a Server-Sent Events (SSE) connection to subscribe to live database events for a project.
GET /api/realtime?projectId=<project-id>
Accept: text/event-stream
Authorization: Bearer <your-api-key>Event Payload Example:
{
"event": "INSERT",
"table": "orders",
"row": { "id": "abc123", "status": "pending" }
}Note: Clients should implement exponential backoff reconnection logic. The Fluxbase JS client SDK handles this automatically.
The ingestion worker is a standalone Python service (ingestion-worker/) that dequeues rows from a Redis buffer and streams them into the database.
- Fast COPY Protocol β Batches are streamed using
asyncpg'sCOPYprotocol instead of parameterizedINSERTstatements, maximizing throughput and eliminating per-row overhead. - Dynamic Union Schema Merging β Before importing a batch, the worker calculates the union of all keys across rows to automatically add missing columns, keeping schemas flexible.
- Strict Identifier Sanitization β Any table or column name not matching
^[a-zA-Z_][a-zA-Z0-9_]*$is rejected and quarantined to a Dead Letter Queue (DLQ), blocking SQL injection at the ingestion boundary. - Auto-Scaler β The
scaler.pymodule monitors queue depth and adjusts worker concurrency automatically.
cd ingestion-worker
pip install -r requirements.txt
python main.pyFluxbase implements low-latency SSE subscriptions with built-in connection resilience:
- Throttled Cache Invalidation β Invalidation events are throttled to prevent UI blocking under high-frequency database writes.
- Connection Resilience β Exponential backoff with jitter and automatic heartbeats ensure clients reconnect gracefully after network drops.
- Shared Event Source β A single SSE connection is reused per project across all UI components to prevent connection exhaustion on the server.
| Technique | Details |
|---|---|
| COPY vs INSERT | Bulk inserts are translated into PostgreSQL binary stream copies, eliminating SQL parsing and planning overhead. |
| Monotonic UUID v7 | Recommended for primary keys to prevent B-tree page fragmentation and index splits under heavy insert loads. |
| Async WAL Writing | Transaction-local SET synchronous_commit = off allows fast ingestion replies without waiting for WAL disk flushes. |
| Redis Queue Buffer | Incoming rows are buffered in Redis, decoupling the API from the database and absorbing traffic spikes. |
async function executeQuery<T>(sql: string): Promise<T[]> {
const response = await fetch("https://api.fluxbase.dev/api/execute-sql", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer <API_KEY>"
},
body: JSON.stringify({ query: sql })
});
const data = await response.json();
if (!data.success) throw new Error(data.error.message);
return data.result.rows;
}import requests
BASE_URL = "https://api.fluxbase.dev"
HEADERS = {"Authorization": "Bearer <API_KEY>"}
def execute_query(sql: str) -> list[dict]:
response = requests.post(
f"{BASE_URL}/api/execute-sql",
headers=HEADERS,
json={"query": sql}
)
data = response.json()
if not data["success"]:
raise RuntimeError(data["error"]["message"])
return data["result"]["rows"]
def ingest_rows(table: str, rows: list[dict]) -> dict:
response = requests.post(
f"{BASE_URL}/api/ingest",
headers=HEADERS,
json={"table": table, "rows": rows}
)
return response.json()const source = new EventSource(
`https://api.fluxbase.dev/api/realtime?projectId=${PROJECT_ID}`,
{ headers: { Authorization: "Bearer <API_KEY>" } }
);
source.onmessage = (event) => {
const { table, eventType, row } = JSON.parse(event.data);
console.log(`[${eventType}] on ${table}:`, row);
};
source.onerror = () => {
// The Fluxbase SDK handles reconnection automatically.
};The ingestion worker exposes a /metrics Prometheus endpoint tracking:
| Metric | Type | Description |
|---|---|---|
rows_ingested_total |
Counter | Total rows successfully written to the database |
rows_failed_total |
Counter | Total rows that failed processing |
rows_dlq_total |
Counter | Total rows quarantined to the Dead Letter Queue |
insert_latency_ms |
Histogram | End-to-end latency from queue dequeue to DB write |
A preconfigured Grafana dashboard is available at ingestion-worker/grafana_dashboard.json for monitoring ingest throughput, error rates, and queue latency in real time.
Alert rules are defined in ingestion-worker/alert_rules.yml.
Fluxbase/
βββ src/
β βββ app/ # Next.js App Router
β β βββ (app)/ # Authenticated dashboard views
β β βββ api/ # API routes (execute-sql, ingest, realtime)
β β βββ pricing/ # Public pricing page
β β βββ docs/ # Public documentation page
β β βββ layout.tsx # Root layout
β β βββ manifest.ts # PWA manifest
β βββ components/ # Reusable UI components
β βββ lib/ # DB pools, auth helpers, utilities
β βββ hooks/ # Custom React hooks
β βββ contexts/ # React context providers
β βββ actions/ # Next.js server actions
β βββ server/ # WebSocket & server-side modules
βββ ingestion-worker/ # Async Python ingestion service
β βββ main.py # Worker entrypoint
β βββ worker.py # Schema merger & COPY implementation
β βββ scaler.py # Auto-scaling logic
β βββ metrics.py # Prometheus metrics definitions
β βββ health.py # Health check endpoint
β βββ throttle.py # Rate-limiting / throttle logic
β βββ grafana_dashboard.json # Preconfigured Grafana dashboard
β βββ alert_rules.yml # Prometheus alert rules
β βββ Dockerfile # Container image for the worker
β βββ requirements.txt
βββ fluxbase-client/ # Official JavaScript/TypeScript SDK
β βββ src/
βββ src-tauri/ # Tauri desktop app wrapper
β βββ tauri.conf.json
βββ public/ # Static assets & PWA icons
βββ next.config.ts
βββ tailwind.config.ts
βββ package.json
βββ README.md
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feat/my-feature
- Commit your changes using Conventional Commits:
git commit -m "feat: add my feature" - Push to your fork:
git push origin feat/my-feature
- Open a Pull Request against the
mainbranch and describe your changes.
Please ensure your code passes linting (
npm run lint) and type-checking (npm run typecheck) before submitting.
This project is licensed under the MIT License β see the LICENSE file for details.
Made with β€οΈ by the Fluxbase Team