██████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ███████╗ ██████╗ ██╗ ██╗███████╗
██╔══██╗██║ ██║██╔════╝██╔═══██╗██║ ██╔════╝ ██╔═══██╗██║ ██║██╔════╝
██████╔╝███████║██║ ██║ ██║██║ █████╗ ██║ ██║██║ █╗ ██║█████╗
██╔══██╗██╔══██║██║ ██║ ██║██║ ██╔══╝ ██║ ██║██║███╗██║██╔══╝
██║ ██║██║ ██║╚██████╗╚██████╔╝███████╗███████╗ ╚██████╔╝╚███╔███╔╝███████╗
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═════╝ ╚══╝ ╚══╝ ╚══════╝
The AI-Native Backend-as-a-Service Platform
Blazing-fast backend development with Sub-100ms Local Dev — Built on Bun + SQLite, deploy anywhere with PostgreSQL support.
Database • Authentication • Realtime Subscriptions • Storage • Serverless Functions • Vector Search
Last Updated: 2026-03-30
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✦ BETTERBASE ARCHITECTURE ✦ │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────────────────────┐ ┌─────────┐ │
│ │ Frontend │ │ │ │ │ │
│ │ (React, Vue, │──────────▶│ BETTERBASE CORE │──────────▶│ DB │ │
│ │ Mobile, │ │ │ │ SQLite/ │ │
│ │ Svelte) │ │ Auth │ Realtime │ Storage │ │ Postgres│ │
│ └──────────────┘ │ RLS │ Vector │ Fns │ └─────────┘ │
│ └──────────────────────────────┘ │ │
│ │ │ │
│ ┌──────▼──────┐ │ │
│ │ IaC │◀──── (Infrastructure as Code) │ │
│ │ Layer │ │ │
│ │ Convex-ish │ │ │
│ └───────────┘ │ │
│ │ │
│ ┌──────▼──────┐│
│ │ Inngest ││
│ │ Workflows ││
│ └────────────┘│
└─────────────────────────────────────────────────────────────────────────────────────────────┘
| TraditionalBAAS | Betterbase | |
|---|---|---|
| ⚡ | Slow local dev | Sub-100ms dev with Bun + SQLite |
| 🗄️ | Black box DB | Full PostgreSQL with raw SQL access |
| 🔍 | Basic search | Full-text + Vector search built-in |
| 🚀 | Cloud lock-in | Self-host anywhere with Docker |
| 📊 | Limited analytics | Full observability out of the box |
| 🔐 | Closed source | 100% open source - deploy anywhere |
# Install the CLI
bun install -g @betterbase/cli
# Create a new project (IaC mode - recommended)
bb init my-app
cd my-app
bun install
bb devYour project structure:
my-app/
├── betterbase/
│ ├── schema.ts # Define tables (Convex-style)
│ ├── queries/ # Read functions (auto-subscribe)
│ ├── mutations/ # Write functions (transactions)
│ └── actions/ # Side-effects (scheduled, HTTP)
├── betterbase.config.ts # Optional config
└── package.json
Edit betterbase/schema.ts:
import { defineSchema, defineTable, v } from "@betterbase/core/iac"
export const schema = defineSchema({
users: defineTable({
name: v.string(),
email: v.string(),
}).uniqueIndex("by_email", ["email"]),
posts: defineTable({
title: v.string(),
content: v.string(),
published: v.boolean(),
authorId: v.id("users"),
}).index("by_author", ["authorId"]),
})// betterbase/queries/posts.ts
import { query } from "@betterbase/core/iac"
export const listPosts = query({
args: { published: v.optional(v.boolean()) },
handler: async (ctx, args) => {
return ctx.db.query("posts")
.filter("published", "eq", args.published ?? true)
.order("desc")
.take(50)
},
})// betterbase/mutations/posts.ts
import { mutation } from "@betterbase/core/iac"
export const createPost = mutation({
args: {
title: v.string(),
content: v.string(),
authorId: v.id("users"),
},
handler: async (ctx, args) => {
return ctx.db.insert("posts", {
...args,
published: false,
})
},
})bb devYour backend runs at http://localhost:3000. The dashboard is at http://localhost:3001.
| Feature | Description |
|---|---|
| IaC Layer | Convex-inspired: define schema + functions in TypeScript |
| Auto-Realtime | Queries auto-subscribe to changes |
| Type Safety | Full TypeScript inference, no code generation needed |
| Migrations | Automatic diff + apply on bb dev |
| Raw SQL | ctx.db.execute() for complex queries |
| Full-Text Search | PostgreSQL GIN indexes via ctx.db.search() |
| Vector Search | pgvector + HNSW for embeddings |
| Serverless Functions | Deploy custom API functions |
| Storage | S3-compatible object storage |
| Webhooks | Event-driven with signed payloads |
| Background Jobs | Durable workflows via Inngest |
| RLS | Row-level security policies |
| Branching | Preview environments per branch |
| Feature | Convex | Betterbase |
|---|---|---|
| Database | Black box | Full PostgreSQL |
| Raw SQL | Not available | ctx.db.execute() |
| Full-Text Search | Not built-in | PostgreSQL FTS |
| Vector Search | Limited | pgvector + HNSW |
| Self-Hosting | Not supported | Docker to your infra |
| Migration | — | bb migrate from-convex |
Betterbase gives you Convex simplicity with full SQL power.
Betterbase uses Inngest for durable workflows and background jobs.
| Mode | Inngest Backend | Used By |
|---|---|---|
| Cloud | https://api.inngest.com |
BetterBase Cloud offering |
| Self-Hosted | http://inngest:8288 |
Docker deployment |
| Local Dev | http://localhost:8288 |
Development and testing |
# For local development
INNGEST_BASE_URL=http://localhost:8288
# For self-hosted production
INNGEST_BASE_URL=http://inngest:8288
INNGEST_SIGNING_KEY=your-signing-key
INNGEST_EVENT_KEY=your-event-key- Webhook Delivery: Retryable, observable webhook delivery with automatic backoff
- Notification Rules: Cron-based metric polling with fan-out notifications
- Background Exports: Async CSV export with progress tracking
Betterbase supports two patterns:
my-app/
├── betterbase/
│ ├── schema.ts # defineSchema() + defineTable()
│ ├── queries/ # query() functions
│ ├── mutations/ # mutation() functions
│ ├── actions/ # action() functions
│ └── cron.ts # scheduled functions
├── betterbase.config.ts # Optional config
└── package.json
my-app/
├── src/
│ ├── db/
│ │ ├── schema.ts # Drizzle schema
│ │ └── migrate.ts # Migration runner
│ ├── routes/ # Hono routes
│ └── functions/ # Serverless functions
├── betterbase.config.ts
└── package.json
Both patterns work together. Add betterbase/ to any existing project.
| Command | Description |
|---|---|
bb init [name] |
Create new project |
bb dev |
Start dev server |
bb iac sync |
Sync IaC schema |
bb iac analyze |
Analyze query performance |
bb migrate |
Run migrations |
bb generate types |
Generate TypeScript types |
bun add @betterbase/clientimport { createClient } from '@betterbase/client'
const client = createClient({
baseUrl: 'http://localhost:3000',
})
// Use IaC functions
const { data: posts } = await client.bff.queries.posts.listPosts({})
// Mutations
await client.bff.mutations.posts.createPost({
title: 'Hello',
content: 'World',
authorId: 'user-123',
})bb devdocker-compose up -dSee SELF_HOSTED.md for full documentation.
database: {
provider: 'neon',
connectionString: process.env.NEON_CONNECTION_STRING
}Best for edge deployments and distributed databases.
database: {
provider: 'turso',
connectionString: process.env.TURSO_DATABASE_URL,
authToken: process.env.TURSO_AUTH_TOKEN
}Best for legacy applications or MySQL preference.
database: {
provider: 'mysql',
connectionString: process.env.MYSQL_URL
}Best for serverless MySQL with branch-based schema changes.
database: {
provider: 'planetscale',
connectionString: process.env.PLANETSCALE_URL
}Initialize authentication in your project:
bb auth setupThis creates src/auth/ with default configuration.
Edit src/auth/index.ts:
import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { db } from '../db'
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'sqlite' // or 'postgres', 'mysql'
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: false
},
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET
}
},
session: {
expiresIn: 60 * 60 * 24 * 7, // 7 days
updateAge: 60 * 60 * 24 // 1 day
}
})Betterbase integrates with database RLS for secure data access:
// In your schema or via CLI
bb rls add \
--table posts \
--name users_own_posts \
--command SELECT \
--check "user_id = auth.uid()"This ensures users can only access their own data.
Your AI-powered development assistant, integrated directly into Betterbase.
Ask Deepwiki provides intelligent context for AI-assisted development:
- Smart Code Context: Automatic
.betterbase-context.jsongeneration - IaC Analysis: Understand your schema, queries, and mutations
- Query Optimization: Get recommendations for better performance
- Documentation Generation: Auto-generate docs from your code
Deepwiki Badge: The badge at the top of this README links to Ask Deepwiki, where you can chat with an AI that understands your entire Betterbase project.
- Development: Get instant answers about your IaC layer
- Debugging: Understand query behavior and optimization
- Onboarding: New team members can ask about your architecture
- Refactoring: Get AI suggestions for improving your code
We welcome contributions! Please follow these steps:
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/betterbase.git - Install dependencies:
bun install - Create a branch:
git checkout -b feature/my-feature
# Install dependencies
bun install
# Build all packages
bun run build
# Run tests
bun test
# Run linting
bun run lintbetterbase/
├── apps/
│ └── test-project/ # Example/test project
├── packages/
│ ├── cli/ # @betterbase/cli
│ ├── client/ # @betterbase/client
│ └── core/ # @betterbase/core
├── templates/ # Project templates
└── turbo.json # Turborepo configuration
We use Biome for code formatting and linting:
# Format code
bun run format
# Lint code
bun run lint
# Fix auto-fixable issues
bun run lint:fix# Run all tests
bun test
# Run tests for specific package
bun test --filter=@betterbase/cli
# Run tests in watch mode
bun test --watchFollow Conventional Commits:
feat: add new feature
fix: resolve bug
docs: update documentation
refactor: restructure code
test: add tests
chore: maintenance
- Push your branch:
git push origin feature/my-feature - Open a Pull Request
- Fill out the PR template
- Wait for review
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at conduct@betterbase.io. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
All notable changes to this project will be documented in this section.
- AI Context Generation: Automatic
.betterbase-context.jsongeneration for AI-assisted development - Branch Management: New
bb branchcommand for creating isolated preview environments - Vector Search: pgvector-powered similarity search with embeddings support
- Auto-REST: Automatic CRUD route generation from Drizzle schema
- Enhanced CLI: Added 12 commands including branch, webhook management, and storage operations
- Updated copyright year to 2026
- Improved documentation with Last Updated timestamp
- Verified all features against current codebase structure
- Removed deprecated @betterbase/shared package references
- Improved webhook signature verification
- Enhanced RLS policy engine
Betterbase is open source under the MIT License.
MIT License
Copyright (c) 2026 Betterbase
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
| Resource | Link |
|---|---|
| Discord | Discord |
| GitHub Issues | GitHub Issues |
| Resource | Link |
|---|---|
| GitHub | GitHub |
| Contributing Guide | CONTRIBUTING.md |
| Good First Issues | Good First Issues |
Built with ❤️ by Weroperking
Website • Documentation • Discord • GitHub • Twitter