PocketBase — Backend in One File for AI Apps
Open-source backend with database, auth, file storage, and admin UI in a single executable. Perfect for AI app backends. 57K+ stars.
What it is
PocketBase is an open-source backend written in Go that packages a SQLite database, user authentication, file storage, and a real-time admin dashboard into a single executable file. You download one binary, run it, and get a fully functional backend with REST and real-time APIs.
It targets indie developers, AI app builders, and small teams who need a backend fast without managing separate database servers, auth providers, and file storage services. It works well as a backend for AI-powered apps, chatbots, and prototypes.
How it saves time or tokens
PocketBase eliminates infrastructure setup. Instead of configuring a database server, setting up an auth service, and wiring file uploads, you run one command and start building your frontend or AI logic. The admin UI lets you create collections (tables), define fields, and manage records visually. For AI apps, this means you can store conversation logs, user data, and model outputs without writing backend code.
How to use
- Download and start PocketBase:
# Download for your platform from GitHub releases
wget https://github.com/pocketbase/pocketbase/releases/latest/download/pocketbase_0.25_linux_amd64.zip
unzip pocketbase_0.25_linux_amd64.zip
./pocketbase serve
- Open the admin UI at
http://127.0.0.1:8090/_/and create your first collection.
- Use the REST API from your app:
# Create a record
curl -X POST http://127.0.0.1:8090/api/collections/messages/records \
-H 'Content-Type: application/json' \
-d '{"text": "Hello from AI", "role": "assistant"}'
Example
// Using PocketBase JavaScript SDK
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
// Authenticate a user
await pb.collection('users').authWithPassword('user@example.com', 'password');
// Store an AI conversation
await pb.collection('conversations').create({
user_id: pb.authStore.model.id,
prompt: 'Explain recursion',
response: 'Recursion is when a function calls itself...',
model: 'claude-sonnet',
tokens_used: 245
});
// Query with filters
const recent = await pb.collection('conversations').getList(1, 10, {
sort: '-created',
filter: 'tokens_used > 100'
});
Related on TokRepo
- AI tools for databases -- Backend and database tools for AI applications
- Self-hosted tools -- Self-hostable infrastructure for AI
Common pitfalls
- PocketBase uses SQLite, which handles reads well but has write concurrency limits. For apps with heavy concurrent writes, consider PostgreSQL-backed alternatives.
- Scaling beyond a single server requires manual replication. PocketBase is designed for single-instance deployment, not horizontal scaling.
- File storage is local by default. For production, configure S3-compatible storage to avoid data loss if the server disk fails.
Frequently Asked Questions
PocketBase works well for small to medium production apps. It uses SQLite internally, which handles thousands of concurrent reads efficiently. Write-heavy workloads may hit SQLite's single-writer limitation. For most AI apps, chatbots, and tools with moderate traffic, PocketBase is production-ready.
Yes. PocketBase has built-in real-time event streaming over Server-Sent Events (SSE). You can subscribe to collection changes from the client SDK and receive create, update, and delete events instantly. This is useful for live chat interfaces and real-time AI response streaming.
PocketBase stores everything in a single SQLite file (pb_data/data.db). You can back it up by copying this file while PocketBase is running -- SQLite supports safe concurrent reads. The admin UI also has a backup export feature. For automated backups, schedule a cron job to copy the database file.
Yes. PocketBase can be used as a Go framework where you import it as a package and add custom routes, hooks, and middleware. You can also write JavaScript hooks that run on record create, update, or delete events. This lets you add AI processing pipelines triggered by database changes.
PocketBase provides official SDKs for JavaScript/TypeScript and Dart/Flutter. The JavaScript SDK works in Node.js, browsers, and frameworks like React, Vue, and Svelte. Community SDKs exist for Python, Go, and other languages. All SDKs support auth, CRUD, real-time subscriptions, and file uploads.
Citations (3)
- PocketBase GitHub Repository— PocketBase is an open-source Go backend with embedded SQLite
- PocketBase Documentation— PocketBase provides REST API, real-time subscriptions, auth, and file storage
- SQLite Documentation— SQLite handles concurrent reads efficiently but has single-writer limitations
Related on TokRepo
Source & Thanks
Created by Gani Georgiev. Licensed under MIT.
pocketbase — ⭐ 57,300+
Thanks to Gani Georgiev for building the simplest path from zero to production backend.