TinyBase is a lightweight, self-hosted Backend-as-a-Service (BaaS) framework designed for Python developers who want simplicity and ease-of-use.
Build and deploy production-ready APIs in minutes with:
- π Zero configuration β Get started with a single command
- π Python-first β Write server-side functions in pure Python with full type safety
- π¦ Easy deployment β SQLite database + FastAPI backend in one package
- π Built-in authentication β JWT-based auth with access and refresh tokens
- β‘ Auto-scaling functions β Isolated execution with automatic dependency management
- π¨ Modern Admin UI β Beautiful Vue 3 interface for managing everything
- π Native scheduling β Cron and interval-based task automation
- π Extensible β Hook into any part of the system with Python extensions
- Dynamic Collections β Create schema-driven collections with JSON schemas, no migrations needed
- Pydantic Validation β Automatic validation for all records with detailed error messages
- SQLite Backend β Simple, reliable, and portable β your entire database in a single file
- REST API β Auto-generated CRUD endpoints for all collections
- JWT Authentication β Secure token-based auth with access and refresh tokens
- User Management β Built-in registration, login, and password reset flows
- Role-Based Access β Admin and user roles with fine-grained permissions
- Token Revocation β Logout endpoint that invalidates all user tokens
- Rate Limiting β Configurable concurrent execution limits per user
- Type-Safe Functions β Define functions with Pydantic models for inputs and outputs
- Isolated Execution β Each function runs in its own subprocess with dependency isolation
- Automatic Dependencies β Use
uv's inline script dependencies for zero-config package management - OpenAPI Integration β All functions automatically documented and exposed as REST endpoints
- Execution Tracking β Full metadata for every function call (status, duration, errors)
- Client API β Built-in authenticated client for calling back into TinyBase
- Cron Expressions β Standard cron syntax for complex scheduling patterns
- Interval Scheduling β Run functions every N seconds, minutes, hours, or days
- One-Time Tasks β Schedule functions to run once at a specific date and time
- Timezone Support β Full timezone awareness for all scheduled tasks
- No External Dependencies β Built-in scheduler, no Redis or Celery required
- Modern Interface β Beautiful SPA built with Vue 3, Pinia, and PicoCSS
- Complete Management β Manage collections, records, users, functions, and schedules
- Function Monitoring β View execution history, errors, and performance metrics
- Settings Management β Configure all instance settings through the UI
- Responsive Design β Works perfectly on desktop and mobile
- One Command Setup β
tinybase init && tinybase serveand you're running - Hot Reload β Automatic server restart on code changes with
--reloadflag - Full OpenAPI Docs β Interactive API documentation at
/docs - CLI Tools β Generate function boilerplate, manage users, run migrations
- Docker Ready β Multi-stage Dockerfile included for production deployments
- Environment-Based Config β Configure via
tinybase.tomlor environment variables
Using uv (recommended):
uv add tinybaseUsing pip:
pip install tinybaseRequirements:
- Python 3.11 or higher
- No additional dependencies required for basic usage
1. Initialize your project:
tinybase init --admin-email admin@example.com --admin-password admin123This creates:
tinybase.tomlconfiguration file- SQLite database with initial schema
- Admin user account
functions/directory for your server-side functions
2. Start the development server:
tinybase serve --reload3. Access your instance:
| Service | URL |
|---|---|
| π¨ Admin UI | http://localhost:8000/admin |
| π API Docs | http://localhost:8000/docs |
| π REST API | http://localhost:8000/api |
4. Create your first function:
tinybase functions new hello -d "Say hello"That's it! You now have a fully functional backend with authentication, database, API, and admin interface.
TinyBase reads configuration from:
- Environment variables.
tinybase.tomlin the current directory.- Internal defaults.
Typical configuration options:
[server]
host = "0.0.0.0"
port = 8000
debug = false
log_level = "info"
[database]
url = "sqlite:///./tinybase.db"
[auth]
token_ttl_hours = 24
[functions]
path = "./functions"
[scheduler]
enabled = true
interval_seconds = 5
token_cleanup_interval = 60
[cors]
allow_origins = ["*"]
[admin]
static_dir = "builtin" # or path to custom admin static files
[environments.production]
url = "https://tinybase.example.com"
api_token = "ADMIN_TOKEN"Corresponding environment variables (examples):
TINYBASE_SERVER_HOSTTINYBASE_SERVER_PORTTINYBASE_DB_URLTINYBASE_AUTH_TOKEN_TTL_HOURSTINYBASE_FUNCTIONS_PATHTINYBASE_SCHEDULER_ENABLEDTINYBASE_SCHEDULER_INTERVAL_SECONDSTINYBASE_SCHEDULER_TOKEN_CLEANUP_INTERVALTINYBASE_CORS_ALLOW_ORIGINSTINYBASE_ADMIN_STATIC_DIR
Admin bootstrap (used by tinybase init if present):
TINYBASE_ADMIN_EMAILTINYBASE_ADMIN_PASSWORD
Functions are regular Python callables registered with the TinyBase SDK decorator and (automatically) exposed as HTTP endpoints and schedulable tasks. Each function should live in its own file within the functions/ package directory generated by tinybase init.
Functions run in isolated subprocess environments with automatic dependency management using uv's single-file script feature.
Example (functions/add_numbers.py):
# /// script
# dependencies = [
# "tinybase-sdk",
# ]
# ///
from pydantic import BaseModel
from tinybase_sdk import register
from tinybase_sdk.cli import run
class AddInput(BaseModel):
x: int
y: int
class AddOutput(BaseModel):
sum: int
@register(
name="add_numbers",
description="Add two numbers",
auth="auth", # "public" | "auth" | "admin"
tags=["math"],
)
def add_numbers(client, payload: AddInput) -> AddOutput:
# Use client to make API calls back to TinyBase
return AddOutput(sum=payload.x + payload.y)
if __name__ == "__main__":
run()This function is automatically exposed at:
POST /api/functions/add_numbers
Request body:
{
"x": 1,
"y": 2
}Response:
{
"call_id": "<uuid>",
"status": "succeeded",
"result": {
"sum": 3
}
}Function calls are also recorded as FunctionCall records for diagnostics (status, duration, errors).
Use the CLI to generate boilerplate for a new function:
tinybase functions new my_function -d "My example function"This creates a new file functions/my_function.py with a typed function template using the SDK format.
TinyBase supports scheduling functions using three methods:
once(single run at a particular date/time).interval(every N seconds/minutes/hours/days).cron(cron expressions, viacroniter).
Schedules are defined as JSON objects stored in the schedule field of FunctionSchedule and validated with Pydantic.
Examples:
Once:
{
"method": "once",
"timezone": "Europe/Berlin",
"date": "2025-11-25",
"time": "08:00:00"
}Interval:
{
"method": "interval",
"timezone": "UTC",
"unit": "hours",
"value": 1
}Cron:
{
"method": "cron",
"timezone": "Europe/Berlin",
"cron": "0 8 * * *",
"description": "every day at 8am"
}Admin endpoints for schedules:
GET /api/admin/schedulesPOST /api/admin/schedulesGET /api/admin/schedules/{id}PATCH /api/admin/schedules/{id}DELETE /api/admin/schedules/{id}
Note: The scheduler runs as a background loop in TinyBase and triggers functions according to their schedule, creating
FunctionCallrecords for each invocation.
TinyBase collections are dynamic, schema-driven tables stored in SQLite.
- Collections are defined with a JSON schema describing their fields and constraints.
- Pydantic models are generated at startup to validate records.
- CRUD endpoints are provided for each collection.
Example schema (Collection.schema):
{
"fields": [
{
"name": "title",
"type": "string",
"required": true,
"max_length": 200
},
{
"name": "published",
"type": "boolean",
"required": false,
"default": false
}
]
}Associated endpoints:
GET /api/collectionsPOST /api/collections(admin)GET /api/collections/{collection_name}GET /api/collections/{collection_name}/recordsPOST /api/collections/{collection_name}/recordsGET /api/collections/{collection_name}/records/{id}PATCH /api/collections/{collection_name}/records/{id}DELETE /api/collections/{collection_name}/records/{id}
The admin UI is a single-page application built with:
- Vue 3
- Pinia
- Vite
- PicoCSS
Source:
- Located in the repository root under
/app.
Build:
cd app
yarn install
yarn buildThis produces a /app/dist directory, which should be copied into the Python package (e.g. tinybase/admin_static) during the build process.
At runtime, FastAPI serves the admin UI at:
GET /admin
The admin UI allows administrators to:
- Log in.
- Manage collections and schemas.
- Inspect and edit records.
- View and manage users.
- View and manage functions.
- Configure schedules.
- Inspect function call metadata.
Contributions are welcome! Please see CONTRIBUTING.md for details.
Backend development:
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
uv pip install -e ".[dev]"
# Initialize and run
tinybase init --admin-email admin@example.com --admin-password admin123
tinybase serve --reloadAdmin UI development:
cd app
yarn install
yarn dev # Start Vite dev server with hot reload# Run all tests
pytest
# Run with coverage
pytest --cov=tinybase --cov-report=html
# Run specific test file
pytest tests/test_function_execution.py
# Run linting
ruff check .Test coverage includes:
- β Function execution and isolation
- β Authentication and JWT flows
- β Collection CRUD operations
- β Scheduling and cron parsing
- β Rate limiting and resource management
- β SDK decorator and CLI
The included Dockerfile provides a production-ready build:
Build:
docker build -t tinybase .Run:
docker run -p 8000:8000 \
-e TINYBASE_ADMIN_EMAIL=admin@example.com \
-e TINYBASE_ADMIN_PASSWORD=admin123 \
-v $(pwd)/data:/app/data \
tinybaseThe multi-stage build:
- Builds the Vue admin UI with yarn
- Creates a minimal Python runtime using uv
- Bundles everything into a single optimized image
- Use environment variables for secrets (don't commit
tinybase.tomlwith credentials) - Mount a volume for persistent SQLite database storage
- Use a reverse proxy (nginx/Caddy) with HTTPS in production
- Consider Redis for rate limiting in multi-instance deployments
- Enable CORS only for trusted origins
Planned improvements may include:
- π Advanced Querying β GraphQL support and complex filtering for collections
- π WebSocket Support β Real-time updates and subscriptions
- π Enhanced Monitoring β Built-in metrics, logs, and performance dashboards
- π§© Plugin Library β Discover and install community extensions
- π Multi-tenancy β Built-in support for multi-tenant applications
- π Database Replication β SQLite replication for high availability
- π± Mobile SDKs β Native SDKs for iOS and Android
- π€ AI Integration β Built-in support for LLM function calling
Have a feature request? Open an issue or start a discussion!
TinyBase is released under the MIT License. See LICENSE for details.
TinyBase is built on the shoulders of giants:
- FastAPI β Modern Python web framework
- SQLModel β SQL databases with Python type hints
- Pydantic β Data validation and settings management
- Vue 3 β Progressive JavaScript framework
- uv β Fast Python package installer
If you find TinyBase useful, please consider:
- β Starring the repository
- π Reporting bugs and issues
- π‘ Suggesting new features
- π Improving documentation
- π Contributing code