# samsongulma/ilink-online-market-place-mobile-application architecture

> Architecture diagram of the GitHub repository samsongulma/ilink-online-market-place-mobile-application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samsongulma/ilink-online-market-place-mobile-application
- Repository: https://github.com/samsongulma/ilink-online-market-place-mobile-application

## Overview

##### Project type and purpose
- This is a cross-platform mobile application built with Flutter and Dart.
- It serves as a “Customer-Service-Handler” storefront: users browse products, view details, add to cart, authenticate, and maintain profiles.
- The back-end is entirely handled by Google Firebase (Firestore for data, Firebase Auth for user management), supplemented by local storage (SharedPreferences).

##### File structure
- Top-level files:
- main.dart – application entry point.
- pubspec.yaml / pubspec.lock – Flutter dependencies and asset declarations.
- README.md – project overview.
- Directories:
- Admin/ – screens for administrator login and home (Admin role).
- userPages/ – user-facing screens (login, signup, home, details, posting, wish cart, profile, forgot password).
- service/ – data layer: database.dart (wraps Firestore calls), shared_pref.dart (wraps local SharedPreferences).
- widget/ – reusable UI components (widget_support.dart).
- assets/ – fonts and images used in the UI.

##### README
- Confirms Firebase Firestore as the database, Firebase Auth for authentication.
- Outlines features: product listing, details, cart, user authentication.
- Provides setup instructions for integrating google-services.json or GoogleService-Info.plist.

##### Main components and their interactions
a. Mobile Client (Flutter)
- UI Layer:
- Pages (in Admin/ and userPages/)
- Reusable Widgets (widget/)
- Business Logic / Service Layer (service/)
- Database service: CRUD operations on Firestore.
- SharedPref service: local caching of tokens or user settings.
b. External Services
- Firebase Firestore: stores product, user profile, cart data.
- Firebase Auth: handles sign-up, login, session.
c. Assets & Local Storage
- Local fonts/images (assets/) loaded by Flutter.
- SharedPreferences for offline caching and quick retrieval.

##### Architectural patterns & design principles
- Layered Architecture:
- Presentation (UI pages, widgets)
- Domain/Service (service layer abstracting Firebase and local storage)
- Data (Firestore + SharedPreferences)
- Single code base for both user and admin roles – role-based routing managed in main.dart.
- Dependency injection possible via passing service instances to pages (not shown but recommended).

## Diagram (Mermaid)

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

        %% Entry Point
        Main["main.dart"]:::config

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            AdminLogin["Admin Login Screen"]:::ui
            AdminHome["Admin Home Screen"]:::ui
            UserHome["Product Listing/Home"]:::ui
            UserDetails["Product Details"]:::ui
            UserPosting["Posting/New Product"]:::ui
            UserWishCart["Wish Cart"]:::ui
            UserProfile["User Profile"]:::ui
            UserLogin["Login Screen"]:::ui
            UserSignup["Signup Screen"]:::ui
            UserForgot["Forgot Password"]:::ui
            WidgetSupport["Shared UI Components"]:::ui
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            DatabaseService["ProductService (database.dart)"]:::service
            PrefService["PrefService (shared_pref.dart)"]:::service
        end

        %% Local Storage & Assets
        subgraph "Local Data & Assets"
            direction TB
            SharedPrefs[(SharedPreferences)]:::local
            AssetsFonts["Assets: Fonts"]:::local
            AssetsImages["Assets: Images"]:::local
        end
    end

    %% External Services
    subgraph "Firebase Services"
        direction TB
        Firestore[(Firebase Firestore)]:::external
        Auth[(Firebase Auth)]:::external
    end

    %% Configuration Files
    subgraph "Configuration"
        direction TB
        Pubspec["pubspec.yaml / pubspec.lock"]:::config
        ReadmeRoot["README.md"]:::config
        AdminReadme["Admin/README.md"]:::config
    end

    %% Relationships
    Main -->|"initializes UI"| AdminLogin
    Main -->|"initializes UI"| UserHome
    AdminLogin -->|"calls loginUser()"| DatabaseService
    UserLogin -->|"calls loginUser()"| Auth
    UserSignup -->|"calls signupUser()"| Auth
    UserForgot -->|"calls resetPassword()"| Auth
    UserHome -->|"fetchProducts()"| DatabaseService
    UserDetails -->|"getProductDetails()"| DatabaseService
    UserPosting -->|"addProduct()"| DatabaseService
    UserWishCart -->|"fetchCart()"| DatabaseService
    UserProfile -->|"updateProfile()"| DatabaseService
    WidgetSupport -.->|"UI support"| AdminHome
    AdminHome -->|"manageProducts()"| DatabaseService
    DatabaseService -->|"GET/POST data"| Firestore
    DatabaseService -->|"AUTH calls"| Auth
    DatabaseService -->|"CACHE userToken"| SharedPrefs
    PrefService -->|"read/write settings"| SharedPrefs
    AdminLogin -->|"load fonts/images"| AssetsFonts
    UserHome -->|"load fonts/images"| AssetsImages

    %% Click Events
    click Main "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/main.dart"
    click AdminLogin "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/Admin/admin_login.dart"
    click AdminHome "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/Admin/admin_home.dart"
    click AdminReadme "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/Admin/README.md"
    click UserHome "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/home.dart"
    click UserDetails "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/details.dart"
    click UserPosting "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/posting.dart"
    click UserWishCart "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/wishCart.dart"
    click UserProfile "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/profile.dart"
    click UserLogin "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/login.dart"
    click UserSignup "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/signup.dart"
    click UserForgot "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/userPages/forgotPassword.dart"
    click WidgetSupport "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/widget/widget_support.dart"
    click DatabaseService "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/service/database.dart"
    click PrefService "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/service/shared_pref.dart"
    click AssetsFonts "https://github.com/samsongulma/ilink-online-market-place-mobile-application/tree/main/assets/fonts"
    click AssetsImages "https://github.com/samsongulma/ilink-online-market-place-mobile-application/tree/main/assets/images"
    click Pubspec "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/pubspec.yaml"
    click ReadmeRoot "https://github.com/samsongulma/ilink-online-market-place-mobile-application/blob/main/README.md"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#036,stroke-width:1px
    classDef service fill:#C3E6CB,stroke:#060,stroke-width:1px
    classDef external fill:#FFD580,stroke:#E68A00,stroke-width:1px
    classDef local fill:#D3D3D3,stroke:#888,stroke-width:1px
    classDef config fill:#E1D5E7,stroke:#9370DB,stroke-width:1px
```
