# entertech/enter-biomodule-ble-pc-sdk architecture

> Architecture diagram of the GitHub repository entertech/enter-biomodule-ble-pc-sdk, 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/entertech/enter-biomodule-ble-pc-sdk
- Repository: https://github.com/entertech/enter-biomodule-ble-pc-sdk

## Overview

##### Project Type and Purpose
- This is a Python SDK library (packaged as `enterble`) allowing client applications to discover, connect, and exchange data with Bluetooth devices on macOS, Linux, and Windows.
- It also provides a specialized “adapter” layer for EnterTech’s Flowtime series chips.

##### File Structure
- Top-level package: `enterble/`
- `ble/`: Core BLE abstractions (scanning, device management)
- `adapter/flowtime/`: Flowtime-specific data exchange logic
- `collector/`: High-level data collection routines
- Support files:
- `examples/`: sample client scripts showing typical usage
- `requirements.txt`, `setup.py`: packaging & dependency info

##### README for Technical Insights
- Uses Python’s `asyncio` event loop to perform scanning and data exchange.
- Abstracts over platform differences (UUID vs. MAC address).
- Guides users through discovery → connection → data collection.

##### Core Components
a. SDK Client Application
- The user’s Python script (e.g., `examples/simple.py`)
b. enterble SDK Layers
1. BLE Scanner (`enterble.ble.scanner`)
2. BLE Device Abstraction (`enterble.ble.device`)
3. Data Collector (`enterble.collector.collector`)
4. Flowtime Adapter (`enterble.adapter.flowtime.collector`)
c. External Systems & Dependencies
- Underlying OS Bluetooth Stack (macOS/Linux/Win)
- Bluetooth Hardware / EnterTech Chipset
- Python Runtime & asyncio

##### Relationships & Interactions
- The Client Application invokes the SDK API.
- The BLE Scanner discovers devices via the OS Bluetooth stack.
- Upon discovery, the BLE Device module manages connection setup.
- Once connected, the Data Collector orchestrates read/write operations.
- If the target device is a Flowtime chip, the Flowtime Adapter layer transforms raw data.
- Collected data is returned to the client for processing or display.

##### Architectural Patterns & Principles
- Modular packaging: clear separation into `ble`, `collector`, and `adapter`.
- Pluggable adapter pattern: new chip series can be supported by adding modules under `enterble.adapter`.
- Async non-blocking I/O with `asyncio` to handle BLE operations concurrently.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Application
    subgraph "Client Application"
        App["examples/simple.py"]:::external
    end

    %% SDK Core Layer
    subgraph "enterble/ble" 
        Scanner["enterble.ble.scanner"]:::sdkcore
        Device["enterble.ble.device"]:::sdkcore
    end

    %% Collector Layer
    subgraph "enterble/collector"
        Collector["enterble.collector.collector"]:::collector
    end

    %% Adapter Layer
    subgraph "enterble/adapter/flowtime"
        FlowAdapter["enterble.adapter.flowtime.collector"]:::adapter
    end

    %% External Dependencies
    Python["Python Runtime & asyncio"]:::external
    OS["OS Bluetooth Stack"]:::external
    Hardware["Bluetooth Hardware / EnterTech Chipset"]:::external
    Metadata["setup.py\nrequirements.txt"]:::external

    %% Interactions
    App -->|"scan() API"| Scanner
    Scanner -->|"on_device_discovered()"| Device
    Device -->|"connect()"| OS
    OS -->|"connection_callback()"| Device
    Device -->|"read_characteristic()"| Collector
    Collector -->|"transform_data() if Flowtime"| FlowAdapter
    FlowAdapter -->|"raw BLE I/O"| Hardware
    Hardware -->|"events"| OS
    Collector -->|"return_data()"| App

    %% External relationships
    Python --> App
    Python --> Scanner
    Python --> Device
    Python --> Collector
    Python --> FlowAdapter

    %% Click Events
    click App "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/examples/simple.py"
    click Scanner "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/enterble/ble/scanner.py"
    click Device "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/enterble/ble/device.py"
    click Collector "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/enterble/collector/collector.py"
    click FlowAdapter "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/enterble/adapter/flowtime/collector.py"
    click Scanner "https://github.com/entertech/enter-biomodule-ble-pc-sdk/tree/main/enterble/ble/"
    click FlowAdapter "https://github.com/entertech/enter-biomodule-ble-pc-sdk/tree/main/enterble/adapter/flowtime/"
    click Collector "https://github.com/entertech/enter-biomodule-ble-pc-sdk/tree/main/enterble/collector/"
    click Metadata "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/setup.py"
    click Metadata "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/requirements.txt"
    click Python "https://github.com/entertech/enter-biomodule-ble-pc-sdk/blob/main/enterble/__init__.py"

    %% Styles
    classDef sdkcore fill:#cce5ff,stroke:#004085,color:#004085
    classDef collector fill:#d4edda,stroke:#155724,color:#155724
    classDef adapter fill:#ffe5b4,stroke:#cc8400,color:#cc8400
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
