Engineering guide
Architecture
Trace launch, dependency assembly, KYC capabilities, and navigation before changing code. Each step links back to audited source evidence.
main at 262db10975,200 app linesTrace the runtime
Follow one path at a time
Choose a map, then select a step to inspect its responsibility, outgoing path, source location, excerpt, and audited hash.
One root state machine owns configuration failure, splash, onboarding, phone auth, customer KYC bootstrap, and entry into ContentView.
9 traced steps
Selected step · entry
App entry
Alva_Online_TradingApp creates RootView unless hosted unit tests are running.
Leads to
Source evidence
Alva Online Trading/App/Alva_Online_TradingApp.swiftAlva_Online_TradingApp.bodyThe production scene installs RootView.
Mental model
Flutter to SwiftUI
Use familiar Flutter concepts as an entry point, while preserving the ownership and lifecycle rules already present in this SwiftUI app.
| Flutter | SwiftUI | How IC-Trade uses it | Caution | Evidence |
|---|---|---|---|---|
| Widget + build() | View + body | RootView, ContentView, and feature views are value descriptions; SwiftUI recreates them as state changes. | Do not treat a View struct as a long-lived controller. | 1 source
|
| StatefulWidget local State | @State / @FocusState | Tab selection, route arrays, filters, sheets, and search text stay local to the owning view. | Moving local state into a global object makes routing harder to reason about. | 1 source
|
| ValueChanged / controlled property | @Binding | Child controls bind to parent-owned form, filter, and selection values. | Use Binding only when the parent truly owns the value. | 1 source
|
| ChangeNotifier + Provider | ObservableObject + @StateObject/@ObservedObject | KYCApplicationStore is created once by AuthenticatedCustomerRoot; AppAuthSessionStore is observed from AppDependencies. | @StateObject owns lifetime; @ObservedObject observes an owner elsewhere. | 2 sources
|
| InheritedWidget / Provider read | @Environment / environment values | Locale, dismiss, Reduce Motion, and other platform values flow through the view tree. | AppDependencies is passed explicitly; do not invent a second environment-based dependency graph. | 1 source
|
| Navigator 2.0 / GoRouter | NavigationStack(path:) + Hashable route | ContentView keeps one [AppRoute] per tab and maps each case to a destination. | Do not collapse the paths into one global stack; tab history would leak across tabs. | 2 sources
|
| initState async kickoff | .task(id:) | Customer bootstrap and remote feature loads start with view lifetime and cancel when identity changes or the view disappears. | Keep UI mutation on MainActor and make requests idempotent. | 1 source
|
| SharedPreferences | @AppStorage / UserDefaults | Onboarding, language, watchlist preferences, and demo KYC persistence live locally. | Local persistence is not customer-account sync and must not be presented as durable backend data. | 2 sources
|
| UI isolate | @MainActor | Root state, dependency assembly, stores, and UI-facing repositories use main-actor isolation. | Do not block MainActor with parsing or network work; return to it only for UI state. | 2 sources
|