# arkefallen/foodie architecture

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

- Interactive diagram: https://gitdiagram.com/arkefallen/foodie
- Repository: https://github.com/arkefallen/foodie

## Overview

##### Project type and purpose
- This is a cross-platform Flutter mobile/web/desktop application (“Foodie”) for browsing restaurants via the Dicoding Restaurant API, viewing details, searching, writing reviews, managing favorites, toggling theme, and scheduling a daily reminder notification.

##### File structure
- Top-level folders:
- android, ios, linux, macos, windows, web – platform-specific shell and native integration
- lib – core Dart/Flutter code organized into data, provider, screens, theme, and util
- integration_test & test – automated end-to-end and unit/widget tests
- lib/data:
- datasource – services (network API, local DB, notification & preferences, background worker)
- model – DTOs mapping JSON from the restaurant API
- lib/provider: ChangeNotifier classes implementing state management for lists, details, search, favorites, reminders, theme, reviews
- lib/screens: UI pages and states for each use case, plus reusable widgets
- Configuration/build scripts: pubspec.yaml, Gradle/CMake files, XCode project files

##### README
- Confirms use of Dicoding Restaurant API, features (list, detail, search, review, notifications, theme, favorites), and how to run the Flutter app.

a. Main components
- Flutter Application (UI Layer)
– Screens & Widgets
– State Management (Providers)
- Domain/Data Layer
– Models (restaurant, review, preferences)
– Repositories / Services (RestaurantService, LocalDatabaseService, NotificationService, ReminderPreferencesService, ThemePreferencesService, WorkerService)
- External Services
– Dicoding Restaurant REST API
– Local SQLite/SharedPreferences or platform storage
– Platform Notification/Background Scheduler (Android WorkManager, iOS notifications, etc.)
b. Relationships & interactions
1. User taps UI → Provider method → calls RestaurantService (over HTTP) or LocalDatabaseService
2. RestaurantService fetches JSON → Model layer → Provider updates state → UI redraw
3. Review flow: UI → AddReviewProvider → RestaurantService.submitReview → API
4. Favorite flow: Provider updates LocalDatabaseService → persists favorites → Provider emits new state → UI updates
5. Daily reminder: WorkerService (platform scheduler) triggers NotificationService using stored ReminderPreferences → shows local notification
6. Theme toggle: UI Provider toggles ThemePreferencesService → writes prefs → Root widget rebuilds in new ThemeData
c. Architectural patterns
- Layered architecture (UI → State/Provider → Data/Service → External)
- MVVM-like separation: Views (Screens) observe ViewModels (Providers)
- Repository/Service pattern for data sources
d. Key technologies/frameworks
- Flutter/Dart
- Provider package for state management
- HTTP package (or Dio) for REST calls
- SharedPreferences/SQLite for local persistence
- Platform-specific notification and background scheduling APIs via Flutter plugins

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Shells
    subgraph "Platform Shells"
        Android["Android"]:::native
        iOS["iOS"]:::native
        Web["Web"]:::native
        Linux["Linux"]:::native
        macOS["macOS"]:::native
        Windows["Windows"]:::native
    end

    %% Flutter Engine
    FlutterEngine["Flutter Engine"]:::native

    %% UI Layer
    subgraph "UI Layer"  
        Screens["Screens & Widgets"]:::ui
        HomeScreen["Home Screen\n(Restaurant List)"]:::ui
        DetailScreen["Restaurant Detail Screen"]:::ui
        FavoriteScreen["Favorite Restaurants Screen"]:::ui
        SearchScreen["Search Restaurant Screen"]:::ui
        SettingsScreen["Settings Screen\n(Theme/Reminder)"]:::ui
        ReusableWidgets["Reusable UI Widgets"]:::ui
    end

    %% State Layer
    subgraph "State Layer"
        ListProvider["ListRestaurantsProvider"]:::state
        DetailProvider["DetailRestaurantProvider"]:::state
        SearchProvider["SearchRestaurantsProvider"]:::state
        AddReviewProvider["AddReviewProvider"]:::state
        FavoriteProvider["FavoriteRestaurantsProvider"]:::state
        ReminderProvider["DailyReminderProvider"]:::state
        ThemeProvider["ThemeSettingsProvider"]:::state
        BottomNavProvider["BottomNavigationProvider"]:::state
    end

    %% Data Layer
    subgraph "Data Layer"
        subgraph Services
            RestaurantService["RestaurantService"]:::data
            LocalDBService["LocalDatabaseService"]:::data
            NotificationService["NotificationService"]:::data
            ReminderPrefsService["ReminderPreferencesService"]:::data
            ThemePrefsService["ThemePreferencesService"]:::data
            WorkerService["WorkerService"]:::data
        end
        subgraph Models
            ListModel["ListRestaurantsModel"]:::model
            DetailModel["DetailRestaurantModel"]:::model
            SearchModel["SearchRestaurantModel"]:::model
            AddReviewModel["AddReviewModel"]:::model
            CustomerReviewModel["CustomerReviewModel"]:::model
            MenusModel["MenusModel & Categories"]:::model
            RestaurantModel["RestaurantModel"]:::model
        end
    end

    %% External Systems
    API["Dicoding Restaurant API"]:::external
    DB["Local Database\n(SQLite)"]:::data
    SP["SharedPreferences"]:::data
    OSN["OS Notification\nScheduler"]:::native

    %% Relationships
    Android & iOS & Web & Linux & macOS & Windows --> FlutterEngine
    FlutterEngine --> Screens
    Screens --> HomeScreen
    Screens --> DetailScreen
    Screens --> FavoriteScreen
    Screens --> SearchScreen
    Screens --> SettingsScreen
    Screens --> ReusableWidgets

    Screens --> ListProvider
    Screens --> DetailProvider
    Screens --> SearchProvider
    Screens --> AddReviewProvider
    Screens --> FavoriteProvider
    Screens --> ReminderProvider
    Screens --> ThemeProvider
    Screens --> BottomNavProvider

    ListProvider --> RestaurantService
    DetailProvider --> RestaurantService
    SearchProvider --> RestaurantService
    AddReviewProvider --> RestaurantService
    FavoriteProvider --> LocalDBService
    ReminderProvider --> WorkerService
    ReminderProvider --> ReminderPrefsService
    ThemeProvider --> ThemePrefsService
    ThemeProvider --> ThemePrefsService

    RestaurantService --> API
    LocalDBService --> DB
    NotificationService --> OSN
    WorkerService --> NotificationService
    ReminderPrefsService --> SP
    ThemePrefsService --> SP

    %% Click Events
    click Screens "https://github.com/arkefallen/foodie/tree/master/lib/screens"
    click ReusableWidgets "https://github.com/arkefallen/foodie/tree/master/lib/screens/widget"
    click HomeScreen "https://github.com/arkefallen/foodie/blob/master/lib/screens/home_screen.dart"
    click DetailScreen "https://github.com/arkefallen/foodie/blob/master/lib/screens/detail_restaurant_screen.dart"
    click FavoriteScreen "https://github.com/arkefallen/foodie/blob/master/lib/screens/favorite_restaurant_screen.dart"
    click SearchScreen "https://github.com/arkefallen/foodie/blob/master/lib/screens/search_restaurant_screen.dart"
    click SettingsScreen "https://github.com/arkefallen/foodie/blob/master/lib/screens/settings_screen.dart"
    click ListProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/list_restaurant_provider.dart"
    click DetailProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/detail_restaurant_provider.dart"
    click SearchProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/search_restaurants_provider.dart"
    click AddReviewProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/add_review_provider.dart"
    click FavoriteProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/favorite_restaurant_provider.dart"
    click ReminderProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/daily_reminder_provider.dart"
    click ThemeProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/theme_settings_provider.dart"
    click BottomNavProvider "https://github.com/arkefallen/foodie/blob/master/lib/provider/bottom_navigation_provider.dart"
    click RestaurantService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/restaurant_service.dart"
    click LocalDBService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/local_database_service.dart"
    click NotificationService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/notification_service.dart"
    click ReminderPrefsService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/reminder_preferences_service.dart"
    click ThemePrefsService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/theme_preferences_service.dart"
    click WorkerService "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/worker_service.dart"
    click ListModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/list_restaurants_model.dart"
    click DetailModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/detail_restaurant_model.dart"
    click SearchModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/search_restaurant_model.dart"
    click AddReviewModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/add_review_model.dart"
    click CustomerReviewModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/customer_review_model.dart"
    click MenusModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/menus_model.dart"
    click RestaurantModel "https://github.com/arkefallen/foodie/blob/master/lib/data/model/restaurant_model.dart"
    click DB "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/local_database_service.dart"
    click SP "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/theme_preferences_service.dart"
    click API "https://github.com/arkefallen/foodie/blob/master/lib/data/datasource/restaurant_service.dart"

    %% Styles
    classDef ui fill:#DDEBFF,stroke:#4F83CC
    classDef state fill:#E8F3D5,stroke:#89C53C
    classDef data fill:#FFF4CC,stroke:#EFC200
    classDef model fill:#FFE2E2,stroke:#E04E5F
    classDef native fill:#ECECEC,stroke:#A0A0A0
    classDef external fill:#FFF0F0,stroke:#E07E7E
```
