How tung204/dntu_focus works
Project Type and Purpose
• Project Type: Full-stack, cross-platform mobile/desktop/web application built with Flutter.
• Purpose: A productivity app combining Pomodoro timers, AI chat commands, and task scheduling/management, synchronized via Firebase and stored offline via Hive.
Main Architectural Components
a. Client Application (Flutter)
• Platforms: Android, iOS, Web, Windows, macOS, Linux.
• Layers inside the client:
• Presentation: Screens and widgets under lib/features/*/presentation and lib/core/widgets
• State Management: BLoC classes (lib/features/*/domain/*.dart using flutter_bloc) and Provider (in lib/core/themes)
• Domain/Business Logic: Cubits, state classes under lib/features/*/domain
• Data Layer: Repositories under lib/features/*/data (task_repository.dart, pomodoro_repository.dart, auth_repository.dart)
• Utilities & Core Services: Hive local storage, BackupService, FirebaseService, GeminiService, NotificationService in lib/core/services
• Routing/Navigation: lib/routes/app_routes.dart and lib/navigation/navigation_manager.dart
b. Local Storage
• Hive database for offline-first persistence (see lib/core/services/backup_service.dart and models under lib/features/tasks/data/models)
c. Cloud & External Services
• Firebase Firestore: Primary data sync for tasks/projects/tags
• Firebase Cloud Messaging: Push notifications for reminders
• Firebase Cloud Functions (functions/index.js): Any custom backend logic or triggers
• Google Gemini AI Service: Natural language processing for AI chat commands (gemini_service.dart)
• Third-Party APIs/Libraries: speech_to_text, flutter_dotenv (for GEMINI_API_KEY), google_fonts
d. Assets & Media
• Local media (audio files, splash video) in assets/images and assets/sounds for white-noise backgrounds
Relationships and Data Flows
• User interacts with Flutter UI → UI dispatches events to BLoC/Providers →
– BLoC calls Repositories →
○ Local: read/write via Hive
○ Remote: read/write via Firebase Firestore or Cloud Functions
○ AI: calls GeminiService (direct HTTP calls with API key)
• Cloud Functions may subscribe to Firestore triggers to process data or send push notifications.
• Firebase Messaging delivers notifications back to the client → NotificationService handles them.
• BackupService periodically syncs Hive data up to Firestore in the background.
Architectural Patterns & Principles
• Feature-based modularization: code organized by feature domain (auth, home, tasks, ai_chat, etc.)
• BLoC for unidirectional data flow and state management
• Repository pattern for data abstraction
• Offline-first strategy with Hive, fallback to Firestore when online
• Dependency injection via Provider for theming and environment config
Final Checklist
[ ] All major components represented
[ ] Interactions and data flows clearly annotated
[ ] Architectural patterns called out (BLoC, Repository, Offline-First)
[ ] Technology labels (Flutter, Firebase, Hive, Gemini) included