# diivi/swapsta architecture

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

- Interactive diagram: https://gitdiagram.com/diivi/swapsta
- Repository: https://github.com/diivi/swapsta

## Overview

##### Project type and purpose
- This is a cross-platform Flutter client application (Android, iOS, Web, Windows) called “Swapsta.”
- Its primary purpose is to allow users to list “swappables,” browse items, initiate swaps, and manage swap history.
- It relies on external backend services (e.g., Firebase for authentication, data storage, Google Sign-In).

##### File structure
- Top-level platform folders:
- android/ (native Android wrapper and Gradle builds)
- ios/ (native iOS wrapper, Xcode project, Podfile)
- web/ (static web assets, HTML, CSS, JS)
- windows/ (CMake, native Windows runner)
- Core application code under lib/:
- lib/main.dart – Flutter entry point
- lib/models/ – domain models (Category, Swap, Swappable)
- lib/providers/ – state-management using Provider pattern (Auth, swappables, swaps, UI)
- lib/screens/ – UI pages (home, explore, profile, add item, swap details, auth)
- lib/widgets/ – reusable UI components (cards, lists, headers, dialogs)
- lib/globals.dart – global constants
- Configuration and assets:
- pubspec.yaml/lock – dependencies & assets
- assets/ and img/ – fonts and images
- Test harness: test/widget_test.dart

