> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/trailbaseio/trailbase/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to TrailBase

> Learn about TrailBase - an open-source, single-executable Firebase alternative with type-safe APIs, WebAssembly runtime, and sub-millisecond performance

## What is TrailBase?

TrailBase is an open-source, **single-executable** Firebase alternative that combines the simplicity of SQLite with the power of modern web technologies. Built on Rust, SQLite, and Wasmtime, TrailBase provides a complete backend solution with type-safe REST APIs, realtime subscriptions, authentication, and an admin UI - all in one binary.

<Info>
  TrailBase delivers **sub-millisecond latencies** that eliminate the need for dedicated caches, ensuring you never deal with stale or inconsistent data.
</Info>

## Key Features

<CardGroup cols={2}>
  <Card title="Type-Safe APIs" icon="shield-check">
    Automatically generated REST APIs with JSON Schema validation and code generation for virtually any language
  </Card>

  <Card title="WebAssembly Runtime" icon="cube">
    Extend functionality with custom logic using JavaScript, TypeScript, or Rust compiled to WebAssembly
  </Card>

  <Card title="Realtime Subscriptions" icon="bolt">
    Built-in support for streaming data changes to clients in real-time
  </Card>

  <Card title="Authentication & Authorization" icon="lock">
    Complete auth system with OAuth2, password-based login, email verification, and fine-grained ACLs
  </Card>

  <Card title="Admin Dashboard" icon="chart-line">
    Web-based admin UI for managing users, tables, APIs, and configurations
  </Card>

  <Card title="Multi-Database Support" icon="database">
    Work with multiple SQLite databases simultaneously with separate migration paths
  </Card>

  <Card title="Vector Search" icon="magnifying-glass">
    Built-in support for vector embeddings and semantic search via sqlite-vec
  </Card>

  <Card title="Geospatial Support" icon="map-location-dot">
    Native geospatial capabilities with PostGIS-compatible functions
  </Card>
</CardGroup>

## Why TrailBase?

### Simplify Your Stack

TrailBase helps you **simplify with fewer moving parts**. Instead of managing multiple services (database, API server, cache, queue, auth service), you get an easy-to-self-host, single-executable backend for your mobile, web, or desktop application.

### Performance That Matters

With **sub-millisecond latencies**, TrailBase eliminates common performance bottlenecks:

* No need for dedicated Redis/Memcached caches
* No stale or inconsistent data from cache invalidation issues
* Direct SQLite access provides blazing-fast queries
* Perfect for edge deployments and resource-constrained environments

### Developer Experience

TrailBase prioritizes developer experience with:

* **Zero dependencies**: Single binary with everything included
* **Type safety**: Generate client libraries in TypeScript, Dart, Rust, Python, Go, Kotlin, Swift, and C#
* **Database migrations**: Built-in migration system for schema versioning
* **Hot reload**: Development mode with automatic reloading
* **Extensibility**: WebAssembly runtime for custom server-side logic

## Architecture Overview

TrailBase's architecture is designed for simplicity and performance:

```
┌─────────────────────────────────────────────────────────┐
│                    TrailBase Server                     │
│  ┌────────────┐  ┌────────────┐  ┌─────────────────┐  │
│  │  Admin UI  │  │ Record APIs│  │  Auth & OAuth2  │  │
│  └────────────┘  └────────────┘  └─────────────────┘  │
│  ┌────────────────────────────────────────────────┐    │
│  │         WebAssembly Runtime (Wasmtime)         │    │
│  │    JS/TS/Rust custom endpoints & functions     │    │
│  └────────────────────────────────────────────────┘    │
│  ┌────────────────────────────────────────────────┐    │
│  │              SQLite Databases                  │    │
│  │  • Main DB  • Logs DB  • Queue DB              │    │
│  │  • Vector Search  • Geospatial  • Full-text    │    │
│  └────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────┘
```

### Core Components

