🦀 Krab
A full-stack Rust framework for SSR + Island Hydration, service composition, and operational hardening.
Quick Start · Architecture · Features · API Reference · Contributing · Release Policy
Krab is a Rust-native full-stack framework designed to give you the developer experience of modern JavaScript frameworks (Next.js, Astro, SvelteKit) with the performance, memory safety, and type guarantees of Rust.
It uses a Server-Side Rendering (SSR) with Island Hydration architecture: pages are rendered as fast HTML on the server, while only interactive components are selectively hydrated with WebAssembly on the client. This results in minimal bundle sizes and blazing-fast page loads.
Unlike single-purpose libraries, Krab ships with built-in service composition — a multi-service architecture with auth, users, and frontend services — and enterprise operational hardening including migration governance, dependency security enforcement, structured telemetry, and production secret management.
| Concern | Axum / Actix | Leptos / Dioxus | Next.js | Krab |
|---|---|---|---|---|
| SSR + Islands | Manual | Full WASM SPA | JS-based ISR | ✅ Native Rust SSR + selective WASM hydration |
| Multi-service orchestration | DIY | Not included | Not included | ✅ Built-in orchestrator + service mesh |
| Migration governance | DIY | DIY | DIY | ✅ Checksum validation, drift detection, rollback rehearsal |
| Dependency security | DIY | DIY | npm audit | ✅ cargo-deny CI gates (advisories + licenses + bans) |
| Secret management | DIY | DIY | DIY | ✅ *_FILE / vault-ref sourcing enforced in production |
| Telemetry & SLOs | DIY | DIY | DIY | ✅ Prometheus metrics, RED/USE taxonomy, burn-rate alerts |
cargo install wasm-packcargo install cargo-deny# Clone and configure
git clone https://github.com/your-org/krab.git
cd krab
cp .env.example .env
# Edit .env with your local settings (DATABASE_URL, KRAB_AUTH_MODE, etc.)
# Individual services
cargo run --bin service_auth # Auth REST API → localhost:3001
cargo run --bin service_users # Users GraphQL API → localhost:3002
cargo run --bin service_frontend # SSR Frontend → localhost:3000
# Or use the orchestrator to run all at once
cargo run --bin krab_orchestrator
cargo fmt --all --check # Formatting
cargo clippy --workspace --all-targets -- -D warnings # Linting
cargo test --workspace # Tests
cargo deny --all-features check advisories licenses bans # Dependency audit
cargo doc --workspace --no-deps # Generate rustdoc
Krab follows a "Server-First, Client-Opt-In" architecture organized as a Cargo workspace.
┌──────────────────────────────────────────────────────────┐
│ krab_orchestrator │
│ (multi-process service runner) │
├────────────┬─────────────────┬────────────────────────────┤
│service_auth│ service_users │ service_frontend │
│ (REST) │ (GraphQL + DB) │ (SSR + Islands) │
├────────────┴─────────────────┴────────────────────────────┤
│ krab_core │
│ config · http · db · telemetry · resilience · signal │
├──────────────────┬────────────────────────────────────────┤
│ krab_macros │ krab_server │ krab_client (WASM) │
│ (view!, #[island])│ (Hyper/Tower) │ (Island hydration) │
├──────────────────┴────────────────────────────────────────┤
│ krab_cli │
│ (dev tooling, env-check, bootstrap) │
└──────────────────────────────────────────────────────────┘
| Crate | Purpose |
|---|---|
krab_core |
Shared config, HTTP middleware, resilience, telemetry, DB governance, and signal system |
krab_macros |
Procedural macros (view!, #[island]) |
krab_client |
WASM runtime for island hydration (browser) |
krab_server |
Hyper/Tower server foundations |
service_auth |
Authentication service (REST — JWT/OIDC token issuance) |
service_users |
Users service (GraphQL + PostgreSQL/SQLite) |
service_frontend |
SSR frontend service with island hydration |
krab_orchestrator |
Multi-service process orchestrator |
krab_cli |
Developer CLI helpers (env-check, bootstrap) |
Pages are server-rendered as static HTML by default. Interactive components are marked with #[island] and selectively hydrated via WebAssembly:
#[island]
pub fn Counter(initial: i32) -> impl View {
let (count, set_count) = create_signal(initial);
view! {
<button on:click=move |_| set_count.update(|n| *n += 1)>
"Count: " {count}
</button>
}
}
Krab supports pluggable database backends via the KRAB_DB_DRIVER environment variable:
| Driver | Value | Use Case | Vulnerability Status |
|---|---|---|---|
| PostgreSQL | postgres (default) |
Production-grade with full migration governance | ✅ Clean |
| SQLite | sqlite |
Lightweight dev/testing, portable deployments | ✅ Clean |
PostgreSQL includes enterprise features: versioned migrations with checksums, drift detection, promotion policy enforcement, and rollback rehearsal requirements.
KeyRing with multiple kid support)KRAB_RATE_LIMIT_FAIL_OPEN)KRAB_JWT_ALLOWED_ALGSKRAB_TRUST_PROXY_HEADERS (forwarded headers are untrusted by default)*_FILE or *_VAULT_REF sourcingZero-tolerance dependency governance enforced via cargo-deny:
ignore entries)cargo deny --all-features check advisories licenses banstracing with OpenTelemetry-aligned field names/metrics/prometheus on every servicekrab_response_5xx_total, krab_request_duration_ms_*)/metrics for programmatic consumption/health) and readiness (/ready) endpoints with dependency statusx-request-id header propagationAll configuration is via environment variables. See .env.example for the complete reference.
| Variable | Description | Default |
|---|---|---|
KRAB_ENVIRONMENT |
Runtime environment (dev, staging, prod) |
dev |
KRAB_AUTH_MODE |
Authentication mode (jwt, oidc, static) |
jwt |
KRAB_DB_DRIVER |
Database backend (postgres, sqlite) |
postgres |
DATABASE_URL |
Database connection string | Per-driver default |
KRAB_HOST |
Service bind host | 127.0.0.1 |
KRAB_PORT |
Service bind port | Per-service default |
RUST_LOG |
Log filter directive | info |
In staging and prod environments, secrets must be provided via file mount or vault reference:
| Secret | File Variable | Vault Variable |
|---|---|---|
| JWT signing key | KRAB_JWT_SECRET_FILE |
KRAB_JWT_SECRET_VAULT_REF |
| JWT key ring | KRAB_JWT_KEYS_JSON_FILE |
KRAB_JWT_KEYS_JSON_VAULT_REF |
| Bootstrap password | KRAB_AUTH_BOOTSTRAP_PASSWORD_FILE |
KRAB_AUTH_BOOTSTRAP_PASSWORD_VAULT_REF |
| Login users | KRAB_AUTH_LOGIN_USERS_JSON_FILE |
KRAB_AUTH_LOGIN_USERS_JSON_VAULT_REF |
| Database URL | DATABASE_URL_FILE |
— |
For the full environment template with validation rules, see plans/environment_template.md.
Full enterprise governance is available when using PostgreSQL:
local → dev → staging → prod orderingkrab_migration_policy_auditSQLite is available for development, testing, and lightweight deployments:
KRAB_DB_DRIVER=sqlite DATABASE_URL="sqlite://krab_users.sqlite?mode=rwc" cargo run --bin service_users
All gates must pass before merge. Automated workflows enforce quality at every PR:
| Workflow | File | Purpose |
|---|---|---|
| Ops Hardening | .github/workflows/ops-hardening.yaml |
fmt + clippy + rustdoc + cargo-deny |
| Dependency Security | .github/workflows/dependency-security.yaml |
cargo-audit + SBOM generation |
| API Contract | .github/workflows/api-contract.yaml |
API contract validation |
| DB Lifecycle | .github/workflows/db-lifecycle.yaml |
Migrations, rollback simulation, drift checks |
| E2E Depth | .github/workflows/e2e-depth.yaml |
Multi-service end-to-end testing |
| NFT Suite | .github/workflows/nft.yaml |
Non-functional / load testing gates |
| Document | Purpose |
|---|---|
README.md |
This document — project overview and quick start |
CONTRIBUTING.md |
Contribution workflow, quality gates, and engineering standards |
CHANGELOG.md |
Release history (Keep a Changelog format) |
RELEASE_POLICY.md |
Release channels, promotion criteria, and versioning |
docs/)| Document | Purpose |
|---|---|
docs/API.md |
Public API contract for all HTTP and GraphQL endpoints |
docs/signal_safety.md |
Signal system threading constraints and SSR usage patterns |
docs/security.md |
Security architecture, secret management, and threat model |
docs/database.md |
Database architecture, migrations, and multi-driver support |
docs/deployment.md |
Deployment guide for containerized and self-hosted environments |
plans/)| Document | Purpose |
|---|---|
plans/01_vision_and_philosophy.md |
Core mission, pillars, and differentiators |
plans/02_architecture_design.md |
Detailed architecture: subsystems, routing, islands, data loading |
plans/03_roadmap.md |
Phase 0 roadmap, governance, epic breakdown, risk log |
plans/08_production_readiness.md |
Production readiness checklist and gate definitions |
plans/oncall_playbook.md |
On-call runbook and incident response procedures |
plans/db_rollback_runbook.md |
Database rollback procedures and disaster recovery |
plans/environment_template.md |
Environment variable reference and validation |
Report vulnerabilities privately via GitHub Security Advisories.
Current security posture:
cargo-deny advisory ignores*_FILE / *_VAULT_REF)KRAB_CORS_ORIGINS required in staging/prod)For the full security architecture, see docs/security.md.
| Role | GitHub |
|---|---|
| Primary Contributor | @manirajkatuwal |
MIT — see individual crate Cargo.toml files for per-crate license declarations.