7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | # Architecture |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | The SDK is split into multiple layers: |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | ```text |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | WASM (external crate matrix-rust-sdk-crypto-wasm) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | / |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | / uniffi |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | / / |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | / bindings (matrix-sdk-ffi) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | crypto | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | bindings | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | | | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | | UI (matrix-sdk-ui) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | | \ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | | \ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | | main (matrix-sdk) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | | / / |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | crypto / |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | \ / |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | store (matrix-sdk-base, + all the store impls) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | common (matrix-sdk-common) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | ``` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | Where the store implementations are `matrix-sdk-sqlite` and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | `matrix-sdk-indexeddb` as well as `MemoryStore` which is defined in |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | `matrix-sdk-base`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | ## `crates/matrix-sdk` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | This is the main crate, and one that is expected to be used by most consumers. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | Notable data types include: |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | - the `Client`, which can run room-independent requests: logging in/out, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | creating rooms, running sync, etc. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | - the `Room`, which represents a room and its state (notably via the observable |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | `RoomInfo`), and allows running queries that are room-specific, notably |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | sending events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | ## `crates/matrix-sdk-base` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | A _sans I/O_ crate to represent the base data types persisted in the SDK. No |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | network or storage I/O happens in this crate, although it defines traits |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | (`StateStore` and `EventCacheStore`) representing storage backends, as well as |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | dummy in-memory implementations of these traits. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | ## `crates/matrix-sdk-common` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | Common helpers used by most of the other crates; almost a leaf in the dependency |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | tree of our own crates (the only crate it's using is test helpers). |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | ## `crates/matrix-sdk-crypto` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | A _sans I/O_ implementation of a state machine that handles end-to-end |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | encryption for Matrix clients. It defines a `CryptoStore` trait representing |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | storage backends that will perform the actual storage I/O later, as well as a |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | dummy in-memory implementation of this trait. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | ## `crates/matrix-sdk-indexeddb` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | Implementations of `EventCacheStore`, `StateStore` and `CryptoStore` for a |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | indexeddb backend (for use in Web browsers, via WebAssembly). |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | ## `crates/matrix-sdk-qrcode` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | Implementation of QR codes for interactive verifications, used in the crypto |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | crate. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | ## `crates/matrix-sdk-sqlite` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | Implementations of `EventCacheStore`, `StateStore` and `CryptoStore` for a |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | SQLite backend. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | ## `crates/matrix-sdk-store-encryption` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | Low-level primitives for encrypting/decrypting/hashing values. Store |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | implementations that implement encryption at rest can use those primitives. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | ## `crates/matrix-sdk-ui` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | Very high-level primitives implementing the best practices and cutting-edge |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | Matrix tech: |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 85 | - `EncryptionSyncService`: a specialized service running simplified sliding sync |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 86 | (MSC4186) for everything related to crypto and E2EE for the current `Client`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 87 | - `RoomListService`: a specialized service running simplified sliding sync |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 88 | (MSC4186) for retrieving the list of current rooms, and exposing its entries. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 89 | - `SyncService`: a wrapper for the two previous services, coordinating their |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 90 | running and shutting down. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 91 | - `Timeline`: a high-level view for a `Room`'s timeline of events, grouping |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 92 | related events (aggregations) into single timeline items. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 93 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 94 | ## `bindings/matrix-sdk-crypto-ffi/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 95 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 96 | FFI bindings for the crypto crate, used in a Web browser context via |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 97 | WebAssembly. These use `wasm-bindgen` to generate the bindings. These bindings |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 98 | are used in Element Web and the legacy Element apps, as of 2024-11-07. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 99 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 100 | ## `bindings/matrix-sdk-ffi/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 101 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 102 | FFI bindings for important concepts in `matrix-sdk-ui` and `matrix-sdk`, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 103 | generated with [UniFFI](https://github.com/mozilla/uniffi-rs) and to be used |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 104 | from other languages like Swift/Go/Kotlin. These bindings are used in the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 105 | ElementX apps, as of 2024-11-07. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 106 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 107 | ## `bindings/matrix-sdk-ffi-macros/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 108 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 109 | Macros used in `bindings/matrix-sdk-ffi`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 110 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 111 | ## `testing/matrix-sdk-test/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 112 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 113 | Common test helpers, used by all the other crates. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 114 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 115 | ## `testing/matrix-sdk-test-macros/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 116 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 117 | Implementation of the `#[async_test]` test macro. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 118 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 119 | ## `testing/matrix-sdk-integration-testing/` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 120 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 121 | Fully-fledged integration tests that require spawning a Synapse instance to run. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 122 | A docker-compose setup is provided to ease running the tests, and it is |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 123 | compatible for running with Podman too. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 124 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 125 | ## Inspiration |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 126 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 127 | This document has been inspired by the reading of this |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 128 | [blog post](https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html). |