# kyathamsatheesh/btapplication architecture

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

- Interactive diagram: https://gitdiagram.com/kyathamsatheesh/btapplication
- Repository: https://github.com/kyathamsatheesh/btapplication

## Overview

##### Project type and purpose
- It provides Bluetooth scanning/connection functionality, stores data locally in SQLite, optionally syncs to Firebase Firestore, and visualizes data via charts.

##### File structure
- Top‐level platform folders (android/, ios/, linux/, macos/, windows/, web/) contain the native host configurations and plugin wiring generated by Flutter.
- The lib/ directory holds the Dart code, organized into:
- main.dart (entrypoint)
- screens/ (UI pages: scan, device view, dashboard, user creation/list, Firestore data display)
- statemanagment/ (Provider classes for Bluetooth and data state)
- services/ (connectivity checks, data service abstraction)
- firebase_firestore/ (CRUD operations for remote store)
- db.sqlite/ (database helper and operations for local persistence)
- charts/, widgets/, commonscreen/, utils/, model/ (UI components, shared screens, helpers, data models)
- test/ holds widget tests.
- Configuration files (pubspec.yaml, analysis_options.yaml) declare dependencies (flutter_blue, sqflite, cloud_firestore, provider, charts_flutter, etc.).

##### Final recommendations
- Be detailed: capture every layer from UI event to hardware or cloud.
- Avoid overcomplicating: stick to these core components and their interactions for clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        scan["ScanScreen"]:::ui
        device["DeviceScreen"]:::ui
        dash["Dashboard"]:::ui
        off["BluetoothOffScreen"]:::ui
        uc["UserCreation"]:::ui
        ul["UserList"]:::ui
        fd["FirestoreDataDisplay"]:::ui
        home["HomeScreen"]:::ui
        profile["ProfileScreen"]:::ui
        bnav["BottomNavBar"]:::ui
        mainScreen["MainScreen"]:::ui
        scan_result["ScanResultTile"]:::widget
        char_tile["CharacteristicTile"]:::widget
        desc_tile["DescriptorTile"]:::widget
        service_tile["ServiceTile"]:::widget
        sys_tile["SystemDeviceTile"]:::widget
        conn_widget["ConnectivityAwareWidget"]:::widget
        chart["HeartChart"]:::chart
    end

    %% State Management Layer
    subgraph "State Management Layer"
        provider["BluetoothDataProvider"]:::state
    end

    %% Service Layer
    subgraph "Service Layer"
        conn_svc["ConnectivityService"]:::service
        data_svc["DataService"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        subgraph "Local Storage"
            db_helper["DatabaseHelper"]:::data
            db_ops["DBOperations"]:::data
        end
        subgraph "Remote Storage"
            firestore["DataStoreCRUD"]:::data
        end
    end

    %% Platform & Plugins
    subgraph "Platform & Plugins"
        flutter_blue["flutter_blue Plugin"]:::plugin
        sqflite["sqflite Plugin"]:::plugin
        cloud_fx["cloud_firestore Plugin"]:::plugin
        native["Native Host Runners"]:::platform
    end

    %% External Dependencies
    subgraph "External Dependencies"
        bt_adapter["Bluetooth Adapter"]:::external
        internet["Internet"]:::external
        firebase_backend["Firebase Backend"]:::external
    end

    %% Data Flows
    scan -->|interacts| provider
    device -->|interacts| provider
    dash -->|requests data| provider
    off -->|notifies| provider
    uc -->|submits| provider
    ul -->|loads| provider
    fd -->|displays| provider
    provider -->|checks connectivity| conn_svc
    provider -->|requests scan/save| data_svc
    conn_svc -->|uses| internet
    data_svc -->|BLE Scan API| flutter_blue
    flutter_blue -->|plugin bridge| native
    data_svc -->|writes| db_helper
    db_helper -->|CRUD operations| db_ops
    data_svc -->|sync| firestore
    firestore -->|via cloud_firestore| cloud_fx
    cloud_fx -->|communicates| native
    firestore -->|writes/reads| firebase_backend
    sqflite -->|native| native
    db_helper -->|through| sqflite

    %% Click Events
    click scan "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/scan_screen.dart"
    click device "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/device_screen.dart"
    click dash "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/dashboard.dart"
    click off "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/bluetooth_off_screen.dart"
    click uc "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/user_creation.dart"
    click ul "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/user_list.dart"
    click fd "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/screens/firestore_data_display.dart"
    click home "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/commonscreen/homescreen.dart"
    click profile "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/commonscreen/profilescreen.dart"
    click bnav "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/BottomNavBar.dart"
    click mainScreen "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/MainScreen.dart"
    click scan_result "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/scan_result_tile.dart"
    click char_tile "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/characteristic_tile.dart"
    click desc_tile "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/descriptor_tile.dart"
    click service_tile "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/service_tile.dart"
    click sys_tile "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/system_device_tile.dart"
    click conn_widget "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/widgets/connectivity_aware_widget.dart"
    click chart "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/charts/heart_chart.dart"
    click provider "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/statemanagment/bluetooth_data_provider.dart"
    click conn_svc "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/services/connectivity_service.dart"
    click data_svc "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/services/data_service.dart"
    click db_helper "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/db.sqlite/database_helper.dart"
    click db_ops "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/db.sqlite/db_operations.dart"
    click firestore "https://github.com/kyathamsatheesh/btapplication/blob/main/lib/firebase_firestore/data_store_CRUD.dart"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/android/app/src/main/kotlin/com/example/btapplication/MainActivity.kt"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/ios/Runner/AppDelegate.swift"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/linux/main.cc"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/linux/flutter/generated_plugin_registrant.cc"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/macos/Flutter/GeneratedPluginRegistrant.swift"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/windows/flutter/generated_plugin_registrant.cc"
    click native "https://github.com/kyathamsatheesh/btapplication/blob/main/web/index.html"

    %% Styles
    classDef ui fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef widget fill:#E3F2FD,stroke:#1976D2,color:#1976D2
    classDef chart fill:#FFEB3B,stroke:#F57F17,color:#F57F17
    classDef state fill:#C8E6C9,stroke:#2E7D32,color:#2E7D32
    classDef service fill:#FFF9C4,stroke:#FBC02D,color:#FBC02D
    classDef data fill:#FFE0B2,stroke:#EF6C00,color:#EF6C00
    classDef plugin fill:#CFD8DC,stroke:#455A64,color:#455A64
    classDef platform fill:#B0BEC5,stroke:#263238,color:#263238
    classDef external fill:#F5F5F5,stroke:#9E9E9E,color:#616161
```
