|
| 1 | +# Architecture |
| 2 | + |
| 3 | +A high-level architectural overview of the Sync Service which includes Sync and Tokenserver. |
| 4 | + |
| 5 | +## Syncstorage |
| 6 | + |
| 7 | + |
| 8 | +Below is an illustration of a highly-simplified Sync flow: |
| 9 | + |
| 10 | +```mermaid |
| 11 | +graph LR |
| 12 | +
|
| 13 | + SignIn["Sign in to FxA"] |
| 14 | + FxA[("FxA")] |
| 15 | + OAuth["Sync client gets OAuth token"] |
| 16 | + PresentToken["OAuth Token presented to Tokenserver"] |
| 17 | + Tokenserver[("Tokenserver")] |
| 18 | + AssignNode["Tokenserver assigns storage node"] |
| 19 | + InfoCollections["info/collections: Do we even need to sync?"] |
| 20 | +
|
| 21 | + MetaGlobal["meta/global: Do we need to start over?"] |
| 22 | + CryptoKeys["crypto/keys: Get keys"] |
| 23 | +
|
| 24 | + GetStorage["GET storage/<collection>: Fetch new data"] |
| 25 | + PostStorage["POST storage/<collection>: Upload new data"] |
| 26 | +
|
| 27 | + %% Main flow |
| 28 | + SignIn --> FxA |
| 29 | + FxA --> OAuth |
| 30 | + OAuth --> PresentToken |
| 31 | + PresentToken --> Tokenserver |
| 32 | + Tokenserver --> AssignNode |
| 33 | + AssignNode --> InfoCollections |
| 34 | +
|
| 35 | + %% Decision / metadata path |
| 36 | + InfoCollections --> MetaGlobal |
| 37 | + MetaGlobal --> CryptoKeys |
| 38 | +
|
| 39 | + %% Sync operations |
| 40 | + CryptoKeys --> GetStorage |
| 41 | + CryptoKeys --> PostStorage |
| 42 | +``` |
| 43 | + |
| 44 | +### Storage-Client Relationship |
| 45 | + |
| 46 | +This high-level diagram illustrates the standard Sync collections and their relationships. |
| 47 | + |
| 48 | +```mermaid |
| 49 | +graph TD |
| 50 | +
|
| 51 | + %% ===== Storage ===== |
| 52 | + DB[("DB")] |
| 53 | + BookmarksMirror[("Bookmarks Mirror")] |
| 54 | + LoginStorage[("Login Manager Storage")] |
| 55 | + AutofillStorage[("Form Autofill Storage")] |
| 56 | + XPIDB[("XPI Database")] |
| 57 | + CredentialStorage[("Credential Storage")] |
| 58 | +
|
| 59 | + %% ===== Client components ===== |
| 60 | + Places["Places"] |
| 61 | + LoginManager["Login Manager"] |
| 62 | + TabbedBrowser["Tabbed Browser"] |
| 63 | + AddonManager["Add-on Manager"] |
| 64 | + ExtensionBridge["Extension Storage Bridge"] |
| 65 | +
|
| 66 | + %% ===== Sync engines ===== |
| 67 | + Bookmarks["Bookmarks"] |
| 68 | + History["History"] |
| 69 | + Passwords["Passwords"] |
| 70 | +
|
| 71 | + CreditCards["Credit cards"] |
| 72 | + Addresses["Addresses"] |
| 73 | + OpenTabs["Open tabs"] |
| 74 | +
|
| 75 | + Addons["Add-ons"] |
| 76 | + Clients["Clients"] |
| 77 | +
|
| 78 | + %% ===== Sync internals ===== |
| 79 | + subgraph Sync["Sync"] |
| 80 | + HTTPClient["HTTP Client"] |
| 81 | + TokenClient["Tokenserver Client"] |
| 82 | + end |
| 83 | +
|
| 84 | + %% ===== Storage ===== |
| 85 | + SyncStorage[("Sync Storage Server")] |
| 86 | + TokenServer[("Tokenserver")] |
| 87 | + PushService["Push Service"] |
| 88 | +
|
| 89 | + subgraph FirefoxAccounts["Firefox Accounts Service"] |
| 90 | + PushIntegration["Push Integration"] |
| 91 | + FxAHTTP["HTTP Clients"] |
| 92 | + end |
| 93 | + subgraph Accounts |
| 94 | + MozillaPush[("Mozilla Push Server")] |
| 95 | + FxAAuth[("FxA Auth Server")] |
| 96 | + FxAOAuth[("FxA OAuth Server")] |
| 97 | + FxAProfile[("FxA Profile Server")] |
| 98 | + end |
| 99 | +
|
| 100 | + %% ===== Relationships ===== |
| 101 | + DB --> Places |
| 102 | + BookmarksMirror --> Places |
| 103 | + Places --> Bookmarks |
| 104 | + Places --> History |
| 105 | + LoginStorage <--> LoginManager |
| 106 | +
|
| 107 | + AutofillStorage --> CreditCards |
| 108 | + AutofillStorage --> Addresses |
| 109 | +
|
| 110 | + TabbedBrowser --> OpenTabs |
| 111 | + AddonManager --> Addons |
| 112 | + XPIDB --> AddonManager |
| 113 | + ExtensionBridge --> Clients |
| 114 | +
|
| 115 | + %% ===== Sync engine / Collections ===== |
| 116 | + Bookmarks --> Sync |
| 117 | + History --> Sync |
| 118 | + Passwords --> Sync |
| 119 | + CreditCards --> Sync |
| 120 | + Addresses --> Sync |
| 121 | + OpenTabs --> Sync |
| 122 | + Addons --> Sync |
| 123 | + Clients --> Sync |
| 124 | + HTTPClient --> Sync |
| 125 | + TokenClient <--> TokenServer |
| 126 | + SyncStorage <--> HTTPClient |
| 127 | +
|
| 128 | + %% ===== Push & Accounts ===== |
| 129 | + FirefoxAccounts --> PushIntegration |
| 130 | + FirefoxAccounts --> FxAHTTP |
| 131 | + FxAAuth <--> MozillaPush |
| 132 | +
|
| 133 | + PushIntegration --> PushService |
| 134 | + FxAHTTP --> FxAAuth |
| 135 | + FxAHTTP --> FxAOAuth |
| 136 | + FxAHTTP --> FxAProfile |
| 137 | + CredentialStorage --> FirefoxAccounts |
| 138 | +``` |
| 139 | + |
| 140 | +## Tokenserver |
| 141 | + |
| 142 | + |
| 143 | +The intent of this file is inspired by a very sensible [blog post](https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html) many developers are familiar with regarding the necessity to illustrate systems with clarity. Given Sync's complexity and interrelationships with other architectures, this |
| 144 | + |
0 commit comments