# ahmednaeim1/style_sphere architecture

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

- Interactive diagram: https://gitdiagram.com/ahmednaeim1/style_sphere
- Repository: https://github.com/ahmednaeim1/style_sphere

## Overview

##### Project type and purpose
- This is a Flutter-based mobile app (Android + iOS) for a shopping/styling experience (“Style Sphere”), featuring authentication, product browsing, cart/checkout, a chatbot, VTO (virtual try-on), and user settings.
- It leverages Firebase (GoogleService-Info), RESTful APIs for selling & VTO, and integrates payment/shipment services.

##### File structure
- Top-level platform folders: android/, ios/ (native project files & Gradle/Xcode configs)
- lib/ contains all Dart code, split into:
– presentation/: UI screens, widgets, router
– businessLogic/: BLoC & Cubit classes (state management)
– data/: models + repositories (data access)
– constants.dart, main.dart (app bootstrap)
- pubspec.yaml defines dependencies (Flutter SDK, Firebase, BLoC, HTTP, etc.)

##### README
- We rely primarily on the file tree to infer layering & external services.

##### Main components
a. Presentation Layer
– Screens & Widgets (login, home, product details, cart, checkout, chatbot, VTO, settings)
– Router (presentation/router.dart)
b. State Management Layer
– BLoCs & Cubits (businessLogic/blocs & /cubits) handling user, products, cart, checkout, chatbot, VTO state
c. Data Layer
– Repositories (data/repositories) implementing CRUD and remote calls
– Models (data/models) representing domain objects
d. External Services & Data Sources
– Firebase Auth/Firestore (via google-services.json)
– REST API endpoints for selling (api_service.dart), VTO processing
– Payment gateway API (payment_repository)
– Shipment service API (shipment_repository)
e. Platform Channels / Native Code
– Android (android/app/src/main/kotlin)
– iOS (ios/Runner/AppDelegate.swift)
f. Assets Store

##### Relationships and interactions
- UI widgets dispatch events to BLoC/Cubit → BLoC/Cubit invokes corresponding repository → repository makes network/database calls → returns model objects → BLoC/Cubit emits new state → UI rebuilds.
- Authentication flows to Firebase Auth.
- Checkout flows split into Payment and Shipment sub-flows.
- Chatbot & VTO screens call external microservices via HTTP.

##### Architectural patterns & key design principles
- Layered architecture (Presentation → State → Data → External)
- Repository pattern abstracts data sources.
- BLoC/Cubit for unidirectional data flow (UI ← State).
- Dependency injection via constructors (e.g., injecting repositories into BLoCs).
- Separation of concerns: UI does not deal with raw HTTP or business logic.

