# SpacetimeDB — Server and Database in One > SpacetimeDB is an open-source relational database that doubles as a server runtime, letting developers write backend logic as stored procedures that run directly inside the database layer. ## Install Save in your project root: # SpacetimeDB — Server and Database in One ## Quick Use ```bash # Install the SpacetimeDB CLI curl -sSf https://install.spacetimedb.com | sh # Start a local instance spacetime start # Create and publish a module spacetime publish my-app --project-path ./server ``` ## Introduction SpacetimeDB merges the database and application server into a single layer. Instead of writing a separate backend service that queries a database, developers write modules (stored procedures in Rust or C#) that execute inside SpacetimeDB itself, eliminating the network hop between server and data. ## What SpacetimeDB Does - Runs server-side logic as compiled WebAssembly modules inside the database engine - Provides a relational data model with SQL-like table definitions and queries - Automatically synchronizes state changes to connected clients in real time - Supports client SDKs for Rust, C#, TypeScript, and Python - Handles authentication, subscriptions, and connection management out of the box ## Architecture Overview SpacetimeDB is written in Rust and uses a custom relational storage engine. Application logic is compiled to WebAssembly and loaded as modules that run inside the database process. When a module updates a table, the change is automatically pushed to subscribed clients via a built-in sync protocol. This eliminates the traditional three-tier architecture in favor of a two-tier model. ## Self-Hosting & Configuration - Install the CLI via the official install script on macOS, Linux, or Windows - Run a local standalone instance with a single command for development - Deploy to production using the provided Docker image or systemd service file - Configure storage backends, listen addresses, and log levels via environment variables - Modules are published and versioned through the CLI with zero-downtime updates ## Key Features - Unified server and database eliminates API boilerplate - WebAssembly module isolation provides security and portability - Real-time client sync without manual WebSocket or polling code - Write server logic in Rust or C# with full type safety - Designed for latency-sensitive applications like multiplayer games ## Comparison with Similar Tools - **Supabase** — Postgres-based BaaS with REST/GraphQL APIs, but server logic lives outside the DB - **Firebase** — Google managed real-time DB with proprietary lock-in and limited query power - **Convex** — Reactive backend with TypeScript functions, but not self-hostable in the same way - **SurrealDB** — Multi-model database with embedded functions, but different sync model - **PocketBase** — Lightweight Go backend with SQLite, simpler but no WASM module system ## FAQ **Q: What languages can I use to write SpacetimeDB modules?** A: Rust and C# are the primary supported languages. TypeScript support is in development. **Q: Is SpacetimeDB suitable for non-game applications?** A: Yes. While it was designed with multiplayer games in mind, it works for any real-time collaborative application, chat system, or IoT data pipeline. **Q: How does SpacetimeDB handle scaling?** A: A single SpacetimeDB instance handles vertical scaling. Horizontal sharding and clustering features are on the roadmap for future releases. **Q: What is the license?** A: SpacetimeDB uses the BSL 1.1 license, which converts to open source after four years. The client SDKs are Apache 2.0 / MIT. ## Sources - https://github.com/clockworklabs/SpacetimeDB - https://spacetimedb.com/docs --- Source: https://tokrepo.com/en/workflows/4177d943-3c71-11f1-9bc6-00163e2b0d79 Author: AI Open Source