Vaultwarden
Audited from github.com/dani-garcia/vaultwarden
Lightweight, unofficial Bitwarden-compatible password manager server written in Rust with SQLite, PostgreSQL, and MySQL support.
- Language
- Rust
- Database
- SQLite
- Hosting
- Docker
- License
- AGPL-3.0
- Running for
- 6 years
- Team
- Solo / 2-5 people
Why this architecture
Vaultwarden replaces the heavy, multi-container official Bitwarden stack with a single fast Rust executable consuming minimal RAM.
Tech stack by layer
6 technologies · audited Sep 17, 2026- SQLiteDefault embedded database storage using bundled libsqlite3 for zero-config deployments
- PostgreSQLRelational database driver supported via Diesel for high-concurrency clustered setups
- MySQLAlternative relational database backend supported through compile-time Diesel feature gates
- DockerMulti-architecture Alpine and Debian container builds with embedded Web Vault static assets
Vaultwarden architecture diagram
Open SVGDiagram as text
- Bitwarden clients (apps · browser · CLI) → vaultwarden (Rust · Rocket): Bitwarden API
- Web Vault (embedded static assets) → vaultwarden (Rust · Rocket): Bitwarden API
- Bitwarden clients (apps · browser · CLI) → Notifications (WebSocket): sync events
- vaultwarden (Rust · Rocket) → Database (SQLite / Postgres / MySQL): Diesel
- vaultwarden (Rust · Rocket) → Attachments (OpenDAL storage): read / write
- vaultwarden (Rust · Rocket) → MFA (WebAuthn-RS · security keys): verify
Key architectural decisions
4 decisions- 01
Single-Binary Bitwarden Server Implementation
Rewrites the multi-service Bitwarden backend in pure Rust, reducing memory consumption from gigabytes to tens of megabytes on self-hosted servers.
- 02
Pluggable Multi-Database Persistence via Diesel
Uses compile-time feature flags in Diesel to generate native queries for SQLite, PostgreSQL, or MySQL without runtime ORM overhead.
- 03
OpenDAL Object Storage Abstraction
Integrates Apache OpenDAL (opendal) to support transparent file attachment storage across local disks and S3-compatible cloud buckets.
- 04
Hardware Multi-Factor Authentication via WebAuthn-RS
Implements FIDO2, WebAuthn, and YubiKey two-step verification using native Rust cryptography without external authentication brokers.
How Vaultwarden is built
How Vaultwarden is structured
Vaultwarden is structured as a high-performance Rust service organized into modular subsystems under src/:
src/api: The HTTP endpoint router implementing the Bitwarden API specification (identity tokens, vault ciphers, folders, collections, sends, organizations, and emergency access).src/db: Database models and connection pooling built on Diesel (r2d2), abstracting schema differences across SQLite, PostgreSQL, and MySQL.src/auth: Cryptographic verification and multi-factor authentication handling (WebAuthn, TOTP, YubiKey, and Duo).src/mail.rs: Transactional email dispatcher built withlettreand Handlebars HTML templates for user invitations and security alerts.src/storage.rs: File attachment management utilizing Apache OpenDAL to support both local filesystems and S3-compatible cloud storage.
Frontend
Vaultwarden serves the official Bitwarden Web Vault through pre-built static assets bundled directly within container releases:
- Embedded Web Vault: Ships a modified build of Bitwarden's web vault (
web-vault), served as static assets directly through Rocket. - Admin Panel: An integrated administration console authored with Handlebars templates (
src/api/admin.rs) allowing administrators to view diagnostics, manage user registrations, and configure global environment variables.
Backend & APIs
The backend server is powered by the Rocket web framework on top of Tokio:
- Bitwarden Sync API: Endpoints under
/apihandle zero-knowledge encrypted vault syncing, batch cipher additions, and organization sharing. - Live Notifications: Employs WebSockets (
rocket_ws) and MessagePack (rmpv) to broadcast cipher mutation events immediately to connected browser extensions and mobile clients. - Rate Limiting: Uses
governorto rate-limit login attempts and prevent brute-force attacks against master passwords. - SSO & OIDC: Optional enterprise single sign-on integration via
openidconnectandmokatoken caching.
Data & persistence
Persistence in Vaultwarden is handled through Diesel ORM with schema migrations maintained under migrations/:
- SQLite: The default zero-configuration backend statically linked via
libsqlite3-sys, perfect for personal and family instances. - PostgreSQL & MySQL: Supported for large team deployments requiring high concurrency and automated database backups.
- Zero-Knowledge Encryption: Vaultwarden never sees unencrypted user secrets; encryption and decryption keys are derived on client devices using PBKDF2 or Argon2.
Realtime / collaboration
Realtime updates are delivered via persistent WebSocket connections:
- When a user modifies or shares a password entry in an organization, Vaultwarden dispatches WebSocket notifications to all authorized active sessions.
- Clients receive push notifications to synchronize their local SQLite vault caches immediately without periodic polling.
Build, test & deploy
The build process is managed with Cargo and Docker Bake:
- Binaries are compiled with link-time optimization (
lto = "fat") and stripped debug symbols to minimize binary sizes. - Multi-architecture container images (amd64, arm64, armv7) are generated using Docker Bake (
docker/docker-bake.hcl) with Debian and Alpine base targets. - Automated end-to-end integration tests run via Playwright (
playwright/) verifying authentication flows against mock OIDC providers (Keycloak) and real database containers.
Self-hosting notes
Vaultwarden is widely self-hosted across homelabs and enterprise environments:
- Standard deployments run
vaultwarden/server:latestvia Docker or Podman, mounting a persistent volume to/data. - A reverse proxy (such as Caddy, Traefik, or Nginx) is required to terminate HTTPS, which is mandatory for browser Web Crypto APIs to function.
- Configuration is handled via environment variables (e.g.,
SIGNUPS_ALLOWED=false,ADMIN_TOKEN,DATABASE_URL).
What to copy (and what not to)
What to copy:
- Reimplementing heavy microservice APIs as a unified, single-binary Rust application to achieve 95%+ reductions in memory and CPU footprint.
- Compile-time feature-gated database support via Diesel, allowing users to compile against SQLite for simplicity or PostgreSQL for scale.
- Serving zero-knowledge encrypted client assets while keeping server-side code completely ignorant of plaintext user secrets.
What not to copy:
- Distributing internal administration interfaces using server-side templating (
Handlebars) tightly coupled to backend server routes; separate admin SPA frontends are cleaner to maintain as security boundaries evolve.
Sources & repo audit
- Cargo.toml (Core workspace dependencies, Rocket framework, and feature flags)
- Dockerfile (Debian and Alpine multi-stage container targets)
- src/main.rs (Server launch sequence, database pool configuration, and route mounting)
Independent analysis of repository at github.com/dani-garcia/vaultwarden. Spotted an inaccuracy? Use the claim form to request a correction.
Show this stack on your README or website
[](https://stackitfast.com/project/vaultwarden)Paste it into your README. It shows your current stack and links to this page.
Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Vaultwarden's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Vaultwarden" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Vaultwarden**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Vaultwarden
- **What It Does**: Lightweight, unofficial Bitwarden-compatible password manager server written in Rust with SQLite, PostgreSQL, and MySQL support.
- **Domain & Category**: Lightweight Self-Hosted Password Vault
- **Production Scale**: Solo / 2-5 people
- **Development Mode**: CLASSIC
- **Architectural Rationale**: Vaultwarden replaces the heavy, multi-container official Bitwarden stack with a single fast Rust executable consuming minimal RAM.
- **Live Website Reference**: https://github.com/dani-garcia/vaultwarden
- **Source Repository**: https://github.com/dani-garcia/vaultwarden
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Rust, SQLite, PostgreSQL, MySQL, Docker, Tokio
- **Primary Language(s)**: Rust, Handlebars, TypeScript, Shell, Jinja, HCL
- **License of the reference repo**: AGPL-3.0
- **Backend & APIs**: Rust — Core systems programming language providing memory safety and minimal resource usage; Tokio — Asynchronous runtime powering concurrent Rocket HTTP connections and WebSocket streams
- **Data & persistence**: SQLite — Default embedded database storage using bundled libsqlite3 for zero-config deployments; PostgreSQL — Relational database driver supported via Diesel for high-concurrency clustered setups; MySQL — Alternative relational database backend supported through compile-time Diesel feature gates
- **Infrastructure & deploy**: Docker — Multi-architecture Alpine and Debian container builds with embedded Web Vault static assets
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/dani-garcia/vaultwarden @ eb212e2)
1. **Single-Binary Bitwarden Server Implementation**: Rewrites the multi-service Bitwarden backend in pure Rust, reducing memory consumption from gigabytes to tens of megabytes on self-hosted servers.
2. **Pluggable Multi-Database Persistence via Diesel**: Uses compile-time feature flags in Diesel to generate native queries for SQLite, PostgreSQL, or MySQL without runtime ORM overhead.
3. **OpenDAL Object Storage Abstraction**: Integrates Apache OpenDAL (opendal) to support transparent file attachment storage across local disks and S3-compatible cloud buckets.
4. **Hardware Multi-Factor Authentication via WebAuthn-RS**: Implements FIDO2, WebAuthn, and YubiKey two-step verification using native Rust cryptography without external authentication brokers.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (SQLite, PostgreSQL, MySQL): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Copied 2 times
Frequently asked about Vaultwarden
Is Vaultwarden compatible with official Bitwarden mobile and browser extensions?
Yes, Vaultwarden faithfully implements the Bitwarden sync and cipher APIs, allowing official desktop, mobile, and browser clients to connect seamlessly.
Can Vaultwarden run on low-power devices like a Raspberry Pi?
Yes, the lightweight Rust binary typically uses less than 50MB of RAM and runs comfortably on embedded ARM devices with SQLite.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- AtuinClassicShell History Sync · 2-5 peopleShares Rust · SQLite · PostgreSQL
- KanidmClassicIdentity Management Platform · 6-20 peopleShares Rust · SQLite · Tokio
- PrismaClassicNext-Generation Node.js & TypeScript ORM · 1M+ MAUShares PostgreSQL · MySQL · SQLite
- DenoClassicSecure JavaScript & TypeScript Runtime · 20+ peopleShares Rust · Tokio · SQLite
- AutheliaClassicAuthentication & SSO Proxy Companion · 6-20 PeopleShares PostgreSQL · MySQL · SQLite
- AppFlowyHybridLocal-First Privacy Workspace · 6-20 PeopleShares Rust · SQLite · Tokio