Skip to main content

Architecture

MedBrains is one server, one database, and several kinds of screen.

PartBuilt withWhere
ServerRust (edition 2024), Axum, Tokiomedbrains/crates/ (about 119 crates, split by department)
DatabasePostgreSQL 17, SQLx with compile-time checked queriesmedbrains/crates/medbrains-db-migrations/
Web appReact 19, TypeScript, Mantine, TanStack Query, Zustandmedbrains/apps/web/
Native appsSwiftUI (iOS) and Jetpack Compose (Android)medbrains/apps/ios/, medbrains/apps/android/
OS boxDebian stable, the server, PostgreSQL, a native screenmedbrains/os/
DocsDocusaurus (this site)medbrains/apps/docs/

The rules that shape it​

  • One server, many hospitals. Every hospital-scoped table has a tenant_id and PostgreSQL row-level security. Each request sets its tenant inside its transaction, and the app connects as a non-owner role, so a query that forgets its tenant returns nothing rather than everything.
  • SQL checked at compile time. A query that does not match the schema does not build. Offline metadata lives in .sqlx/.
  • Permissions first. Every action has a permission defined in Rust before any handler or screen. See permissions.
  • A fault is not a refusal. Authorization has three outcomes: allow, deny and unknown. An outage is never shown as an empty list.
  • The kernel. Apps reach shared concerns (tenancy, authorization, audit, configuration, sequences, storage) only through medbrains-kernel, and the kernel holds nothing about hospitals. CI enforces both.

The full design is in ENGINEERING.md and the RFCs under RFCs/.

Next​

Run MedBrains locally.