# quecpython/solution-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/quecpython/solution-tracker
- Repository: https://github.com/quecpython/solution-tracker

## Overview

##### Project Type and Purpose
- This is an IoT-tracker solution built on a QuecPython-powered EC200U development board.
- It targets embedded device applications that collect GNSS and sensor data, send alarms/events over LTE, and integrate with cloud IoT platforms and user-facing dashboards (web/mobile).

##### File Structure Analysis
- Top-level:
– QPY_OCPU_BETA0001_EC200U_EUAA_FW/ : QuecPython firmware binaries & docs
– code/ : application code deployed to the device
– docs/ : documentation and process images
– object_model_demo/ : example cloud object model JSON
- code/ substructure:
– _main.py : entry-point, orchestrates modules
– modules/ : hardware and protocol abstractions (GNSS, buzzer, LED, MQTT clients for Alibaba IoT, ThingsBoard, serial, power/temperature sensors, logging, net_manage)
– settings*.py : configuration layers (loc, server, user)
– tracker_ali.py, tracker_tb.py : high-level flows for each cloud integration

##### README Insights
- Describes end-to-end tracker solution: device → LTE network → cloud IoT platforms → visual operation platform & mobile app.
- References two major integrations: Alibaba IoT Platform and ThingsBoard (open-source)

a. Main Components
1) Embedded Device Layer
– QuecPython runtime on EC200U board
– Sensors & peripherals: GNSS module, buzzer, LEDs, temp/humidity, audio mic/speaker
– Application modules: net_manage, location, alarms, power_manage, logging, etc.
2) Connectivity Layer
– LTE modem and cellular network
3) Cloud IoT Platforms
– Alibaba Cloud IoT (MQTT, JSON object model)
– ThingsBoard (MQTT/HTTP)
– Private/custom server (if configured)
4) User Applications
– Visual operation web dashboard
– Mobile APP for tracking and control
5) Development & Tools
– QPYcom debug/tool chain
– Firmware flashing process
– Object model definition (ali_cloud_object_model.json)

b. Component Relationships & Data Flows
- Device sensors → QuecPython modules → _main.py
- net_manage handles cellular registration and MQTT connectivity
- tracker_ali.py/tracker_tb.py serialize sensor data into cloud-specific formats
- Over LTE → Cloud IoT (MQTT broker) → downstream services (dashboards, alerts)
- Mobile/Web client ↔ Cloud REST/WebSocket APIs for real-time tracking

c. Architectural Patterns & Principles
- Modular driver abstraction (each peripheral or service is a separate Python module)
- Configuration layering (global vs. location vs. user vs. server settings)
- Publish/subscribe model for data reporting (MQTT)
- Single‐source entry point (_main.py) orchestrates high-level flows via plugin modules

d. Key Technologies & Frameworks
- QuecPython (Python subset for embedded)
- MQTT protocol for IoT messaging
- Alibaba Cloud IoT SDK (aliIot.py)
- ThingsBoard client (thingsboard.py)
- GNSS positioning libraries (location.py)
- QPYcom flashing/debug tool

## Diagram (Mermaid)

