# rickyricko302/flutter-search-book architecture

> Architecture diagram of the GitHub repository rickyricko302/flutter-search-book, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rickyricko302/flutter-search-book
- Repository: https://github.com/rickyricko302/flutter-search-book

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platforms
    subgraph "Platforms"
        direction TB
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        Web["Web"]:::platform
        Windows["Windows"]:::platform
        macOS["macOS"]:::platform
        Linux["Linux"]:::platform
    end
    Android -->|runs on| FlutterEngine
    iOS --> FlutterEngine
    Web --> FlutterEngine
    Windows --> FlutterEngine
    macOS --> FlutterEngine
    Linux --> FlutterEngine

    %% Flutter Engine
    FlutterEngine["Flutter Engine & Plugins"]:::engine --> PresentationLayer

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        style PresentationLayer fill:#E0F7FA,stroke:#0288D1,stroke-width:2px
        SplashScreen["SplashScreen"] 
        LoginScreen["LoginScreen"]
        SearchBookScreen["SearchBookScreen"]
        DetailBookScreen["DetailBookScreen"]
        AuthNotifier["AuthNotifier"]
        BookNotifier["BookNotifier"]
        AuthProviders["auth_providers.dart"]
        BookProviders["book_providers.dart"]
        Router["router.dart"]
        Assets["Assets (Lottie, Images)"]
        SplashScreen --> AuthNotifier
        LoginScreen --> AuthNotifier
        SearchBookScreen --> BookNotifier
        DetailBookScreen --> BookNotifier
        AuthNotifier --> AuthProviders
        BookNotifier --> BookProviders
        Router --> SplashScreen
    end
    PresentationLayer -->|1. calls UseCase| DomainLayer

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        style DomainLayer fill:#E8F5E9,stroke:#43A047,stroke-width:2px
        BookEntity["book_entity.dart"]
        GenreEntity["genre_entity.dart"]
        FilterEntity["filter_entity.dart"]
        LoginGoogle["login_google_usecase.dart"]
        UserSignOut["user_sign_out_usecase.dart"]
        FetchGenre["fetch_genre_usecase.dart"]
        FetchSearchBook["fetch_search_book_usecase.dart"]
        OpenUrlExternalUC["open_url_external_usecase.dart"]
        AuthRepositoryInterface["auth_repository.dart"]
        BookRepositoryInterface["book_repository.dart"]
        BookEntity --> LoginGoogle
        GenreEntity --> FetchGenre
        FilterEntity --> FetchSearchBook
        LoginGoogle --> AuthRepositoryInterface
        UserSignOut --> AuthRepositoryInterface
        FetchGenre --> BookRepositoryInterface
        FetchSearchBook --> BookRepositoryInterface
        OpenUrlExternalUC --> AuthRepositoryInterface
    end
    DomainLayer -->|2. calls Data| DataLayer

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        style DataLayer fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
        AuthRemoteDS["auth_remote_datasource.dart"]
        BookRemoteDS["book_remote_datasource.dart"]
        AuthRepoImpl["auth_repository_impl.dart"]
        BookRepoImpl["book_repository_impl.dart"]
        FilterModel["filter_model.dart"]
        ListBookModel["list_book_model.dart"]
        ListGenreModel["list_genre_model.dart"]
        AuthRemoteDS --> AuthRepoImpl
        BookRemoteDS --> BookRepoImpl
        AuthRepoImpl --> AuthRepositoryInterface
        BookRepoImpl --> BookRepositoryInterface
        FilterModel --> BookRemoteDS
        ListBookModel --> BookRemoteDS
        ListGenreModel --> BookRemoteDS
    end
    DataLayer -->|3. uses Core/Infra| CoreLayer

    %% Core/Infrastructure Layer
    subgraph "Core/Infrastructure Layer"
        direction TB
        style CoreLayer fill:#ECEFF1,stroke:#546E7A,stroke-width:2px
        ApiService["ApiService"]
        SupabaseProvider["supabase_provider.dart"]
        OpenUrlExternalProvider["open_url_external_provider.dart"]
        ExceptionUtil["exception.dart"]
        Util["util.dart"]
        Theme["theme.dart"]
        ApiService -->|HTTP calls| ExternalServices
        SupabaseProvider -->|SDK calls| ExternalServices
        OpenUrlExternalProvider -->|OS call| ExternalServices
    end
    CoreLayer -->|4. network to| ExternalServices

    %% External Services
    subgraph "External Services"
        direction TB
        style ExternalServices fill:#FFEBEE,stroke:#C62828,stroke-width:2px
        Supabase["Supabase Backend"]:::external
        RESTAPI["Third-party REST API"]:::external
        DeviceOS["Device OS (URL opener)"]:::external
    end

    %% Return flows
    ExternalServices -.->|response| CoreLayer
    CoreLayer -.->|data| DataLayer
    DataLayer -.->|entities| DomainLayer
    DomainLayer -.->|state| PresentationLayer

    %% Click Events
    click SplashScreen "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/splash_screen/presentation/screen/splash_screen.dart"
    click LoginScreen "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/presentation/screen/login_screen.dart"
    click SearchBookScreen "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/presentation/screen/search_book_screen.dart"
    click DetailBookScreen "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/presentation/screen/detail_book_screen.dart"
    click AuthNotifier "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/presentation/providers/auth_notifier.dart"
    click BookNotifier "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/presentation/providers/book_notifiers.dart"
    click AuthProviders "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/presentation/providers/auth_providers.dart"
    click BookProviders "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/presentation/providers/book_providers.dart"
    click Router "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/route/router.dart"
    click BookEntity "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/entities/book_entity.dart"
    click GenreEntity "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/entities/genre_entity.dart"
    click FilterEntity "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/entities/filter_entity.dart"
    click LoginGoogle "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/domain/usecase/login_google_usecase.dart"
    click UserSignOut "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/domain/usecase/user_sign_out_usecase.dart"
    click FetchGenre "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/usecase/fetch_genre_usecase.dart"
    click FetchSearchBook "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/usecase/fetch_search_book_usecase.dart"
    click AuthRepositoryInterface "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/domain/repositories/auth_repository.dart"
    click BookRepositoryInterface "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/domain/repositories/book_repository.dart"
    click AuthRemoteDS "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/data/datasources/auth_remote_datasource.dart"
    click BookRemoteDS "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/data/datasources/book_remote_datasource.dart"
    click AuthRepoImpl "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/authentication/data/repositories/auth_repository_impl.dart"
    click BookRepoImpl "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/data/repositories/book_repository_impl.dart"
    click FilterModel "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/data/model/filter_model.dart"
    click ListBookModel "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/data/model/list_book_model.dart"
    click ListGenreModel "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/features/books/data/model/list_genre_model.dart"
    click ApiService "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/network/api_service.dart"
    click SupabaseProvider "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/providers/supabase_provider.dart"
    click OpenUrlExternalProvider "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/providers/open_url_external_provider.dart"
    click ExceptionUtil "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/error/exception.dart"
    click Util "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/util.dart"
    click Theme "https://github.com/rickyricko302/flutter-search-book/blob/main/lib/core/theme.dart"

    %% Styles
    classDef platform fill:#F3E5F5,stroke:#8E24AA,stroke-width:1px
    classDef engine fill:#E1F5FE,stroke:#0277BD,stroke-width:1px
    classDef external fill:#FFEBEE,stroke:#C62828,stroke-width:1px
```
