Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

modpotato/Sakura

Repository files navigation

🌸 Sakura

A modern, high-performance, FOSS alternative to Discord. Built with Rust, SolidJS, and PostgreSQL.

Sakura is an open-source community platform that stays self-hostable and horizontally scalable without sacrificing trust & safety. One binary, two worlds: deploy as a managed SaaS service or self-host with Docker Compose.

Features

  • Real-time messaging — Send, edit, delete, pin, and search messages with MsgPack-encoded WebSocket delivery
  • Guilds & channels — Create communities with text and voice channels, roles, and permissions
  • Voice & video — LiveKit-powered voice channels with screen sharing
  • Reactions & typing indicators — Full emoji reactions and live typing status
  • File uploads — Content-addressable storage with SHA256 deduplication, image compression, and antivirus scanning
  • Roles & permissions — Hierarchical role system with per-channel permission overwrites
  • Invite system — Shareable invite links with expiration and usage limits
  • Friends & DMs — Friend requests, direct messages, and user blocking
  • Presence — Online, Idle, DND, Invisible, and Offline status with real-time updates
  • MFA — TOTP-based multi-factor authentication with backup codes
  • Moderation — Reports, bans, trust scoring, word filters, ClamAV integration, and admin audit logs
  • Desktop client — Full-featured SolidJS client with dark theme, virtual scrolling, markdown rendering, and device management
  • Admin panel — Report triage, user banning, message deletion, and audit log viewer
  • Self-hosting — Single Docker Compose deployment with MinIO, PostgreSQL, and Redis

Architecture

┌─────────────┐     ┌──────────────┐     ┌──────────────┐
│  Desktop /  │────▶│  sakura-api  │────▶│  PostgreSQL   │
│  Web Client │     │  (REST API)  │     │  (partitioned)│
└──────┬──────┘     └──────────────┘     └──────────────┘
       │                    │
       │ MsgPack/WS         │ Redis Pub/Sub
       ▼                    ▼
┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│sakura-gateway│◀───▶│    Redis     │     │ S3 / MinIO   │
│ (WebSocket)  │     │              │     │  (CAS files) │
└──────────────┘     └──────────────┘     └──────────────┘
                                          ┌──────────────┐
                                          │sakura-janitor│
                                          │  (cleanup)   │
                                          └──────────────┘
Crate Purpose
crates/core Shared types, DB models, config, auth, extensibility traits
crates/api Axum REST API — auth, guilds, channels, messages, uploads, moderation, voice
crates/gateway WebSocket gateway — real-time event fanout via MsgPack + Redis Pub/Sub
crates/janitor Background cleanup — expired attachments, orphaned files, cascading deletes
crates/moderation Content scanning — ClamAV, perceptual image hashing, trust scoring
apps/desktop SolidJS desktop client — guilds, messaging, voice, file uploads, reactions
apps/web Astro landing page with OS-aware download button
apps/admin SolidJS admin dashboard — reports, bans, audit logs

Design Principles

  • Stateless services, stateful data — All state lives in Postgres, Redis, or object storage; services restart without drama
  • Time-ordered data by default — UUIDv7 + partitioned tables for message scale
  • Content-addressable storage — Files deduplicated, reference-counted, and garbage-collected
  • Safety is foundational — MFA, moderation hooks, and audit trails are core, not add-ons
  • One binary, two worlds — SaaS and self-hosted modes are configuration choices, not forks

Extensibility

Sakura exposes trait-based extension points for plugins and alternative backends:

  • EventPublisher — Swap Redis Pub/Sub for NATS or Kafka
  • StorageProvider — Plug in Backblaze B2, GCS, or any S3-compatible backend
  • AuthProvider — Replace PASETO with SSO/OAuth
  • NotificationProvider — Push, email, or webhook delivery
  • ModerationScanner — Custom content scanners beyond ClamAV
  • PreSendHook / PostSendHook — Message pipeline validation and analytics

Getting Started

Prerequisites

  • Rust 1.75+
  • PostgreSQL 15+
  • Redis 7+
  • S3-compatible storage (Cloudflare R2, MinIO, or AWS S3)
  • Node.js 18+ (for frontend development)

Backend Setup

# Clone and build
git clone https://github.com/modpotato/Sakura.git
cd Sakura
cargo build

# Copy and edit config
cp config.example.toml config.toml       # SaaS mode (Cloudflare R2)
# or
cp config.selfhosted.example.toml config.toml  # Self-hosted mode (MinIO)

# Run all database migrations
for f in migrations/*.sql; do psql "$DATABASE_URL" -f "$f"; done

# Start services (each in its own terminal)
cargo run -p sakura-api       # REST API on :8080
cargo run -p sakura-gateway   # WebSocket gateway on :9001
cargo run -p sakura-janitor   # Background cleanup (runs every 5 min)

Desktop Client

cd apps/desktop
npm install
npm run dev     # Vite dev server on :1420

Admin Dashboard

cd apps/admin
npm install
npm run dev     # Vite dev server on :3001

Docker Compose (Recommended)

cp .env.example .env   # Edit with your secrets
docker compose up -d   # Starts API, gateway, janitor, Postgres, Redis, MinIO

See README_PROD.md for production deployment on Hetzner/VPS.

Testing

cargo test

Configuration

Copy config.example.toml (SaaS) or config.selfhosted.example.toml (self-hosted) to config.toml. Environment variables with the SAKURA__ prefix override TOML settings:

SAKURA__DATABASE__URL=postgres://sakura:pass@localhost/sakura
SAKURA__REDIS__URL=redis://localhost:6379
SAKURA__AUTH__PASETO_SECRET=<base64-32-bytes>
SAKURA__STORAGE__BUCKET=sakura-uploads

See DOCS/SELF_HOSTING.md for a complete self-hosting guide.

Documentation

License

GPL-3.0 — see LICENSE.

About

a vibed discord alternative

Topics

Resources

License

Stars

Watchers

Forks

Contributors