##### README for additional insights
- The README only contains a link to a Behance UI mockup. The image demonstrates the intended look & feel but provides no architectural details.
- No server-side code is present, so interactions with backend services must be via Flutter plugins (e.g., cloud_firestore, firebase_auth).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client Application"
        subgraph "Entry Point"
            Main["main.dart"]:::model
        end
        subgraph "Presentation Layer"
            Home["HomeScreen"]:::presentation
            Explore["ExploreScreen"]:::presentation
            Profile["ProfileScreen"]:::presentation
            AddItem["AddItemScreen"]:::presentation
            AuthScreen["AuthScreen"]:::presentation
            SwapDetails["SwapDetailsScreen"]:::presentation
            SwappableDetails["SwappableDetailsScreen"]:::presentation
            ImagePreview["ImagePreviewScreen"]:::presentation
            Feedback["FeedbackScreen"]:::presentation
            subgraph "Widgets"
                Widgets["Reusable Widgets"]:::presentation
            end
        end
        subgraph "Business Logic Layer"
            AuthProv["AuthProvider"]:::logic
            GoogleSignInProv["GoogleSignInService"]:::logic
            SwappablesProv["SwappablesProvider"]:::logic
            SentSwapsProv["SentSwapsProvider"]:::logic
            RecvSwapsProv["ReceivedSwapsProvider"]:::logic
            SwapHistoryProv["SwapHistoryProvider"]:::logic
            BottomNavProv["BottomNavVisibilityProvider"]:::logic
            ScreenNavProv["ScreenNavigationProvider"]:::logic
        end
        subgraph "Data Models"
            Category["Category"]:::model
            SwapModel["Swap"]:::model
            Swappable["Swappable"]:::model
        end
        subgraph "Service Layer"
            FirebaseAuth["FirebaseAuthPlugin"]:::service
            Firestore["CloudFirestorePlugin"]:::service
            Storage["CloudStoragePlugin"]:::service
            GoogleSignInPlugin["GoogleSignInPlugin"]:::service
        end
    end

    subgraph "Host Platforms"
        Android["Android"]:::platform
        iOS["iOS"]:::platform
        Web["Web"]:::platform
        Windows["Windows"]:::platform
    end

    subgraph "External Services"
        ExtAuth["Firebase Auth"]:::external
        ExtDB["Firestore Database"]:::external
        ExtStorage["Cloud Storage"]:::external
        ExtGoogleAPI["Google Sign-In API"]:::external
    end

    %% Application Flow
    Main --> Home
    Main --> Explore
    Main --> Profile
    Main --> AddItem
    Main --> AuthScreen
    Main --> SwapDetails
    Main --> SwappableDetails
    Main --> ImagePreview
    Main --> Feedback
    Main --> Widgets

    Home --> AuthProv
    Home --> SwappablesProv
    Home --> BottomNavProv

    Explore --> SwappablesProv

    Profile --> AuthProv
    Profile --> SwapHistoryProv

    AddItem --> AuthProv
    AddItem --> SwappablesProv

    AuthScreen --> AuthProv
    AuthScreen --> GoogleSignInProv

    SwapDetails --> SwappablesProv
    SwapDetails --> SentSwapsProv
    SwapDetails --> RecvSwapsProv

    SwappableDetails --> SwappablesProv

    %% Providers to Services
    AuthProv --> FirebaseAuth
    AuthProv --> GoogleSignInPlugin
    GoogleSignInProv --> GoogleSignInPlugin

    SwappablesProv --> Firestore
    SentSwapsProv --> Firestore
    RecvSwapsProv --> Firestore
    SwapHistoryProv --> Firestore

    %% Services to External
    FirebaseAuth --> ExtAuth
    Firestore --> ExtDB
    Storage --> ExtStorage
    GoogleSignInPlugin --> ExtGoogleAPI

    %% Platform bootstrap
    Android -.-> Main
    iOS -.-> Main
    Web -.-> Main
    Windows -.-> Main

    %% Click Events
    click Main "https://github.com/diivi/swapsta/blob/main/lib/main.dart"
    click Category "https://github.com/diivi/swapsta/blob/main/lib/models/category.dart"
    click SwapModel "https://github.com/diivi/swapsta/blob/main/lib/models/swap.dart"
    click Swappable "https://github.com/diivi/swapsta/blob/main/lib/models/swappable.dart"
    click AuthProv "https://github.com/diivi/swapsta/blob/main/lib/providers/auth_provider.dart"
    click GoogleSignInProv "https://github.com/diivi/swapsta/blob/main/lib/providers/Auth/google_sign_in.dart"
    click SwappablesProv "https://github.com/diivi/swapsta/blob/main/lib/providers/swappables_provider.dart"
    click SentSwapsProv "https://github.com/diivi/swapsta/blob/main/lib/providers/sent_swaps_provider.dart"
    click RecvSwapsProv "https://github.com/diivi/swapsta/blob/main/lib/providers/recieved_swap_provider.dart"
    click SwapHistoryProv "https://github.com/diivi/swapsta/blob/main/lib/providers/swap_history_provider.dart"
    click BottomNavProv "https://github.com/diivi/swapsta/blob/main/lib/providers/bottom_nav_visibility_provider.dart"
    click ScreenNavProv "https://github.com/diivi/swapsta/blob/main/lib/providers/screen_provider.dart"
    click Home "https://github.com/diivi/swapsta/blob/main/lib/screens/home_screen.dart"
    click Explore "https://github.com/diivi/swapsta/blob/main/lib/screens/explore_screen.dart"
    click Profile "https://github.com/diivi/swapsta/blob/main/lib/screens/profile_screen.dart"
    click AddItem "https://github.com/diivi/swapsta/blob/main/lib/screens/add_item_screen.dart"
    click AuthScreen "https://github.com/diivi/swapsta/blob/main/lib/screens/auth_screen.dart"
    click SwapDetails "https://github.com/diivi/swapsta/blob/main/lib/screens/swap_screen.dart"
    click SwappableDetails "https://github.com/diivi/swapsta/blob/main/lib/screens/swappable_screen.dart"
    click ImagePreview "https://github.com/diivi/swapsta/blob/main/lib/screens/image_screen.dart"
    click Feedback "https://github.com/diivi/swapsta/blob/main/lib/screens/feedback_screen.dart"
    click Widgets "https://github.com/diivi/swapsta/tree/main/lib/widgets/"
    click Android "https://github.com/diivi/swapsta/tree/main/android/"
    click iOS "https://github.com/diivi/swapsta/tree/main/ios/"
    click Web "https://github.com/diivi/swapsta/tree/main/web/"
    click Windows "https://github.com/diivi/swapsta/tree/main/windows/"

    %% Styles
    classDef presentation fill:#D6EAF8,stroke:#3498DB,stroke-width:1px
    classDef logic fill:#D5F5E3,stroke:#27AE60,stroke-width:1px
    classDef service fill:#FAD7A0,stroke:#D68910,stroke-width:1px
    classDef model fill:#E8DAEF,stroke:#8E44AD,stroke-width:1px
    classDef external fill:#D5D8DC,stroke:#566573,stroke-width:1px
    classDef platform fill:#F2F3F4,stroke:#99A3A4,stroke-width:1px
```
