Skip to content

Commit e487c1e

Browse files
committed
refactor: Reorganize documentation structure with improved categorization
- Reorganize documentation into logical folder structure: - /architecture: High-level design and flow diagrams - /configuration: Version management and configuration guides - /examples: Practical examples and use cases - /migration: Migration guides and implementation summaries - Improve documentation discoverability and navigation - Maintain all existing content while providing better organization - Add proper categorization for different audience types - Ensure documentation follows enterprise documentation standards This reorganization addresses the need for better documentation structure and makes it easier for different stakeholders to find relevant information.
1 parent 0b0aa97 commit e487c1e

File tree

8 files changed

+716
-44
lines changed

8 files changed

+716
-44
lines changed
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
# Branch SDK Architecture: Delegate Pattern Flow Diagrams
2+
3+
**Document Type:** Technical Flow Diagrams
4+
**Created:** June 2025
5+
**Last Updated:** June 2025
6+
**Version:** 1.0
7+
**Author:** Branch SDK Team
8+
9+
---
10+
11+
## Document Purpose
12+
13+
This document provides detailed visual diagrams that illustrate how the delegate pattern works in practice within the Branch SDK modernization architecture. The diagrams cover everything from legacy API calls to modern core processing, including error flows, performance monitoring, and configuration.
14+
15+
## Legacy API Call Flow
16+
17+
This diagram shows the complete flow of a legacy API call through the delegation system:
18+
19+
```mermaid
20+
sequenceDiagram
21+
participant Client as Client App
22+
participant Legacy as Legacy API
23+
participant Wrapper as API Wrapper
24+
participant Manager as Preservation Manager
25+
participant Analytics as Usage Analytics
26+
participant Registry as API Registry
27+
participant Modern as Modern Core
28+
participant StateFlow as Reactive State
29+
30+
Note over Client: Developer calls legacy API
31+
Client->>Legacy: Branch.getInstance().setIdentity("user123")
32+
33+
Note over Legacy,Wrapper: API Preservation Layer
34+
Legacy->>Wrapper: LegacyBranchWrapper.setIdentity()
35+
Wrapper->>Manager: handleLegacyApiCall("setIdentity", ["user123"])
36+
37+
Note over Manager: Coordination Phase
38+
Manager->>Analytics: recordApiUsage("setIdentity", params)
39+
Manager->>Registry: getApiInfo("setIdentity")
40+
Registry-->>Manager: ApiMethodInfo (deprecation details)
41+
Manager->>Manager: logDeprecationWarning()
42+
43+
Note over Manager,Modern: Delegation Phase
44+
Manager->>Modern: delegateToModernCore("setIdentity", params)
45+
Modern->>Modern: identityManager.setIdentity("user123")
46+
Modern->>StateFlow: Update currentUser StateFlow
47+
48+
Note over Modern,Client: Response Flow
49+
Modern-->>Manager: Success/Failure Result
50+
Manager-->>Wrapper: Processed Result
51+
Wrapper-->>Legacy: Legacy-compatible Response
52+
Legacy-->>Client: Boolean/Original Return Type
53+
54+
Note over Analytics: Background Analytics
55+
Analytics->>Analytics: Update usage statistics
56+
Analytics->>Analytics: Track performance metrics
57+
```
58+
59+
## Component Interaction Detail
60+
61+
```mermaid
62+
graph LR
63+
subgraph "Client Layer"
64+
A[Legacy Client Code]
65+
end
66+
67+
subgraph "Preservation Layer"
68+
B[PreservedBranchApi]
69+
C[LegacyBranchWrapper]
70+
D[Callback Adapters]
71+
end
72+
73+
subgraph "Coordination Layer"
74+
E[BranchApiPreservationManager]
75+
F[Usage Analytics]
76+
G[API Registry]
77+
H[Version Config]
78+
end
79+
80+
subgraph "Modern Layer"
81+
I[ModernBranchCore]
82+
J[SessionManager]
83+
K[IdentityManager]
84+
L[LinkManager]
85+
M[EventManager]
86+
end
87+
88+
A --> B
89+
A --> C
90+
B --> E
91+
C --> E
92+
E --> F
93+
E --> G
94+
E --> H
95+
E --> I
96+
I --> J
97+
I --> K
98+
I --> L
99+
I --> M
100+
C --> D
101+
D --> E
102+
```
103+
104+
## API Lifecycle States
105+
106+
```mermaid
107+
stateDiagram-v2
108+
[*] --> Active: API is current
109+
Active --> Deprecated: Deprecation version reached
110+
Deprecated --> Warning: Usage triggers warnings
111+
Warning --> Removed: Removal version reached
112+
Removed --> [*]
113+
114+
Active: ✅ Full Support
115+
Deprecated: ⚠️ Deprecated with warnings
116+
Warning: 🚨 Enhanced warnings
117+
Removed: ❌ No longer available
118+
119+
note right of Deprecated
120+
API-specific timelines:
121+
- Critical: 5.0.0 → 7.0.0
122+
- Standard: 5.0.0 → 6.0.0
123+
- Problematic: 4.0.0 → 5.0.0
124+
end note
125+
```
126+
127+
## Migration Timeline Visualization
128+
129+
```mermaid
130+
gantt
131+
title Branch SDK API Migration Timeline
132+
dateFormat X
133+
axisFormat %s
134+
135+
section Critical APIs
136+
getInstance() :active, critical1, 0, 4
137+
getAutoInstance() :active, critical2, 0, 4
138+
generateShortUrl() :active, critical3, 0, 4
139+
140+
section Standard APIs
141+
setIdentity() :standard1, 0, 3
142+
resetUserSession() :standard2, 0, 3
143+
logout() :standard3, 0, 3
144+
145+
section Problematic APIs
146+
getFirstReferringParamsSync() :crit, problem1, 0, 2
147+
enableTestMode() :problem2, 0, 2
148+
149+
section Modern APIs
150+
ModernBranchCore :modern1, 1, 5
151+
Reactive StateFlow :modern2, 1, 5
152+
Coroutine Operations :modern3, 2, 5
153+
```
154+
155+
## Data Flow Architecture
156+
157+
```mermaid
158+
flowchart TD
159+
A[Legacy API Call] --> B{API Type?}
160+
161+
B -->|Static| C[PreservedBranchApi]
162+
B -->|Instance| D[LegacyBranchWrapper]
163+
164+
C --> E[BranchApiPreservationManager]
165+
D --> E
166+
167+
E --> F[Record Usage]
168+
E --> G[Check Deprecation Status]
169+
E --> H[Log Warnings]
170+
E --> I[Delegate to Modern Core]
171+
172+
I --> J{Operation Type?}
173+
174+
J -->|Session| K[SessionManager]
175+
J -->|Identity| L[IdentityManager]
176+
J -->|Links| M[LinkManager]
177+
J -->|Events| N[EventManager]
178+
J -->|Data| O[DataManager]
179+
J -->|Config| P[ConfigManager]
180+
181+
K --> Q[Update StateFlow]
182+
L --> Q
183+
M --> Q
184+
N --> Q
185+
O --> Q
186+
P --> Q
187+
188+
Q --> R[Return to Legacy Format]
189+
R --> S[Client Receives Response]
190+
191+
F --> T[Analytics Database]
192+
G --> U[Version Registry]
193+
H --> V[Deprecation Logs]
194+
```
195+
196+
## Performance Monitoring Flow
197+
198+
```mermaid
199+
sequenceDiagram
200+
participant Call as API Call
201+
participant Manager as Preservation Manager
202+
participant Analytics as Analytics Engine
203+
participant Registry as API Registry
204+
participant Reports as Reporting System
205+
206+
Call->>Manager: handleLegacyApiCall()
207+
Note over Manager: Start timing
208+
209+
Manager->>Analytics: recordApiCall(start_time)
210+
Manager->>Registry: getApiInfo()
211+
Manager->>Manager: Execute delegation
212+
213+
Note over Manager: End timing
214+
Manager->>Analytics: recordApiCallCompletion(duration, success)
215+
216+
Analytics->>Analytics: Update metrics
217+
Analytics->>Reports: Generate usage reports
218+
219+
Note over Reports: Background processing
220+
Reports->>Reports: Calculate trends
221+
Reports->>Reports: Identify hot paths
222+
Reports->>Reports: Flag performance issues
223+
```
224+
225+
## Error Handling Flow
226+
227+
```mermaid
228+
flowchart TD
229+
A[Legacy API Call] --> B[Preservation Manager]
230+
B --> C{Validation}
231+
232+
C -->|Valid| D[Delegate to Modern Core]
233+
C -->|Invalid| E[Log Error & Return Default]
234+
235+
D --> F{Modern Core Response}
236+
237+
F -->|Success| G[Record Success Metrics]
238+
F -->|Error| H[Handle Error Gracefully]
239+
240+
G --> I[Return Legacy-Compatible Result]
241+
H --> J[Log Error Details]
242+
H --> K[Return Legacy-Compatible Error]
243+
244+
I --> L[Client Receives Success]
245+
K --> L
246+
247+
J --> M[Analytics Database]
248+
M --> N[Error Tracking Reports]
249+
```
250+
251+
## Configuration Loading Flow
252+
253+
```mermaid
254+
sequenceDiagram
255+
participant App as Application
256+
participant Manager as Preservation Manager
257+
participant Factory as Version Config Factory
258+
participant Config as Properties Config
259+
participant Assets as Assets Folder
260+
261+
App->>Manager: getInstance(context)
262+
Manager->>Factory: createConfiguration(context)
263+
Factory->>Config: getInstance(context)
264+
265+
Config->>Assets: load("branch_version_config.properties")
266+
267+
alt File exists
268+
Assets-->>Config: Properties loaded
269+
Config->>Config: Parse configuration
270+
else File missing
271+
Config->>Config: Use default values
272+
end
273+
274+
Config-->>Factory: VersionConfiguration
275+
Factory-->>Manager: Configured instance
276+
Manager-->>App: Ready for use
277+
278+
Note over Config: Configuration includes:
279+
Note over Config: - deprecation.version
280+
Note over Config: - removal.version
281+
Note over Config: - migration.guide.url
282+
```
283+
284+
This diagram system shows how the delegate pattern works in practice, from the initial call to the final result, passing through all layers of preservation, coordination, and modern execution.

0 commit comments

Comments
 (0)