```mermaid
graph TB
    %% Embedded Device Layer
    subgraph "Embedded Device Layer"
        direction TB
        Main["_main.py"]:::orchestrator
        subgraph "Firmware Modules"
            direction TB
            Loc["location.py"]:::module
            Buzzer["buzzer.py"]:::module
            LED["led.py"]:::module
            Serial["serial.py"]:::module
            Power["power_manage.py"]:::module
            Logging["logging.py"]:::module
            Net["net_manage.py"]:::module
            MQTT_Ali["mqtt_ali.py"]:::module
            MQTT_TB["mqtt_tb.py"]:::module
        end
        subgraph "Configuration Layer"
            direction TB
            Settings["settings.py"]:::config
            SettingsLoc["settings_loc.py"]:::config
            SettingsServer["settings_server.py"]:::config
            SettingsUser["settings_user.py"]:::config
        end
        Main -->|orchestrates| Loc
        Main --> Buzzer
        Main --> LED
        Main --> Serial
        Main --> Power
        Main --> Logging
        Main --> Net
        Main --> MQTT_Ali
        Main --> MQTT_TB
        Main --> Settings
        Main --> SettingsLoc
        Main --> SettingsServer
        Main --> SettingsUser
    end

    %% Connectivity Layer
    subgraph "Connectivity Layer"
        direction TB
        LTE["LTE Modem"]:::network
        CellNet["Cellular Network"]:::network
    end
    Net --> LTE
    LTE --> CellNet

    %% Cloud IoT Platforms
    subgraph "Cloud IoT Platforms"
        direction TB
        AliCloud["Alibaba IoT Platform"]:::cloud
        TBCloud["ThingsBoard Platform"]:::cloud
        PrivateSrv["Private/Custom Server"]:::cloud
        ObjectModel["ali_cloud_object_model.json"]:::storage
    end
    MQTT_Ali -->|MQTT Publish| AliCloud
    MQTT_TB -->|MQTT Publish| TBCloud
    MQTT_Ali -->|optional HTTP| PrivateSrv
    MQTT_TB -->|optional HTTP| PrivateSrv
    AliCloud --> ObjectModel
    TBCloud --> ObjectModel

    %% User Applications
    subgraph "User Applications"
        direction TB
        WebApp["Web Dashboard"]:::client
        MobileApp["Mobile App"]:::client
    end
    AliCloud -->|REST/WebSocket| WebApp
    AliCloud -->|REST/WebSocket| MobileApp
    TBCloud -->|REST/WebSocket| WebApp
    TBCloud -->|REST/WebSocket| MobileApp

    %% Development & Tools
    subgraph "Development & Tools"
        direction TB
        QPYcom["QPYcom Debug/Flashing Tool"]:::tool
        FirmwareBin["QuecPython Firmware Binaries & Docs"]:::tool
        README["README.md"]:::doc
        Changelog["CHANGELOG.md"]:::doc
        License["LICENSE"]:::doc
        DocsEN["docs/en/media/"]:::doc
        DocsZH["docs/zh/media/"]:::doc
    end
    QPYcom --> FirmwareBin
    QPYcom --> Main

    %% Flow of Deployment
    QPYcom -->|flashing| Main

    %% Click Events
    click FirmwareBin "https://github.com/quecpython/solution-tracker/tree/master/QPY_OCPU_BETA0001_EC200U_EUAA_FW/"
    click Main "https://github.com/quecpython/solution-tracker/blob/master/code/_main.py"
    click Loc "https://github.com/quecpython/solution-tracker/blob/master/code/modules/location.py"
    click Buzzer "https://github.com/quecpython/solution-tracker/blob/master/code/modules/buzzer.py"
    click LED "https://github.com/quecpython/solution-tracker/blob/master/code/modules/led.py"
    click Serial "https://github.com/quecpython/solution-tracker/blob/master/code/modules/serial.py"
    click Power "https://github.com/quecpython/solution-tracker/blob/master/code/modules/power_manage.py"
    click Logging "https://github.com/quecpython/solution-tracker/blob/master/code/modules/logging.py"
    click Net "https://github.com/quecpython/solution-tracker/blob/master/code/modules/net_manage.py"
    click MQTT_Ali "https://github.com/quecpython/solution-tracker/blob/master/code/modules/mqtt_ali.py"
    click MQTT_TB "https://github.com/quecpython/solution-tracker/blob/master/code/modules/mqtt_tb.py"
    click Settings "https://github.com/quecpython/solution-tracker/blob/master/code/settings.py"
    click SettingsLoc "https://github.com/quecpython/solution-tracker/blob/master/code/settings_loc.py"
    click SettingsServer "https://github.com/quecpython/solution-tracker/blob/master/code/settings_server.py"
    click SettingsUser "https://github.com/quecpython/solution-tracker/blob/master/code/settings_user.py"
    click ObjectModel "https://github.com/quecpython/solution-tracker/blob/master/object_model_demo/ali_cloud_object_model.json"
    click DocsEN "https://github.com/quecpython/solution-tracker/tree/master/docs/en/media/"
    click DocsZH "https://github.com/quecpython/solution-tracker/tree/master/docs/zh/media/"

    %% Styles
    classDef module fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef orchestrator fill:#1E90FF,stroke:#000,stroke-width:1px
    classDef config fill:#87CEFA,stroke:#000,stroke-width:1px
    classDef network fill:#98FB98,stroke:#000,stroke-width:1px
    classDef cloud fill:#FFA500,stroke:#000,stroke-width:1px
    classDef client fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef tool fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef doc fill:#F5DEB3,stroke:#000,stroke-width:1px
    classDef storage fill:#FFE4B5,stroke:#000,stroke-width:1px
```
