# md-khadimul-islam/brandtech_shop architecture

> Architecture diagram of the GitHub repository md-khadimul-islam/brandtech_shop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/md-khadimul-islam/brandtech_shop
- Repository: https://github.com/md-khadimul-islam/brandtech_shop

## Overview

1. **Overall shape**
   - This is a cross-platform Flutter client app, with one shared Dart codebase under `lib/` and standard platform runner shells for Android, iOS, web, macOS, Windows, and Linux.
   - The architecture is explicitly layered around **core** and **features**, following a clean-architecture style.

2. **App bootstrap and shell**
   - `lib/main.dart` is the entry point that wires the app together.
   - The app shell likely sets up global providers, theme state, routing, and shared services before rendering feature screens.

3. **Core subsystem**
   - `lib/core/` holds app-wide infrastructure that is reused by all features:
     - `constants/` for strings and app constants
     - `errors/` for shared exception/failure types
     - `network/` for `Dio` HTTP and connectivity checking
     - `router/` for global `GoRouter` configuration
     - `services/` for shared UI services like snackbars
     - `theme/` for light/dark theme definitions and theme state
   - This is the main boundary separating reusable platform/app concerns from feature logic.

4. **Navigation boundary**
   - Routing is centralized in `lib/core/router/app_router.dart`.
   - Screens are navigated through `go_router`, with custom transitions mentioned in the README.
   - The routed destinations are the feature screens, mainly home, product details, and favorites.

5. **Products feature: end-to-end data flow**
   - The products module is the primary online data path:
     - `data/datasources/product_remote_datasource.dart` calls the public FakeStore API through `Dio`
     - `data/models/product_model.dart` maps JSON into app data objects
     - `data/repositories/product_repository_impl.dart` bridges data access to domain
     - `domain/usecases/get_products_usecase.dart` exposes the product-fetching operation
     - `presentation/providers/products_provider.dart` drives UI state
     - `presentation/screens/home_screen.dart` and `product_details_screen.dart` render the result
   - This is the main request/response pipeline in the app.

6. **Products UI composition**
   - The product UI is split into reusable widgets:
     - product cards
     - shimmer loading placeholders
     - error-state views
   - The home screen includes product grid browsing, search/filter behavior, and pull-to-refresh.
   - The details screen shows a product’s full information and supports favorite toggling.

7. **Favorites feature: local persistence flow**
   - Favorites are stored locally and do not depend on the remote API at runtime.
   - The flow is:
     - `data/datasources/favorites_local_datasource.dart` uses Hive
     - `data/repositories/favorites_repository_impl.dart` abstracts persistence operations
     - `presentation/providers/favorites_provider.dart` manages favorite state
     - `presentation/screens/favorite_screen.dart` shows the saved items
   - This subsystem is the main offline/stateful boundary in the app.

8. **State management model**
   - The app uses Riverpod throughout, with generated provider files under `*.g.dart`.
   - Providers act as the bridge between UI and repositories/use cases, keeping widgets mostly declarative.
   - The codegen indicates `riverpod_annotation`/`build_runner` are part of the architecture, not just tooling.

9. **Data, errors, and offline behavior**
   - `lib/core/network/connectivity_checker.dart` is used to distinguish connectivity problems from other failures.
   - Shared failure/exception classes in `core/errors/` flow upward into UI error states, including retry actions.
   - This separation means the UI can present specific “no internet” and “server error” experiences rather than generic failures.

10. **Theme and app preferences**
   - Theme is treated as application-wide state through `core/theme/theme_provider.dart`.
   - The README indicates dark mode preference is persisted in Hive, so the theme subsystem has both UI and local-storage responsibilities.
   - This is another cross-feature state boundary similar to favorites, but global rather than domain-specific.

11. **Shared UX services**
   - Snackbar behavior is centralized in `core/services/snackbar_service.dart`, which suggests transient messaging is handled outside individual screens.
   - Extensions and string helpers in `core/extensions/` provide small shared presentation utilities.

12. **External dependencies that matter architecturally**
   - **FakeStore API** is the only remote backend; there is no custom server in this repo.
   - **Hive** provides local persistence for favorites and theme preference.
   - **Dio** handles HTTP.
   - **connectivity_plus** informs network-aware error handling.
   - **cached_network_image**, **shimmer**, and **flutter_rating_bar** support key product-listing UI behaviors.

13. **Platform layer**
   - The native Android/iOS/macos/windows/linux/web directories are mostly standard Flutter runners and build scaffolding.
   - There is no sign of heavy native business logic; the architecture is overwhelmingly shared-Dart with minimal platform-specific code.

14. **Diagram takeaway**
   - The cleanest architecture diagram would show:
     - a single Flutter UI shell
     - two main feature domains: **Products** and **Favorites**
     - a shared **Core** layer underneath
     - remote FakeStore API on the products side
     - Hive local storage on the favorites/theme side
     - Riverpod as the state bridge between repositories/use cases and screens.

