mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-14 20:24:29 +01:00
* opt.: docs l10n Fixes #1035 * opt. * rm: redundant docs * rm: features chapter * opt.: docs l10n Fixes #1035 * fix
2.9 KiB
2.9 KiB
title, description
| title | description |
|---|---|
| Architecture | Architecture patterns and design decisions |
Server Box follows clean architecture principles with clear separation between data, domain, and presentation layers.
Layered Architecture
┌─────────────────────────────────────┐
│ Presentation Layer │
│ (lib/view/page/) │
│ - Pages, Widgets, Controllers │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Business Logic Layer │
│ (lib/data/provider/) │
│ - Riverpod Providers │
│ - State Management │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Data Layer │
│ (lib/data/model/, store/) │
│ - Models, Storage, Services │
└─────────────────────────────────────┘
Key Patterns
State Management: Riverpod
- Code Generation: Uses
riverpod_generatorfor type-safe providers - State Notifiers: For mutable state with business logic
- Async Notifiers: For loading and error states
- Stream Providers: For real-time data
Immutable Models: Freezed
- All data models use Freezed for immutability
- Union types for state representation
- Built-in JSON serialization
- CopyWith extensions for updates
Local Storage: Hive
- hive_ce: Community edition of Hive
- No manual
@HiveFieldor@HiveTypeneeded - Type adapters auto-generated
- Persistent key-value storage
Dependency Injection
Services and stores are injected via:
- Providers: Expose dependencies to UI
- GetIt: Service location (where applicable)
- Constructor Injection: Explicit dependencies
Data Flow
User Action → Widget → Provider → Service/Store → Model Update → UI Rebuild
- User interacts with widget
- Widget calls provider method
- Provider updates state via service/store
- State change triggers UI rebuild
- New state reflected in widget
Custom Dependencies
The project uses several custom forks to extend functionality:
- dartssh2: Enhanced SSH features
- xterm: Terminal emulator with mobile support
- fl_lib: Shared UI components and utilities
Threading
- Isolates: Heavy computation off main thread
- computer package: Multi-threading utilities
- Async/Await: Non-blocking I/O operations