How dear-luca/echo works
Project Type & Purpose
• Echo is a *Kotlin Multiplatform* mobile app (Android + iOS) for *decentralized, GPS-based messaging* using aggregate computing (Collektive) and MQTT transport.
• It consists of:
• A shared Kotlin “commonMain” layer (business logic, gossip algorithms, models, serializers, network abstractions).
• Two platform UIs: Compose for Android, SwiftUI for iOS.
• Platform adapters for location & MQTT mailbox.
• CI/CD (Fastlane + GitHub Actions).
Top-Level Components
1. UI Layer
– Android: Compose Multiplatform (MainActivity.kt, Compose screens, viewmodels)
– iOS: SwiftUI (MainViewController.swift, ContentView.swift)
2. Business Logic Layer (commonMain)
– App.kt (entrypoint), ViewModels (NearbyDevicesViewModel), Models (ChatMessage, DeviceLocationHeartbeat)
– GossipAlgorithms (location-aware gradient gossip) via Collektive
– Serialization & Networking (AbstractSerializerMailbox, MqttMailbox)
3. Platform Adapters
– LocationServiceFactory & PlatformLocationService (android/ios implementations)
– LocationPermissionHandler (android/ios)
– MQTT mailbox binds to platform’s network stack (WebSockets over mobile network)
4. External Services
– GPS hardware & OS location APIs
– Public MQTT broker (message routing)
Relationships & Data Flow
• UI Layer ←→ Business Logic
• UI triggers ViewModel actions (e.g., “send message”, “request neighbors”)
• ViewModel exposes LiveState for UI to render (nearby devices, incoming messages)
• Business Logic → Gossip Algorithm Engine (Collektive)
• Applies aggregate computing rounds on neighbor data
• Business Logic → Platform Adapters
• Requests location updates from LocationService
• Publishes and subscribes to messages via MqttMailbox
• Platform Adapters → External Services
• LocationService queries GPS APIs
• MqttMailbox connects to public broker (over WebSockets/TCP)
Architectural Patterns & Principles
• Modular layering: UI / BL / Adapters / External
• Aggregate computing: Single global program compiles to local gossip execution
• Decentralized gossip: Peer-to-peer, no central coordinator
• Kotlin Multiplatform: Shared business logic, platform-specific UI & services
• MQTT transport: QoS and WebSocket support for mobile