How rickyricko302/flutter-search-book works
Project Type and Purpose
• This is a multi-platform Flutter application (“cariin_buku”) designed for searching and browsing books.
• It follows a Clean Architecture pattern: clear separation of presentation, domain, data, and infrastructure (core) layers.
• It uses Supabase (via supabase_provider) and a generic ApiService for network calls, plus Riverpod-style providers for state management.
High-Level Architecture Components
a. Presentation Layer
• Screens & Widgets (Flutter UI):
– SplashScreen, LoginScreen, SearchBookScreen, DetailBookScreen, etc.
• State Management:
– Notifiers (e.g., AuthNotifier, BookNotifier)
– Providers (auth_providers.dart, book_providers.dart)
• Routing: router.dart handles navigation.
b. Domain Layer
• Entities: book_entity.dart, genre_entity.dart, filter_entity.dart
• UseCases:
– Authentication (loginGoogle, userSignOut)
– Books (fetchGenre, fetchSearchBook)
• Repository Interfaces: auth_repository.dart, book_repository.dart
c. Data Layer
• DataSources (remote only):
– AuthRemoteDataSource (Google sign-in & supabase)
– BookRemoteDataSource (REST API via ApiService)
• Repository Implementations:
– AuthRepositoryImpl, BookRepositoryImpl
• Models & Mappers: filter_model, list_book_model, list_genre_model
d. Core/Infrastructure Layer
• Network: ApiService
• Providers: SupabaseProvider, OpenUrlExternalProvider
• Utilities: exception.dart, util.dart, theme.dart
e. External Services
• Supabase backend for authentication/data
• Third-party REST API for book data
• Device external URL opener
Interactions and Data Flow
• UI Screen triggers an action (e.g., “search for books”).
• Screen calls through Provider → Notifier → UseCase.
• UseCase invokes Repository Interface.
• RepositoryImpl delegates to DataSource.
• DataSource calls ApiService or Supabase SDK.
• Response flows back through layers, updating state in Notifier.
• UI rebuilds to reflect new state.