##### Technologies, frameworks & libraries
- Flutter & Dart
- flutter_bloc / bloc
- Firebase Core, Auth, Firestore
- http / dio (for REST calls)
- json_serializable (for model serialization)
- Platform-specific code (Android/Kotlin, iOS/Swift)
- Asset management via pubspec.yaml

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Flutter App Container
    subgraph "Flutter App"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            UI["UI (Screens & Widgets)"]:::presentation
            Router["Router"]:::presentation
            AuthScreens["Authentication Screens"]:::presentation
            HomeCore["Home & Core Screens"]:::presentation
            CartScreen["Cart Screen"]:::presentation
            CheckoutScreens["Checkout & Confirmation Screens"]:::presentation
            ChatbotScreens["Chatbot Screens"]:::presentation
            VTOScreens["VTO Screens"]:::presentation
            SellingScreens["Selling Screens & API Service"]:::presentation
            SettingsScreens["Settings Screens"]:::presentation
            CommonWidgets["Common Widgets & Functions"]:::presentation
        end

        %% State Management Layer
        subgraph "State Management Layer"
            direction TB
            subgraph "BLoCs"
                direction TB
                Blocs["BLoC Classes"]:::state
            end
            subgraph "Cubits"
                direction TB
                Cubits["Cubit Classes"]:::state
            end
        end

        %% Data Layer
        subgraph "Data Layer"
            direction TB
            subgraph "Models"
                direction TB
                Models["Data Models"]:::data
            end
            subgraph "Repositories"
                direction TB
                Repos["Repositories"]:::data
            end
        end

    end

    %% External Services
    subgraph "External Services"
        direction TB
        Firebase["Firebase Auth/Firestore"]:::external
        SellingAPI["Selling REST API"]:::external
        VTOAPI["VTO REST API"]:::external
        PaymentAPI["Payment Gateway API"]:::external
        ShipmentAPI["Shipment Service API"]:::external
        ChatbotAPI["Chatbot API"]:::external
    end

    %% Assets Store
    subgraph "Assets"
        direction TB
        Fonts["Fonts"]:::assets
        Icons["Icons"]:::assets
        AuthData["Authentication UI Data"]:::assets
        Prefs["Preferences Definitions"]:::assets
        SettingsData["Settings Static Data"]:::assets
        VTOAssets["VTO Assets"]:::assets
    end

    %% Interactions
    UI -->|"dispatch Event"| Blocs
    UI -->|"dispatch Event"| Cubits
    Blocs -->|"call Repository"| Repos
    Cubits -->|"call Repository"| Repos
    Repos -->|"HTTP Request"| Firebase
    Repos -->|"HTTP Request"| SellingAPI
    Repos -->|"HTTP Request"| VTOAPI
    Repos -->|"HTTP Request"| PaymentAPI
    Repos -->|"HTTP Request"| ShipmentAPI
    Repos -->|"HTTP Request"| ChatbotAPI
    Firebase -->|"Response"| Repos
    SellingAPI -->|"Response"| Repos
    VTOAPI -->|"Response"| Repos
    PaymentAPI -->|"Response"| Repos
    ShipmentAPI -->|"Response"| Repos
    ChatbotAPI -->|"Response"| Repos
    Repos -->|"return Data"| Blocs
    Repos -->|"return Data"| Cubits
    Blocs -->|"emit State"| UI
    Cubits -->|"emit State"| UI
    Fonts --> UI
    Icons --> UI
    AuthData --> UI
    Prefs --> UI
    SettingsData --> UI
    VTOAssets --> UI

    %% Click Events
    click UI "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/presentation"
    click Router "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/router.dart"
    click AuthScreens "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/presentation/screens/Authentication"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/home.dart"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/splash_screen.dart"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/profile.dart"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/preferences.dart"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/products_details.dart"
    click HomeCore "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/search_result.dart"
    click CartScreen "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Cart/cart_page.dart"
    click CheckoutScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Settings/confirmation_page.dart"
    click ChatbotScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Chatbot/chatbot.dart"
    click ChatbotScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Chatbot/chatbot_results.dart"
    click VTOScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/VTO/VTO.dart"
    click VTOScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/VTO/loading_screen.dart"
    click VTOScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/VTO/results_screen.dart"
    click SellingScreens "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/presentation/screens/Selling"
    click SellingScreens "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Selling/api_service.dart"
    click SettingsScreens "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/presentation/screens/Settings"
    click CommonWidgets "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/presentation/constant_widgets"
    click CommonWidgets "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/functions/constant_functions.dart"
    click Blocs "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/businessLogic/blocs"
    click Cubits "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/businessLogic/cubits"
    click Models "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/data/models"
    click Repos "https://github.com/ahmednaeim1/style_sphere/tree/main/lib/data/repositories"
    click Firebase "https://github.com/ahmednaeim1/style_sphere/blob/main/android/app/google-services.json"
    click Firebase "https://github.com/ahmednaeim1/style_sphere/blob/main/ios/Runner/GoogleService-Info.plist"
    click SellingAPI "https://github.com/ahmednaeim1/style_sphere/blob/main/lib/presentation/screens/Selling/api_service.dart"
    click Fonts "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/fonts"
    click Icons "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/icons"
    click AuthData "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/authentication"
    click Prefs "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/preferences"
    click SettingsData "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/settings"
    click VTOAssets "https://github.com/ahmednaeim1/style_sphere/tree/main/assets/vto"

    %% Styles
    classDef presentation fill:#bbdefb,stroke:#1e88e5,color:#000
    classDef state fill:#c8e6c9,stroke:#43a047,color:#000
    classDef data fill:#ffe0b2,stroke:#fb8c00,color:#000
    classDef external fill:#eceff1,stroke:#90a4ae,color:#000
    classDef assets fill:#f3e5f5,stroke:#8e24aa,color:#000
```
