Technical guides, client SDK references, and runnable recipes for all 8 programmable cloud subsystems: compute, microVMs, PostgreSQL 17, maps, auth, storage, transactional mail, and AI agent MCP.
Explore complete ingress specifications, Model Context Protocol integration, and multi-language SDK recipes.
PGB Hub unifies compute, microVMs, databases, geospatial maps, auth, storage, transactional mail, and AI agents into a single sovereign control plane under https://<project>.pgbhub.app.
import { createClient } from "@pgbox/client";
// One client connects to all 8 cloud services:
export const pgb = createClient({
endpoint: process.env.PGB_ENDPOINT || "https://my-app.pgbhub.app",
apiKey: process.env.PGB_API_KEY
});
// Access compute, database, auth, storage, maps & mail with zero glue code:
const user = await pgb.auth.getUser();
const orders = await pgb.table("orders").find({ user_id: user.id });Deploy Node.js and Python functions with sub-10ms cold starts, automatic HTTP routing, cron schedules, and database change listeners.
// functions/payments/create-order.ts
import { FunctionContext, FunctionEvent } from "@pgbox/functions";
export async function handle(event: FunctionEvent, ctx: FunctionContext) {
const { user } = ctx.auth;
const { items, total } = event.body;
// Direct transactional database access with automatic RLS scoping
const order = await ctx.db.table("orders").create({
user_id: user.id,
items,
total,
status: "CONFIRMED"
});
// Dispatch transactional email
await ctx.mail.send({
to: user.email,
subject: `Order #${order.id} Confirmed`,
html: `<p>Your order of $${total} is confirmed!</p>`
});
return { statusCode: 200, body: { orderId: order.id } };
}Run full Docker OCI containers with hardware cgroups v2 isolation and CRIU memory snapshots that scale to 0 RAM when idle.
// pgb.services.yml
version: "1.0"
services:
api:
image: ghcr.io/ridemesh/ridemesh-api:v2.4.1
port: 5010
env:
- NODE_ENV=production
- DATABASE_URL=postgresql://app:token@db.pgbhub.app:5433/db?sslmode=require
scale:
min_replicas: 0 # Scales to 0 MB RAM after 5m idle via CRIU snapshot
max_replicas: 10
target_cpu: 70%100% Mapbox-compatible vector/raster tiles, Search Box autocomplete, reverse geocoding, and turn-by-turn routing with $0 Mapbox API fees.
// Flutter / Dart (MapLibre / RideMesh integration)
import 'package:maplibre_gl/maplibre_gl.dart';
class RideMapWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MapLibreMap(
styleString: "https://<project>.pgbhub.app/maps/styles/v1/mapbox/streets-v12",
initialCameraPosition: CameraPosition(
target: LatLng(37.7749, -122.4194),
zoom: 14.0,
),
);
}
}Complete identity management supporting 6-digit passwordless OTP, magic links, JWT session verification, and automatic PostgreSQL Row-Level Security.
import { createClient } from "@pgbox/client";
const pgb = createClient({ endpoint: "https://<project>.pgbhub.app" });
// 1. Request 6-Digit Passwordless OTP via email
await pgb.auth.sendOtp({ email: "driver@ridemesh.com" });
// 2. Verify OTP & Obtain Session JWT
const { session, user } = await pgb.auth.verifyOtp({
email: "driver@ridemesh.com",
token: "849201"
});
console.log("Logged in user:", user.id, "JWT:", session.accessToken);
// 3. PostgreSQL RLS automatically filters rows for this user
const myRides = await pgb.table("rides").find(); // Returns only rides owned by user.idS3-compatible bucket storage with 15-minute presigned upload URLs, media streaming, and edge CDN distribution.
import { createClient } from "@pgbox/client";
const pgb = createClient({ endpoint: "https://<project>.pgbhub.app", apiKey: "..." });
// 1. Generate 15-minute secure presigned upload URL
const { uploadUrl, fileKey } = await pgb.storage.getPresignedUploadUrl({
path: "avatars/driver_984.jpg",
contentType: "image/jpeg",
expiresInSeconds: 900 // 15 mins
});
// 2. Upload file directly from browser / mobile client
await fetch(uploadUrl, {
method: "PUT",
headers: { "Content-Type": "image/jpeg" },
body: fileBlob
});
// 3. Obtain public CDN delivery URL
const cdnUrl = pgb.storage.getPublicUrl(fileKey);Enterprise email dispatch with automated AWS SES bounce and complaint handling, template rendering, and reputation monitoring.
import { createClient } from "@pgbox/client";
const pgb = createClient({ endpoint: "https://<project>.pgbhub.app", apiKey: "..." });
// Send transactional email with deliverability tracking
const res = await pgb.mail.send({
to: "customer@domain.com",
subject: "Your Ride Receipt #9842",
html: "<h1>Thanks for riding with RideMesh</h1><p>Total: $24.50</p>",
trackOpens: true,
trackClicks: true
});
console.log('Message Dispatched:', res.messageId);Connect Claude Desktop, Cursor IDE, and autonomous AI agents directly to your live database schemas and cloud APIs via Model Context Protocol.
// Add to claude_desktop_config.json or cursor.json:
{
"mcpServers": {
"pgbox": {
"command": "npx",
"args": ["-y", "@pgbox/mcp-server"],
"env": {
"PGB_ENDPOINT": "https://<project>.pgbhub.app",
"PGB_API_KEY": "pgb_live_secret_token"
}
}
}
}Store schema-free JSON document collections with automated GIN path indexing, PostGIS 3.4 geospatial queries, and pgvector embeddings.
-- 1. Query JSONB document collections with GIN index acceleration
SELECT id, data->>'name' AS venue, data->'pricing'->>'tier' AS tier
FROM venues
WHERE data @> '{"status": "OPEN", "category": "restaurant"}'::jsonb;
-- 2. PostGIS 3.4 Spatial Nearest Neighbor Calculation
SELECT id, data->>'name' AS name,
ST_Distance(geom::geography, ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 4326)::geography) AS distance_meters
FROM venues
WHERE ST_DWithin(geom::geography, ST_SetSRID(ST_MakePoint(-122.4194, 37.7749), 4326)::geography, 5000)
ORDER BY distance_meters ASC
LIMIT 10;Handle thousands of concurrent clients with built-in PgBouncer transaction pooling and automated daily AES-256-GCM encrypted snapshot vaults.
-- Connect via standard psql CLI with mandatory TLS 1.3 encryption
psql "postgresql://app_user:token@db.pgbhub.app:5433/production_db?sslmode=require"
-- PgBouncer is pre-configured on port 6543 for massive serverless concurrency
SHOW POOLS;