How tw-bc-group/twallet works
Project Type and Purpose
• TWallet is a mobile-first digital wallet application built using Flutter. It supports blockchain token transactions (DC/EP), decentralized identifiers (DID), and includes a DApp browser interface.
• The README explains key concepts (digital wallet, DID, DApp) and clarifies that the app targets multiple platforms (Android, iOS) while leveraging Flutter’s cross-platform capabilities.
Analyzing the File Structure
• Top-Level Directories: The project includes platform-specific directories (“android”, “ios”), a “lib” folder with all the Dart source code, “assets” for images, fonts, dummy data, and “docs” for architecture decision records (ADRs). This clearly indicates a layered architecture.
• Inside “lib”, note:
• “views” – contains UI pages and components (presentation layer).
• “widgets” – encapsulates reusable UI components.
• “router” – manages routing with separate router handlers and declarations.
• “store” – houses state management (likely using GetX as seen from “lib/common/getx.dart”), which indicates an application/business logic layer.
• “service” – includes service classes (api_provider, blockchain, contract, firebase service, identity, pincode, etc.) that interact with external systems and perform business logic.
• “models” – defines data entities and DTOs with auto-generated serializers.
• Other files such as “pubspec.yaml”, various .dart files, and test cases further confirm a clean separation between UI, business logic, and data models.
a. Mobile Client (Flutter App):
• Two sub-nodes for Native Platforms (Android and iOS). Represent these as containers showing their native configuration and integration (e.g., “android”, “ios” folders).
• “lib” directory representing the bulk of Flutter code.
b. Presentation Layer (UI):
• “views” and “widgets” are the screens, dialogs, and UI components. Mark these as the front-end representation where user interactions occur.
• “router” for navigation among screens.
c. Business Logic / State Management Layer:
• “store” contains application state (e.g., wallet balances, identity, transactions) with GetX-based or similar state management.
• “common”, “l10n” (localization), and “generated” are supporting modules.
d. Service / Data Access Layer:
• “service” folder includes key services like API Provider, Blockchain, Contract, Identity, and even Firebase service for additional features.
• “models” represent the data transfer objects that flow between layers.
e. External Systems:
• Blockchain Network: Illustrate connections to the blockchain for transaction signing, smart contract interactions, and token operations.
• DID Services and Third-Party APIs: Show potential integrations for verification and decentralized identity functions.
• (Optionally) BLE module for payments under “lib/ble”, if it interacts with external devices.
Architectural Patterns and Design Principles
• The code follows a layered/multi-tiered architecture: UI (views, widgets) → State Management (store) → Service Layer (API clients and business logic) → External Systems (blockchain, identity, third-party services).
• There is clear separation of concerns which exemplifies the MVC (or MVVM/GetX) pattern used in Flutter.
• The project leverages auto-generated code (e.g., serializer.g.dart, various *.g.dart files) to ensure consistency in data management.
• Localization (l10n), theme management, and modular routing further enhance maintainability.