# rahul-badgujar/eshopee-flutter-ecommerce-app architecture

> Architecture diagram of the GitHub repository rahul-badgujar/eshopee-flutter-ecommerce-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahul-badgujar/eshopee-flutter-ecommerce-app
- Repository: https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app

## Overview

##### Project type and purpose
- This is a full-stack mobile eCommerce application built with Flutter for the UI and Firebase (Auth, Cloud Firestore, Storage) as the backend. Its purpose is to let users browse products, manage carts and addresses, place mock orders, upload products, and handle user profile operations.

##### File structure
- Top-level:
- android/ & ios/ – native project wrappers for Android and iOS platform integration and packaging
- lib/ – Dart source, organized into:
– components/ (reusable widgets)
– screens/ (one folder per feature/screen, each with sub-folders for UI, forms, provider models)
– services/ (Authentication, Data Streams, Firestore DB helpers, Storage access, Local file access)
– models/ (domain objects: Product, CartItem, User, etc.)
– wrappers/ (authentication state wrapper)
– exceptions/ (error handling for FirebaseAuth and file handling)
– app.dart & main.dart (entry points), theme, constants, utils, size_config

##### README
- Confirms the use of Flutter + Firebase (Auth, Firestore, Storage).
- Highlights features: authentication, product CRUD, categories, cart, favorites, orders, reviews, address management.
- No custom backend—the app communicates directly with Firebase SDKs.

##### Main components & their interactions
a. Presentation Layer (UI)
– lib/screens/*: Widgets for sign-in, sign-up, home, product details, cart, orders, profile screens
– lib/components/*: Reusable UI parts (buttons, fields, cards)
b. State Management / ViewModels
– provider_models under certain screens: hold screen state, expose data streams and service calls to UI
– authentification_wrapper: bootstraps user auth state before rendering app
c. Service Layer
– AuthenticationService: wraps Firebase Auth operations (sign-in, sign-up, reauth, password reset)
– DataStreams: subscribe to Firestore collections (products, cart items, orders, favorites, addresses)
– DatabaseHelpers: perform CRUD on Firestore documents (products, reviews, users)
– FirestoreFilesAccessService: upload/download product images to Firebase Storage
– LocalFilesAccessService: pick images from device for uploads
d. Data Layer
– Models (Product, CartItem, Address, Review, etc.) represent Firestore documents
e. External Services
– Firebase Authentication, Cloud Firestore, Firebase Storage
f. Platform Integration
– Android and iOS folders: Gradle, Xcode projects for building, plus platform-specific configuration (google-services.json, Info.plist, CocoaPods)

##### Architectural patterns & principles
- MVVM-style layering: UI (View) → Provider Models (ViewModel) → Services/Models (Model)
- Reactive streams: DataStreams classes use Firestore’s real-time listeners to push updates to UI
- Separation of concerns: UI components know nothing about how data is fetched; they rely on provider models and services
- Single-source services: each service is a singleton or static instance, injectable into provider models

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile App Layers
    subgraph "Mobile App"
        subgraph "Presentation Layer"
            Screens["Screens"]:::frontend
            Components["Components"]:::frontend
        end
        subgraph "State Layer"
            Providers["Provider Models"]:::state
            AuthWrapper["Auth Wrapper"]:::state
            Entry["main.dart"]:::state
            App["app.dart"]:::state
        end
        subgraph "Service Layer"
            AuthService["AuthenticationService"]:::service
            DataStreams["DataStreams"]:::service
            DBHelpers["DatabaseHelpers"]:::service
            StorageAccess["FirestoreFilesAccessService"]:::service
            LocalAccess["LocalFilesAccessService"]:::service
        end
        subgraph "Data Layer"
            Models["Models"]:::data
            Theme["Theme"]:::data
            Constants["Constants"]:::data
            Utils["Utils"]:::data
            SizeConfig["SizeConfig"]:::data
        end
    end

    %% Platform Modules
    subgraph "Platform Modules"
        Android["Android Module"]:::platform
        iOS["iOS Module"]:::platform
    end

    %% External Services
    subgraph "External Services"
        FirebaseAuth["Firebase Authentication"]:::external
        Firestore["Cloud Firestore"]:::external
        FirebaseStorage["Firebase Storage"]:::external
    end

    %% Device
    Device["Device Camera/Gallery & Local FS"]:::device

    %% Application Flow
    Entry -->|launch| App
    App -->|use| AuthWrapper

    %% UI to State
    Screens -->|"invokes action"| Providers
    Components -->|"renders UI"| Providers

    %% State to Services
    Providers -->|"call signIn()"| AuthService
    Providers -->|"listen to streams"| DataStreams
    Providers -->|"call upload flow"| LocalAccess

    %% Services to External/Device
    AuthService -->|"SDK calls"| FirebaseAuth
    DataStreams -->|"real-time listeners"| Firestore
    DBHelpers -->|"CRUD operations"| Firestore
    StorageAccess -->|"upload/download"| FirebaseStorage
    LocalAccess -->|"pickImage()"| Device

    %% Image upload sequence
    LocalAccess -->|"provide File"| StorageAccess
    StorageAccess -->|"return URL"| DBHelpers
    DBHelpers -->|"update document"| Firestore

    %% Data Layer connections
    Providers -->|"use models"| Models
    App -->|"load theme/constants/utils"| Theme
    App -->|"load theme/constants/utils"| Constants
    App -->|"load theme/constants/utils"| Utils
    App -->|"load theme/constants/utils"| SizeConfig

    %% Platform as boundaries
    Android --- App
    iOS --- App

    %% Click Events
    click Android "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/android/"
    click iOS "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/ios/"
    click Screens "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/screens/"
    click Components "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/components/"
    click Providers "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/screens/*/provider_models/"
    click AuthWrapper "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/wrappers/authentification_wrapper.dart"
    click AuthService "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/services/authentification/authentification_service.dart"
    click DataStreams "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/services/data_streams/"
    click DBHelpers "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/services/database/"
    click StorageAccess "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/services/firestore_files_access/firestore_files_access_service.dart"
    click LocalAccess "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/services/local_files_access/local_files_access_service.dart"
    click Models "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/tree/main/lib/models/"
    click Entry "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/main.dart"
    click App "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/app.dart"
    click Theme "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/theme.dart"
    click Constants "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/constants.dart"
    click Utils "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/utils.dart"
    click SizeConfig "https://github.com/rahul-badgujar/eshopee-flutter-ecommerce-app/blob/main/lib/size_config.dart"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,color:#000
    classDef state fill:#90EE90,stroke:#000,color:#000
    classDef service fill:#FFA500,stroke:#000,color:#000
    classDef data fill:#D3D3D3,stroke:#000,color:#000
    classDef external fill:#FF6347,stroke:#000,color:#000
    classDef platform fill:#DDA0DD,stroke:#000,color:#000
    classDef device fill:#A52A2A,stroke:#000,color:#fff
```