<AccordionGroup>
  <Accordion title="SQLite Database Layer">
    TrailBase uses SQLite as its database engine with:

    * **Multiple databases**: Separate databases for main data, logs, and queues
    * **Extensions**: sqlite-vec for vector search, sqlean for additional functions
    * **STRICT tables**: Type safety at the database level
    * **WAL mode**: Write-Ahead Logging for better concurrency
  </Accordion>

  <Accordion title="Record API System">
    Automatically generated REST APIs from database schemas:

    * **CRUD operations**: Create, Read, Update, Delete
    * **Filtering & sorting**: Query parameters for complex queries
    * **Pagination**: Efficient data fetching with offset/limit
    * **JSON Schema**: Auto-generated schemas for type-safe clients
    * **Access control**: Table and column-level permissions
  </Accordion>

  <Accordion title="WebAssembly Runtime">
    Extend TrailBase with custom logic:

    * **Wasmtime-based**: Fast, secure WebAssembly execution
    * **Multiple languages**: JavaScript, TypeScript, or Rust
    * **Custom endpoints**: Add new HTTP routes
    * **Database access**: Query databases from WASM code
    * **Component model**: Install pre-built components like auth UI
  </Accordion>

  <Accordion title="Authentication System">
    Complete auth solution with:

    * **Password authentication**: Argon2 hashing
    * **OAuth2 providers**: Google, GitHub, Apple, Microsoft, and more
    * **Email verification**: Built-in email sending
    * **JWT tokens**: Secure, stateless authentication
    * **User management**: Admin CLI and UI tools
  </Accordion>
</AccordionGroup>

## Project Structure

When you run TrailBase, it creates a `traildepot` directory with the following structure:

```
traildepot/
├── data/               # SQLite database files
│   ├── main.db        # Primary application database
│   ├── logs.db        # Request/access logs
│   └── queue.db       # Background job queue
├── migrations/        # Database migration files
│   └── main/         # Migrations for main database
├── backups/          # Automated database backups
├── uploads/          # Local file uploads (supports S3)
├── secrets/          # JWT keys and sensitive config
│   └── keys/
├── wasm/             # WebAssembly components
├── config.textproto  # Server configuration
└── metadata.textproto # Additional metadata
```

<Note>
  The `traildepot` directory is portable - you can copy it between environments or back it up as a single unit.
</Note>

## Use Cases

TrailBase is perfect for:

* **Mobile & web apps**: Full-featured backend in a single binary
* **Internal tools**: Rapid development with admin UI
* **Edge deployments**: Run close to users with minimal resources
* **Data analysis**: SQLite-compatible with programmatic access
* **Prototypes & MVPs**: Get started quickly without infrastructure complexity
* **Self-hosted alternatives**: Replace Firebase, Supabase, or PocketBase

## Client Libraries

TrailBase provides official client libraries for multiple languages:

* **JavaScript/TypeScript**: [npm](https://www.npmjs.com/package/trailbase)
* **Dart/Flutter**: [pub.dev](https://pub.dev/packages/trailbase)
* **Rust**: [crates.io](https://crates.io/crates/trailbase-client)
* **C#/.NET**: [NuGet](https://www.nuget.org/packages/TrailBase/)
* **Swift**: [GitHub](https://github.com/trailbaseio/trailbase/tree/main/client/swift/trailbase)
* **Kotlin**: [Maven](https://mvnrepository.com/artifact/io.trailbase/trailbase-client)
* **Go**: [GitHub](https://github.com/trailbaseio/trailbase/tree/main/client/go/trailbase)
* **Python**: [PyPI](https://pypi.org/project/trailbase/)

## License

TrailBase is free software under the **Open Software License 3.0 (OSL-3.0)**. The license's narrow definition of "derivative work" means:

* ✅ Your application code is **not** subject to copyleft
* ✅ You can build commercial applications
* ✅ Works for web, mobile, desktop, and services
* ✅ Modifications to TrailBase itself must be shared

Client libraries are dual-licensed under the permissive **Apache-2.0** license.

<Info>
  For exceptions or enterprise licensing, contact [contact@trailbase.io](mailto:contact@trailbase.io)
</Info>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get TrailBase running in under 5 minutes
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Detailed installation instructions for all platforms
  </Card>
</CardGroup>
