blockchain-flutter/README.md
StillHammer 5a8300c5ea Initial setup: Flutter blockchain explorer app
- Clean architecture with feature-based organization
- Riverpod state management, Dio HTTP, GoRouter navigation
- Dashboard, blocks, wallet, transactions, mining screens
- Dark crypto theme with JetBrains Mono font
2026-02-01 10:12:34 +08:00

101 lines
3.3 KiB
Markdown

# blockchain-flutter
Flutter app for blockchain explorer, wallet management, and mining. Connects to the blockchain node via REST API.
## Architecture
Clean Architecture with feature-based organization:
```
lib/
├── main.dart
├── core/
│ ├── network/
│ │ └── api_client.dart # Dio HTTP client setup
│ ├── theme/
│ │ └── app_theme.dart # Dark theme, crypto aesthetic
│ └── utils/
│ └── formatters.dart # Amount, hash, date formatting
├── features/
│ ├── dashboard/ # Home: chain stats, recent blocks
│ │ ├── dashboard_screen.dart
│ │ └── dashboard_provider.dart
│ ├── blocks/ # Block explorer (list + detail)
│ │ ├── blocks_screen.dart
│ │ ├── block_detail_screen.dart
│ │ └── blocks_provider.dart
│ ├── wallet/ # Create, view balance, list wallets
│ │ ├── wallet_screen.dart
│ │ └── wallet_provider.dart
│ ├── transactions/ # Send tx, pending list
│ │ ├── transactions_screen.dart
│ │ ├── send_tx_screen.dart
│ │ └── transactions_provider.dart
│ └── mining/ # Mine button, difficulty info
│ ├── mining_screen.dart
│ └── mining_provider.dart
└── routing/
└── app_router.dart # GoRouter navigation
```
## Tech Stack
| Component | Choice | Rationale |
|-----------|--------|-----------|
| State management | Riverpod | Less boilerplate than BLoC, familiar |
| HTTP client | Dio | Interceptors, retry support |
| Navigation | GoRouter | Declarative routing |
| Models | Freezed + json_serializable | Immutable data classes |
| Secure storage | flutter_secure_storage | Wallet private keys |
| Charts | fl_chart | Chain visualization |
| Real-time | Polling (5-10s) | Simple, no WebSocket needed |
## Features
- **Dashboard**: chain height, difficulty, block reward, recent blocks
- **Block Explorer**: browse blocks, view transactions per block
- **Wallet**: generate keypairs, check balances, manage multiple wallets
- **Transactions**: send signed transactions, view pending pool
- **Mining**: one-tap mining, difficulty display, reward info
## Screens
1. **Dashboard** - overview with chain stats and recent activity
2. **Blocks** - paginated block list with expandable details
3. **Block Detail** - full block info with transaction list
4. **Wallets** - wallet list with balances, create new
5. **Send Transaction** - form: from, to, amount, sign & submit
6. **Pending Transactions** - current mempool
7. **Mining** - mine button with result display
## Quick Start
```bash
# Install dependencies
flutter pub get
# Generate code (Freezed models)
dart run build_runner build --delete-conflicting-outputs
# Run (blockchain-node must be running on localhost:3000)
flutter run
# Run on web
flutter run -d chrome
```
## Configuration
Node URL is configured in `lib/core/network/api_client.dart`. Defaults to `http://localhost:3000`.
For Android emulator, use `http://10.0.2.2:3000` to reach host localhost.
## Related Repos
- [blockchain-core](../blockchain-core) - Core library + REST API node
- [blockchain-cli](../blockchain-cli) - Rust CLI tool
## License
MIT