How trieuluan/hui_application works
Project Type and Purpose
• This is a client-side, cross-platform Flutter application targeting mobile (Android/iOS), desktop (Windows/Mac/Linux), and web.
• It implements user authentication (login, registration, OTP) and navigation (splash, intro, home), backed by REST/Firebase services.
File Structure
• Top-level “android”, “ios”, “linux”, “macos”, “windows”, “web” folders: platform-specific embedding of the Flutter engine.
• “lib/” is the single Dart codebase, subdivided into:
• core/ (configuration, constants, networking, utilities, validators)
• features/auth/ (models, providers, screens, utils for authentication)
• routes/ (app routing definitions)
• screens/ (app-wide UI views: splash, intro, home)
• services/ (business logic helper classes, e.g., AuthManager)
• widgets/ (reusable UI components)
• Configuration files: firebase.json, google-services.json, platform Gradle/Xcode configs, pubspec.yaml.
README
• Standard Flutter scaffold; no custom architectural notes. The file tree reveals the real architecture: layered client app with network and persistence integration.
a. Main Components
1. Flutter Engine & Embedder Layers (per platform):
• Android (Kotlin MainActivity), iOS (Swift AppDelegate), Windows/Linux/Mac hosts.
2. Application Layer (Dart code in lib/):
• Presentation: Screens & Widgets
• State Management: Riverpod/Provider (auth_provider)
• Domain/Services: AuthManager, AuthService
• Data Layer: ApiClient, HTTP/REST, Firebase SDK
3. External Systems:
• Firebase Authentication / Firestore / REST APIs
• Remote Backend Endpoints (defined in core/constants/endpoints.dart)
b. Relationships & Data Flows
• User taps UI → Screen widget calls Provider → Provider invokes Service → Service uses ApiClient → HTTP request to Firebase/REST → Response returns up to Service → Provider updates state → UI rebuilds.
• Routing: main.dart → PlatformApp → MaterialApp (app_routes) → initialRoute (splash) → subsequent navigation.
• Auth persistence: auth_provider reads/writes local storage (SharedPreferences or secure storage via auth_persistence).
c. Architectural Patterns & Principles
• Layered architecture: Presentation → State → Domain (Services) → Data (API) → External.
• Single-codebase multi-platform embedding via Flutter embedder.
• Dependency inversion: higher layers depend on abstractions (AuthService interface).
• Separation of concerns: core/ vs. feature/ vs. widgets/.
d. Key Technologies & Frameworks
• Flutter & Dart
• Provider/Riverpod (state management)
• HTTP client or Dio via ApiClient
• Firebase SDK (auth, analytics)
• Platform channels (if any native code is invoked)
Detailed Elements
• Platform Embedders: Android, iOS, Windows, macOS, Linux, Web
• main.dart → PlatformApp → MaterialApp + app_routes
• Presentation Layer: splash_screen, intro_screen, login_screen, home_screen
• State Layer: auth_provider (noting use of Freezed for AuthState)
• Domain Layer: AuthManager, AuthService (token refresh, persistence)
• Data Layer: ApiClient (base URL, interceptors), endpoints constants
• External: Firebase Auth, any REST endpoints (e.g., defined in endpoints.dart), local persistence store
• Assets: animations, fonts, images (optional, for completeness)