How yaolya/flutter-are-you-bored works
Project Type and Purpose
• This is a cross‑platform mobile/web application built with Flutter.
• It helps users discover random activities when they’re bored, save favorites locally, and remove saved items.
• It follows the BLoC (Cubit) pattern for state management and uses a local SQLite database (via sqflite) plus an external “Bored API” for network calls.
File Structure Analysis
• Top‐level directories:
• android/ and ios/ contain the native shell projects and platform integration.
• lib/ hosts all Dart source code, subdivided into:
– business_logic/ – Cubits + States for “activity” and “activities_list.”
– data/ – database service, network API client, data models, repositories (real and mock).
– ui/ – Flutter screens and widgets.
– main.dart – app entry point.
• assets/ – JSON animations and images.
• test/ – unit tests for cubits.
• Configuration/build: pubspec.yaml, Android Gradle files, Xcode project, CI workflow for tests.
README Insights
• Confirms BLoC pattern, sqflite for database, remote API usage, and a web deployment via GitHub Pages.
• Project structure block aligns with lib/ subdivisions.
a. Main Components
1. Presentation Layer (Flutter UI)
2. Business Logic Layer (ActivitiesListCubit, ActivityCubit)
3. Data Layer
– Repositories (ActivityRepository, Mock)
– Network Client (ActivityApi)
– Local Database Service (sqflite)
4. External Service (Bored API at boredapi.com)
5. Persistence (SQLite DB on device)
6. Platform Shells (Android, iOS, Web host)
b. Relationships & Interactions
• UI Widgets dispatch user events (e.g. “fetch new activity,” “save activity”) to BLoCs.
• BLoCs call into Repositories via an IActivityRepository interface.
• Repositories route calls to:
– ActivityApi (HTTP GET/POST) when fetching new activities.
– DatabaseService for CRUD on saved activities.
• Responses propagate back through the repository to the Cubit, which emits new State objects to the UI.
• CI workflow runs unit tests against cubits in test/ directory.
c. Architectural Patterns & Principles
• Layered/Clean Architecture: separation of UI, business logic, data.
• BLoC (Cubit) for predictable state management and testability.
• Dependency inversion via repository interface and mock implementations for unit testing.
• Single source of truth: Cubits own the state; UI is a pure function of state.
d. Key Technologies & Frameworks
• Flutter & Dart – UI toolkit and language
• flutter_bloc – BLoC/Cubit state management
• http or dio (inside ActivityApi) for network calls
• sqflite – SQLite database on device
• GitHub Actions CI for testing