Architecture Overview
Flutter Server Box follows a layered architecture with clear separation of concerns.
Architecture Layers
Section titled “Architecture Layers”┌─────────────────────────────────────────────────┐│ Presentation Layer (UI) ││ lib/view/page/, lib/view/widget/ ││ - Pages, Widgets, Controllers │└─────────────────────────────────────────────────┘ ↓┌─────────────────────────────────────────────────┐│ Business Logic Layer ││ lib/data/provider/ ││ - Riverpod Providers, State Notifiers │└─────────────────────────────────────────────────┘ ↓┌─────────────────────────────────────────────────┐│ Data Access Layer ││ lib/data/store/, lib/data/model/ ││ - Hive Stores, Data Models │└─────────────────────────────────────────────────┘ ↓┌─────────────────────────────────────────────────┐│ External Integration Layer ││ - SSH (dartssh2), Terminal (xterm), SFTP ││ - Platform-specific code (iOS, Android, etc.) │└─────────────────────────────────────────────────┘Application Foundation
Section titled “Application Foundation”Main Entry Point
Section titled “Main Entry Point”lib/main.dart initializes the app:
void main() { runApp( ProviderScope( child: MyApp(), ), );}Root Widget
Section titled “Root Widget”MyApp provides:
- Theme Management: Light/dark theme switching
- Routing Configuration: Navigation structure
- Provider Scope: Dependency injection root
Home Page
Section titled “Home Page”HomePage serves as navigation hub:
- Tabbed Interface: Server, Snippet, Container, SSH
- State Management: Per-tab state
- Navigation: Feature access
Core Systems
Section titled “Core Systems”State Management: Riverpod
Section titled “State Management: Riverpod”Why Riverpod?
- Compile-time safety
- Easy testing
- No Build context dependency
- Works across platforms
Provider Types Used:
StateProvider: Simple mutable stateAsyncNotifierProvider: Loading/error/data statesStreamProvider: Real-time data streams- Future providers: One-time async operations
Data Persistence: Hive CE
Section titled “Data Persistence: Hive CE”Why Hive CE?
- No native code dependencies
- Fast key-value storage
- Type-safe with code generation
- No manual field annotations needed
Stores:
SettingStore: App preferencesServerStore: Server configurationsSnippetStore: Command snippetsKeyStore: SSH keys
Immutable Models: Freezed
Section titled “Immutable Models: Freezed”Benefits:
- Compile-time immutability
- Union types for state
- Built-in JSON serialization
- CopyWith extensions
Cross-Platform Strategy
Section titled “Cross-Platform Strategy”Plugin System
Section titled “Plugin System”Flutter plugins provide platform integration:
| Platform | Integration Method |
|---|---|
| iOS | CocoaPods, Swift/Obj-C |
| Android | Gradle, Kotlin/Java |
| macOS | CocoaPods, Swift |
| Linux | CMake, C++ |
| Windows | CMake, C# |
Platform-Specific Features
Section titled “Platform-Specific Features”iOS Only:
- Home screen widgets
- Live Activities
- Apple Watch companion
Android Only:
- Background service
- Push notifications
- File system access
Desktop Only:
- Menu bar integration
- Multiple windows
- Custom title bar
Custom Dependencies
Section titled “Custom Dependencies”dartssh2 Fork
Section titled “dartssh2 Fork”Enhanced SSH client with:
- Better mobile support
- Enhanced error handling
- Performance optimizations
xterm.dart Fork
Section titled “xterm.dart Fork”Terminal emulator with:
- Mobile-optimized rendering
- Touch gesture support
- Virtual keyboard integration
fl_lib
Section titled “fl_lib”Shared utilities package with:
- Common widgets
- Extensions
- Helper functions
Build System
Section titled “Build System”fl_build Package
Section titled “fl_build Package”Custom build system for:
- Multi-platform builds
- Code signing
- Asset bundling
- Version management
Build Process
Section titled “Build Process”make.dart (version) → fl_build (build) → Platform output- Pre-build: Calculate version from Git
- Build: Compile for target platform
- Post-build: Package and sign
Data Flow Example
Section titled “Data Flow Example”Server Status Update
Section titled “Server Status Update”1. Timer triggers →2. Provider calls service →3. Service executes SSH command →4. Response parsed to model →5. State updated →6. UI rebuilds with new dataUser Action Flow
Section titled “User Action Flow”1. User taps button →2. Widget calls provider method →3. Provider updates state →4. State change triggers rebuild →5. New state reflected in UISecurity Architecture
Section titled “Security Architecture”Data Protection
Section titled “Data Protection”- Passwords: Encrypted with flutter_secure_storage
- SSH Keys: Encrypted at rest
- Host Fingerprints: Stored securely
- Session Data: Not persisted
Connection Security
Section titled “Connection Security”- Host Key Verification: MITM detection
- Encryption: Standard SSH encryption
- No Plain Text: Sensitive data never stored plain