@startuml skinparam componentStyle rectangle skinparam defaultTextAlignment center
title "iOS App Architecture (Clean + MVVM)"
package "Presentation Layer" { component "SwiftUI Views" as views component "ViewModels (ObservableObject)" as vms component "Coordinators" as coord }
package "Domain Layer" { component "Use Cases" as uc component "Entities" as entities component "Repository Protocols" as repo_proto }
package "Data Layer" { component "Repository Impls" as repo_impl component "Network (URLSession)" as network component "Local DB (Core Data / SwiftData)" as localdb component "Keychain" as kc component "File Cache" as fc }
package "Cross-cutting" { component "Analytics" as analytics component "Logger (OSLog)" as logger component "Error Handler" as eh }
@startuml skinparam componentStyle rectangle skinparam defaultTextAlignment center
title "Android App Architecture (MVVM + Hilt)"
package "UI Layer (Compose)" { component "Composables" as composables component "ViewModel" as vms component "Navigation" as nav }
package "Domain Layer" { component "UseCase" as uc component "Domain Model" as dm }
package "Data Layer" { component "Repository" as repo component "Retrofit (API)" as api component "Room (DB)" as room component "DataStore (Prefs)" as ds component "WorkManager (Background)" as wm }
package "DI (Hilt)" { component "Modules" as hilt }
@startuml skinparam componentStyle rectangle skinparam defaultTextAlignment center
title "Flutter App Architecture (BLoC)"
package "UI" { component "Widgets" as w component "Pages" as pages }
package "BLoC (State Management)" { component "BLoC" as bloc component "Events" as events component "States" as states }
package "Domain" { component "UseCases" as uc component "Entities" as e component "Repositories (abstract)" as repo_abs }
package "Data" { component "Repository Impl" as repo_impl component "Dio (HTTP)" as dio component "Drift (SQLite)" as drift component "Secure Storage" as ss component "Flutter Secure Storage" as fss }
package "Platform Channels" { component "MethodChannel" as mc }
pages --> w w --> bloc : "dispatch event" bloc --> events : "handle" bloc --> states : "emit" pages --> states : "listen"
actor "User" as User participant "UI" as UI participant "Local DB\n(SQLite/Room/Drift)" as LDB participant "Sync Engine" as Sync queue "Outbox Queue" as Outbox participant "API" as API queue "Server Event Stream" as SSE
User -> UI : ① 创建订单(无网络) UI -> LDB : ② 写本地 DB UI -> Outbox : ③ 入队待同步操作 UI --> User : ④ 立即显示订单(本地)
note over Sync : 后台检测网络恢复 Sync -> Outbox : ⑤ 取出待同步 Sync -> API : ⑥ POST /orders API --> Sync : ⑦ 200 + server_id Sync -> LDB : ⑧ 更新 server_id,标记 synced
participant "App Server" as Server participant "FCM (Firebase)" as FCM participant "APNs (Apple)" as APNs participant "Device" as Device
== Android == Server -> FCM : ① POST /messages {token, data, notification} FCM -> Device : ② Push via Google Play Services Device -> Device : ③ 显示通知 / 后台数据
participant "App" as App participant "Firebase Crashlytics" as Crashlytics participant "Firebase Performance" as Perf participant "Sentry" as Sentry participant "Datadog RUM" as DD