Skip to content

Commit a108a0d

Browse files
authored
docs: architecture and system diagrams (#1973)
docs: architecture and system diagrams
1 parent a3ca41f commit a108a0d

File tree

4 files changed

+145
-0
lines changed

4 files changed

+145
-0
lines changed

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[Introduction](introduction.md)
99
[Application Configuration](config.md)
1010
[Docs and MdBook Notes](doc-notes.md)
11+
[Application Architecture](architecture.md)
1112

1213
- [Tokenserver](tokenserver/tokenserver.md)
1314
- [Tokenserver API](tokenserver/tokenserver_api.md)

docs/src/architecture.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Architecture
2+
3+
A high-level architectural overview of the Sync Service which includes Sync and Tokenserver.
4+
5+
## Syncstorage
6+
![image](assets/sync-architecture.png)
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+
![image](assets/tokenserver-architecture.png)
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+
69.5 KB
Loading
108 KB
Loading

0 commit comments

Comments
 (0)