Mobile Client Architecture (learnway-mobile/)
The LearnWay mobile application (learnway-mobile/) serves as the primary touchpoint for learners, combining gamified course delivery, real-time multiplayer quiz battles, an intelligent conversational AI Mentor, and an embedded Web3 smart account wallet.
Core Application Modules
Key Mobile Features & User Journeys
1. The AI Mentor Tab
- Persistent Companion: Available from the main navigation bar. Learners can ask questions about active courses or general Web3 concepts.
- Context Awareness: The client attaches the current
courseId,lessonId, and user skill level to prompt requests. - Streaming Responses & Voice: Supports text chat and speech-to-text prompt submission with smooth rendering.
2. Interactive Slide & Quiz Engine
- Micro-Learning Slides: Renders rich media slides (text, syntax-highlighted code blocks, diagrams, video clips).
- Instant Feedback: Multiple-choice, drag-and-drop, and code-completion quizzes provide real-time explanations.
- Optimistic Updates: Progress and streak counters update locally before syncing to the backend.
3. Real-Time 1v1 Quiz Battles (WebSockets)
- Matchmaking Screen: Joins
/quiz-battlesnamespace, displaying an animated 30-second matchmaking radar. - Turn-Based Battle View: Synchronized countdown timers (15s per question), real-time opponent score animations, and final gem wager settlement.
- Bot Seamless Fallback: If no human opponent is found in 30 seconds, automatically transitions to a bot battle.
4. Embedded Web3 Smart Wallet & MPC Key Security (SecretSharingService)
LearnWay implements a non-custodial, seedless wallet experience powered by SLIP-39 Multi-Party Computation (MPC) Shamir Secret Sharing:
- 2-of-3 Threshold SLIP-39 Architecture:
- The master private key is generated client-side and split into 3 cryptographic SLIP-39 mnemonic shares.
- Any 2 of the 3 shares can recover the master key. A single share reveals zero cryptographic information about the underlying secret.
- Distribution of the 3 Shares:
- Share 1 (
localShare): Stored on the learner’s physical device inside hardware-backed secure storage (FlutterSecureStorageusingiOS KeychainandAndroid EncryptedSharedPreferences), encrypted with the user’s secret passphrase. - Share 2 (
backendShare1): Encrypted client-side using Argon2id key derivation + AES-GCM with the user’s passphrase/wallet context before being transmitted to the backend database. - Share 3 (
backendShare2/ Cloud Backup): Encrypted as a second independent Argon2id envelope and stored remotely on the backend server.
- Share 1 (
- Zero-Knowledge Security Guarantee:
- The server holds two encrypted envelopes (
backendShare1andbackendShare2), but neither can be decrypted without the user’s client-side passphrase. The backend has zero knowledge of the master key.
- The server holds two encrypted envelopes (
- Seedless Multi-Device & Account Recovery:
- Standard Session: Mobile client unlocks
localShare+ decryptsbackendShare1via PIN/passphrase to sign transactions. - Lost/New Device: The learner signs in via OAuth/OTP, downloads the two remote encrypted shares, inputs their personal passphrase to decrypt them, and restores their wallet instantly without manual 12-word seed phrases.
- Standard Session: Mobile client unlocks
- Gasless ERC-4337 Execution:
- Reconstructed keys sign UserOperations that are submitted to the hosted
/altobundler with gas sponsorship from the backendVerifyingPaymaster.
- Reconstructed keys sign UserOperations that are submitted to the hosted
5. In-App Purchases & Subscriptions
- Integrates RevenueCat for cross-platform Apple App Store (StoreKit 2) and Google Play Billing.
- Automatically refreshes user entitlement state upon successful purchase or restore.