Main entry points: [`lib/main.dart`](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/main.dart) (main.dart), [`lib/features/products/presentation/providers/products_provider.dart`](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/providers/products_provider.dart) (Products provider), [`lib/core/router/app_router.dart`](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/router/app_router.dart) (Router), [`lib/features/products/data/datasources/product_remote_datasource.dart`](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/datasources/product_remote_datasource.dart) (Product API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Flutter App"]
  node_main["main.dart<br/>entrypoint<br/>[main.dart]"]
end

subgraph group_core["Core"]
  node_router["Router<br/>navigation<br/>[app_router.dart]"]
  node_theme["Theme<br/>app state"]
  node_dio["Dio client<br/>http setup<br/>[dio_client.dart]"]
  node_connectivity["Connectivity<br/>network check"]
  node_snackbar["Snackbar<br/>ui service"]
  node_errors["Failures<br/>error types<br/>[failures.dart]"]
  node_constants["Constants<br/>shared config<br/>[app_constants.dart]"]
end

subgraph group_products["Products"]
  node_product_ds["Product API<br/>remote datasource"]
  node_product_model["Product model<br/>json model<br/>[product_model.dart]"]
  node_product_repo["Product repo<br/>repository impl"]
  node_product_entity["Product<br/>domain entity"]
  node_get_products["Get products<br/>use case"]
  node_products_provider["Products provider<br/>riverpod state"]
  node_home["Home screen<br/>products UI<br/>[home_screen.dart]"]
  node_details["Details screen<br/>products UI"]
end

subgraph group_favorites["Favorites"]
  node_favorites_ds["Favorites store<br/>local datasource"]
  node_favorites_repo["Favorites repo<br/>repository impl"]
  node_favorites_provider["Favorites provider<br/>riverpod state"]
  node_favorites_screen["Favorites screen<br/>favorites UI"]
end

subgraph group_platform["Platforms"]
  node_android["Android<br/>platform shell<br/>[MainActivity.kt]"]
  node_ios["iOS<br/>platform shell<br/>[AppDelegate.swift]"]
end

node_main -->|"configures"| node_router
node_main -->|"provides"| node_theme
node_main -->|"wires"| node_products_provider
node_main -->|"wires"| node_favorites_provider
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_details
node_router -->|"routes to"| node_favorites_screen
node_product_ds -->|"uses"| node_dio
node_product_ds -->|"checks"| node_connectivity
node_product_ds -->|"maps"| node_product_model
node_product_model -->|"adapts to"| node_product_entity
node_product_repo -->|"fetches from"| node_product_ds
node_product_repo -->|"returns"| node_product_entity
node_get_products -->|"depends on"| node_product_repo
node_products_provider -->|"invokes"| node_get_products
node_products_provider -->|"handles"| node_errors
node_home -->|"reads"| node_products_provider
node_home -->|"uses"| node_snackbar
node_details -->|"reads"| node_products_provider
node_details -->|"toggles"| node_favorites_provider
node_favorites_repo -->|"persists via"| node_favorites_ds
node_favorites_provider -->|"depends on"| node_favorites_repo
node_favorites_screen -->|"reads"| node_favorites_provider
node_favorites_ds -.->|"shares storage pattern with"| node_theme
node_android -->|"hosts"| node_main
node_ios -->|"hosts"| node_main

click node_main "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/main.dart"
click node_router "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/router/app_router.dart"
click node_theme "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/theme/theme_provider.dart"
click node_dio "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/network/dio_client.dart"
click node_connectivity "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/network/connectivity_checker.dart"
click node_snackbar "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/services/snackbar_service.dart"
click node_errors "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/errors/failures.dart"
click node_constants "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/constants/app_constants.dart"
click node_product_ds "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/datasources/product_remote_datasource.dart"
click node_product_model "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/models/product_model.dart"
click node_product_repo "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/repositories/product_repository_impl.dart"
click node_product_entity "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/domain/entities/product_entity.dart"
click node_get_products "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/domain/usecases/get_products_usecase.dart"
click node_products_provider "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/providers/products_provider.dart"
click node_home "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/screens/home_screen.dart"
click node_details "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/screens/product_details_screen.dart"
click node_favorites_ds "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/data/datasources/favorites_local_datasource.dart"
click node_favorites_repo "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/data/repositories/favorites_repository_impl.dart"
click node_favorites_provider "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/presentation/providers/favorites_provider.dart"
click node_favorites_screen "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/presentation/screens/favorite_screen.dart"
click node_android "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/android/app/src/main/kotlin/com/example/brandtech_shop/MainActivity.kt"
click node_ios "https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/ios/Runner/AppDelegate.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main toneBlue
class node_router,node_theme,node_dio,node_connectivity,node_snackbar,node_errors,node_constants toneAmber
class node_product_ds,node_product_model,node_product_repo,node_product_entity,node_get_products,node_products_provider,node_home,node_details toneMint
class node_favorites_ds,node_favorites_repo,node_favorites_provider,node_favorites_screen toneRose
class node_android,node_ios toneIndigo
```

## Components

### Flutter App

Shared Dart app shell and platform runners

- [main.dart](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/main.dart): entrypoint · App bootstrap and top-level wiring · `lib/main.dart`

### Core

Reusable app-wide infrastructure

- [Router](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/router/app_router.dart): navigation · Central app routing and transitions · `lib/core/router/app_router.dart`
- [Theme](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/theme/theme_provider.dart): app state · Global light/dark theme state · `lib/core/theme/theme_provider.dart`
- [Dio client](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/network/dio_client.dart): http setup · Shared HTTP client configuration · `lib/core/network/dio_client.dart`
- [Connectivity](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/network/connectivity_checker.dart): network check · Connectivity detection for offline handling · `lib/core/network/connectivity_checker.dart`
- [Snackbar](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/services/snackbar_service.dart): ui service · Central transient messaging service · `lib/core/services/snackbar_service.dart`
- [Failures](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/errors/failures.dart): error types · Shared exceptions and failures · `lib/core/errors/failures.dart`
- [Constants](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/core/constants/app_constants.dart): shared config · App-wide strings and constants · `lib/core/constants/app_constants.dart`

### Products

Remote catalog browsing and details flow

- [Product API](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/datasources/product_remote_datasource.dart): remote datasource · Fetches products from FakeStore API · `lib/features/products/data/datasources/product_remote_datasource.dart`
- [Product model](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/models/product_model.dart): json model · Maps API JSON into app data objects · `lib/features/products/data/models/product_model.dart`
- [Product repo](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/data/repositories/product_repository_impl.dart): repository impl · Bridges remote data to domain · `lib/features/products/data/repositories/product_repository_impl.dart`
- [Product](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/domain/entities/product_entity.dart): domain entity · Core product domain object · `lib/features/products/domain/entities/product_entity.dart`
- [Get products](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/domain/usecases/get_products_usecase.dart): use case · Domain operation for loading products · `lib/features/products/domain/usecases/get_products_usecase.dart`
- [Products provider](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/providers/products_provider.dart): riverpod state · Drives product loading and UI state · `lib/features/products/presentation/providers/products_provider.dart`
- [Home screen](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/screens/home_screen.dart): products UI · Grid browsing, search, refresh, and loading states · `lib/features/products/presentation/screens/home_screen.dart`
- [Details screen](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/products/presentation/screens/product_details_screen.dart): products UI · Full product view with favorite toggle · `lib/features/products/presentation/screens/product_details_screen.dart`

### Favorites

Local saved-items flow

- [Favorites store](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/data/datasources/favorites_local_datasource.dart): local datasource · Hive-backed favorite persistence · `lib/features/favorites/data/datasources/favorites_local_datasource.dart`
- [Favorites repo](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/data/repositories/favorites_repository_impl.dart): repository impl · Abstracts local favorite persistence · `lib/features/favorites/data/repositories/favorites_repository_impl.dart`
- [Favorites provider](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/presentation/providers/favorites_provider.dart): riverpod state · Manages saved-item state · `lib/features/favorites/presentation/providers/favorites_provider.dart`
- [Favorites screen](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/lib/features/favorites/presentation/screens/favorite_screen.dart): favorites UI · Displays saved products · `lib/features/favorites/presentation/screens/favorite_screen.dart`

### Platforms

Native runner shells

- [Android](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/android/app/src/main/kotlin/com/example/brandtech_shop/MainActivity.kt): platform shell · Native Android runner shell · `android/app/src/main/kotlin/com/example/brandtech_shop/MainActivity.kt`
- [iOS](https://github.com/md-khadimul-islam/brandtech_shop/blob/khadimul/ios/Runner/AppDelegate.swift): platform shell · Native iOS runner shell · `ios/Runner/AppDelegate.swift`

## Connections

- main.dart → Router: configures · Bootstraps app navigation
- main.dart → Theme: provides · Sets up global theme state
- main.dart → Products provider: wires · Connects UI state into the app shell
- main.dart → Favorites provider: wires · Connects favorites state into the app shell
- Router → Home screen: routes to · Primary landing screen
- Router → Details screen: routes to · Product details destination
- Router → Favorites screen: routes to · Favorites destination
- Product API → Dio client: uses · Performs HTTP requests through shared client
- Product API → Connectivity: checks · Separates offline from server failures
- Product API → Product model: maps · Converts API payloads into models
- Product model → Product: adapts to · Bridges data and domain representations
- Product repo → Product API: fetches from · Delegates remote access
- Product repo → Product: returns · Exposes domain objects upward
- Get products → Product repo: depends on · Loads products through repository
- Products provider → Get products: invokes · Triggers product fetching
- Products provider → Failures: handles · Surfaces failures to UI state
- Home screen → Products provider: reads · Renders catalog state
- Home screen → Snackbar: uses · Shows transient actions and messages
- Details screen → Products provider: reads · Uses selected product state
- Details screen → Favorites provider: toggles · Adds or removes favorites
- Favorites repo → Favorites store: persists via · Stores favorites locally
- Favorites provider → Favorites repo: depends on · Manages saved-item operations
- Favorites screen → Favorites provider: reads · Displays saved products
- Favorites store → Theme: shares storage pattern with · Both are Hive-backed app preferences/state
- Android → main.dart: hosts · Android runner launches shared Dart app
- iOS → main.dart: hosts · iOS runner launches shared Dart app
