# fenghaowu/uji_internship architecture

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

- Interactive diagram: https://gitdiagram.com/fenghaowu/uji_internship
- Repository: https://github.com/fenghaowu/uji_internship

## Overview

This repository implements an ESP32 EMG/IMU acquisition device and two Python BLE clients: one for live signal visualization and one for connection-performance monitoring. The main workflow samples eight EMG channels and six IMU axes, batches binary frames, and sends notifications for host-side decoding and display. The monitor separately records throughput and packet-rate measurements and plots them afterward. The README is unavailable as usable text, so capabilities and links here reflect the sampled source; CAN transmission is present but disabled by default.

Main entry points: [`src/main.cpp`](https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp) (Frame Batching), [`BLE_Live_Graph.py`](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py) (BLE Receiver), [`BLE_Record.py`](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py) (BLE Monitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["ESP32 Firmware"]
  node_acquisition["Sensor Sampling<br/>[main.cpp]"]
  node_batching["Frame Batching<br/>[main.cpp]"]
  node_ble_service["BLE Service<br/>[main.cpp]"]
  node_can_output["CAN Output<br/>[main.cpp]"]
end

subgraph group_live["Live Visualization"]
  node_live_client["BLE Receiver<br/>[BLE_Live_Graph.py]"]
  node_frame_decode["Frame Decoder<br/>[BLE_Live_Graph.py]"]
  node_signal_buffer["Signal Buffer<br/>[BLE_Live_Graph.py]"]
  node_live_plot["Live Plot UI<br/>[BLE_Live_Graph.py]"]
end

subgraph group_monitor["Performance Monitor"]
  node_monitor_client["BLE Monitor<br/>[BLE_Record.py]"]
  node_rate_metrics["Rate Metrics<br/>[BLE_Record.py]"]
  node_monitor_log["Session Log<br/>[BLE_Record.py]"]
  node_offline_plot["Performance Plot<br/>[BLE_Record.py]"]
end

node_sensors{{"EMG/IMU Hardware"}}

node_sensors -->|"provides readings"| node_acquisition
node_acquisition -->|"fills frames"| node_batching
node_batching -->|"notifies batches"| node_ble_service
node_batching -->|"routes frames"| node_can_output
node_ble_service -.->|"sends notifications"| node_live_client
node_ble_service -.->|"sends notifications"| node_monitor_client
node_live_client -->|"decodes notifications"| node_frame_decode
node_frame_decode -->|"emits samples"| node_signal_buffer
node_signal_buffer -->|"updates curves"| node_live_plot
node_monitor_client -->|"counts packets"| node_rate_metrics
node_rate_metrics -->|"appends rates"| node_monitor_log
node_monitor_log -->|"reads measurements"| node_offline_plot

click node_acquisition "https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp"
click node_batching "https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp"
click node_ble_service "https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp"
click node_can_output "https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp"
click node_live_client "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py"
click node_frame_decode "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py"
click node_signal_buffer "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py"
click node_live_plot "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py"
click node_monitor_client "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py"
click node_rate_metrics "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py"
click node_monitor_log "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py"
click node_offline_plot "https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_acquisition,node_batching,node_ble_service,node_can_output toneBlue
class node_live_client,node_frame_decode,node_signal_buffer,node_live_plot toneAmber
class node_monitor_client,node_rate_metrics,node_monitor_log,node_offline_plot toneMint
class node_sensors toneIndigo
```

## Components

### ESP32 Firmware

- [Sensor Sampling](https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp): `src/main.cpp`
- [Frame Batching](https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp): `src/main.cpp`
- [BLE Service](https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp): `src/main.cpp`
- [CAN Output](https://github.com/fenghaowu/uji_internship/blob/main/src/main.cpp): `src/main.cpp`

### Live Visualization

- [BLE Receiver](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py): `BLE_Live_Graph.py`
- [Frame Decoder](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py): `BLE_Live_Graph.py`
- [Signal Buffer](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py): `BLE_Live_Graph.py`
- [Live Plot UI](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Live_Graph.py): `BLE_Live_Graph.py`

### Performance Monitor

- [BLE Monitor](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py): `BLE_Record.py`
- [Rate Metrics](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py): `BLE_Record.py`
- [Session Log](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py): `BLE_Record.py`
- [Performance Plot](https://github.com/fenghaowu/uji_internship/blob/main/BLE_Record.py): `BLE_Record.py`

### Other components

- **EMG/IMU Hardware**

## Connections

- EMG/IMU Hardware → Sensor Sampling: provides readings (evidence: `src/main.cpp`)
- Sensor Sampling → Frame Batching: fills frames (evidence: `src/main.cpp`)
- Frame Batching → BLE Service: notifies batches (evidence: `src/main.cpp`)
- Frame Batching → CAN Output: routes frames (evidence: `src/main.cpp`)
- BLE Service → BLE Receiver: sends notifications
- BLE Service → BLE Monitor: sends notifications
- BLE Receiver → Frame Decoder: decodes notifications (evidence: `BLE_Live_Graph.py`)
- Frame Decoder → Signal Buffer: emits samples (evidence: `BLE_Live_Graph.py`)
- Signal Buffer → Live Plot UI: updates curves (evidence: `BLE_Live_Graph.py`)
- BLE Monitor → Rate Metrics: counts packets (evidence: `BLE_Record.py`)
- Rate Metrics → Session Log: appends rates (evidence: `BLE_Record.py`)
- Session Log → Performance Plot: reads measurements (evidence: `BLE_Record.py`)
