# ahmadmadani265/furniture_app architecture

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

- Interactive diagram: https://gitdiagram.com/ahmadmadani265/furniture_app
- Repository: https://github.com/ahmadmadani265/furniture_app

## Overview

##### Project Type and Purpose
- This is a multi-platform Flutter client app (“furniture_app”) targeting Android, iOS, Web, Linux, macOS, and Windows.
- The app’s main function is e-commerce for furniture: browsing categories, viewing product details, managing cart/favorites, and user authentication via Firebase.

##### File Structure
- Top-level platform folders: android/, ios/, web/, linux/, macos/, windows/ – embedding code for each target.
- lib/ holds all Dart code:
– lib/views & lib/widgets: UI layer
– lib/logic: Bloc/Cubit and Riverpod providers for state management
– lib/services: Firebase integration (auth, Firestore)
– lib/utils: routing, styling, theme, constants
– lib/main.dart: application entry point
- Configuration files: firebase_options.dart, android/app/google-services.json, ios/Runner/Info.plist for Firebase, pubspec.yaml for dependencies.

##### README Insights
- Standard Flutter “starter” project scaffold.
- Firebase is configured (firebase_options.dart) but no custom backend beyond Google’s Firebase services.

##### Main Components & Layers
- MainApp (lib/main.dart)
- AppRouter (lib/utils/app_router.dart)
- View Widgets (lib/views/** and lib/widgets/**)
- Platform Embedders: Android Runner, iOS Runner, Web index.html, Desktop Runners
- Cubits (auth_cubit.dart) & States (auth_state.dart)
- Riverpod Providers (count_total_provider, my_cart_provider, etc.)
- FirebaseAuthService (lib/services/firebase_auth.dart)
- Firestore Repositories (if present or future expansion)
- Local caches/providers (optional)
- Firebase Auth (Cloud Auth)
- Firebase Firestore (Cloud Firestore)
- Firebase Storage (if used for product images)
- Other external APIs (none currently, but placeholder)

##### Relationships & Data Flow
1. App start → main.dart → runApp → initialize Firebase (firebase_options.dart)
2. AppRouter directs to SignIn/SignUp or Home based on auth state (AuthCubit)
3. UI Widgets dispatch user actions to Cubits/Providers
4. Cubit/Provider calls FirebaseAuthService or Firestore API
5. Firebase returns async responses → update Cubit state → UI rebuilds
6. Cart/Favorites flows similarly via providers and may persist in Firestore or local storage

##### Architectural Patterns & Principles
- Layered/Clean Architecture: clear separation between UI, state management, and data
- Bloc/Cubit Pattern for authentication flows
- Riverpod/Provider for lightweight state and dependency injection
- “Repository” abstraction in services layer for easy unit testing and future backend swap
- Platform-agnostic code in lib/; platform folders only for embedding

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platform Embedders
    subgraph "Platform Embedders"
        direction TB
        AndroidRunner["Android Runner"]:::embed
        iOSRunner["iOS Runner"]:::embed
        WebEmbedder["Web Embedder"]:::embed
        LinuxRunner["Linux Runner"]:::embed
        macOSRunner["macOS Runner"]:::embed
        WindowsRunner["Windows Runner"]:::embed
    end

    %% Flutter Engine
    Engine["Flutter Engine"]:::engine

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        MainApp["MainApp"]:::ui
        AppRouter["AppRouter"]:::ui
        ViewWidgets["View Widgets"]:::ui
        ReusableWidgets["Reusable Widgets"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        AuthCubit["AuthCubit"]:::logic
        AuthState["AuthState"]:::logic
        Providers["Riverpod Providers"]:::logic
    end

    subgraph "Providers Details"
        direction TB
        CountProvider["count_total_provider"]:::logic
        ListFavorite["list_favorite_provider"]:::logic
        MyCart["my_cart_provider"]:::logic
        NotificationProvider["notification_provider"]:::logic
    end

    %% Data & Service Layer
    subgraph "Data & Service Layer"
        direction TB
        FirebaseAuthService["FirebaseAuthService"]:::service
        FirebaseConfig["firebase_options.dart"]:::service
    end

    %% External Layer
    subgraph "External Services"
        direction TB
        FirebaseAuth["Firebase Auth"]:::external
        Firestore["Firebase Firestore"]:::external
        Storage["Firebase Storage"]:::external
    end

    %% Connections
    AndroidRunner -->|embed| Engine
    iOSRunner -->|embed| Engine
    WebEmbedder -->|embed| Engine
    LinuxRunner -->|embed| Engine
    macOSRunner -->|embed| Engine
    WindowsRunner -->|embed| Engine

    Engine -->|runApp| MainApp
    MainApp -->|initializeRoutes| AppRouter
    AppRouter -->|navigate| ViewWidgets
    ViewWidgets -->|dispatchUserAction| AuthCubit
    ViewWidgets -->|dispatchUserAction| Providers

    AuthCubit -->|manageAuthState| AuthState
    Providers -->|provideState| CountProvider
    Providers -->|provideState| ListFavorite
    Providers -->|provideState| MyCart
    Providers -->|provideState| NotificationProvider

    AuthCubit -->|signInWithEmail| FirebaseAuthService
    CountProvider -->|fetchTotal| FirebaseAuthService
    ListFavorite -->|fetchFavorites| FirebaseAuthService
    MyCart -->|fetchCartItems| FirebaseAuthService
    NotificationProvider -->|subscribe| FirebaseAuthService

    FirebaseConfig -->|configures| FirebaseAuthService

    FirebaseAuthService -->|callAuth| FirebaseAuth
    FirebaseAuthService -->|callFirestore| Firestore
    FirebaseAuthService -->|uploadImages| Storage

    FirebaseAuth -->|response| FirebaseAuthService
    Firestore -->|response| FirebaseAuthService
    Storage -->|response| FirebaseAuthService

    FirebaseAuthService -->|updateState| AuthCubit
    FirebaseAuthService -->|updateProviders| Providers

    %% Click Events
    click MainApp "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/main.dart"
    click AppRouter "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/utils/app_router.dart"
    click ViewWidgets "https://github.com/ahmadmadani265/furniture_app/tree/main/lib/views/**"
    click ReusableWidgets "https://github.com/ahmadmadani265/furniture_app/tree/main/lib/views/widgets/**"
    click AndroidRunner "https://github.com/ahmadmadani265/furniture_app/blob/main/android/app/src/main/kotlin/com/example/furniture_app/MainActivity.kt"
    click iOSRunner "https://github.com/ahmadmadani265/furniture_app/blob/main/ios/Runner/AppDelegate.swift"
    click WebEmbedder "https://github.com/ahmadmadani265/furniture_app/blob/main/web/index.html"
    click LinuxRunner "https://github.com/ahmadmadani265/furniture_app/blob/main/linux/runner/main.cc"
    click macOSRunner "https://github.com/ahmadmadani265/furniture_app/blob/main/macos/Runner/MainFlutterWindow.swift"
    click WindowsRunner "https://github.com/ahmadmadani265/furniture_app/blob/main/windows/runner/main.cpp"
    click AuthCubit "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/auth_cubit.dart"
    click AuthState "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/auth_state.dart"
    click CountProvider "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/count_total_provider.dart"
    click ListFavorite "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/list_favorite_provider.dart"
    click MyCart "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/my_cart_provider.dart"
    click NotificationProvider "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/logic/notification_provider.dart"
    click FirebaseAuthService "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/services/firebase_auth.dart"
    click FirebaseConfig "https://github.com/ahmadmadani265/furniture_app/blob/main/lib/firebase_options.dart"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#000,stroke-width:1px
    classDef service fill:#FFA500,stroke:#000,stroke-width:1px
    classDef external fill:#F08080,stroke:#000,stroke-width:1px
    classDef embed fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef engine fill:#EEEEEE,stroke:#000,stroke-width:1px
```
