# git-jaishnu/line_follower architecture

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

- Interactive diagram: https://gitdiagram.com/git-jaishnu/line_follower
- Repository: https://github.com/git-jaishnu/line_follower

## Overview

This repository implements STM32F4 line-following robot firmware plus a desktop PID-tuning dashboard. The main workflow samples sensor and battery inputs, interprets line position and junctions, computes steering, and drives the motors; Bluetooth carries telemetry and tuning commands. The README describes the domain flow, while the source index and excerpts provide only partial implementation evidence, so documented relationships cite the README and unsampled internals are not treated as inspected.

Main entry points: [`Core/Src/main.c`](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c) (Control loop), [`pid_tuner.py`](https://github.com/git-jaishnu/line_follower/blob/main/pid_tuner.py) (PID tuner dashboard), [`Core/Src/motor.c`](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/motor.c) (Motor control), [`Core/Src/bluetooth.c`](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/bluetooth.c) (Bluetooth protocol)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Robot firmware"]
  node_adc_dma["ADC and DMA<br/>[main.c]"]
  node_sensor_sync["Sensor synchronization<br/>[sensor_module.c]"]
  node_main_loop["Control loop<br/>[main.c]"]
  node_utils["Utility helpers<br/>[utils.c]"]
end

subgraph group_control["Navigation and control"]
  node_sensor_processing["Sensor processing<br/>[sensor_module.c]"]
  node_junction["Junction detection<br/>[sensor_module.c]"]
  node_line_error["Line error<br/>[sensor_module.c]"]
  node_pid["PID steering<br/>[sensor_module.c]"]
  node_motor_control["Motor control<br/>[motor.c]"]
end

subgraph group_communications["Telemetry and tuning"]
  node_bluetooth["Bluetooth protocol<br/>[bluetooth.c]"]
  node_dashboard["PID tuner dashboard<br/>[pid_tuner.py]"]
end

subgraph group_hardware["Robot hardware"]
  node_sensor_bar["IR sensor array"]
  node_battery["Battery divider"]
  node_motors["H-bridge motors"]
  node_uart["Bluetooth UART<br/>[main.c]"]
end

node_robot(("Robot operator"))

node_sensor_bar -->|"supplies readings"| node_adc_dma
node_battery -->|"supplies voltage"| node_adc_dma
node_adc_dma -->|"transfers samples"| node_sensor_sync
node_main_loop -->|"synchronizes inputs"| node_sensor_sync
node_main_loop -->|"processes sensors"| node_sensor_processing
node_main_loop -->|"checks junctions"| node_junction
node_main_loop -->|"calculates error"| node_line_error
node_main_loop -->|"calculates steering"| node_pid
node_main_loop -->|"sets motor output"| node_motor_control
node_motor_control -->|"drives motors"| node_motors
node_main_loop -->|"handles commands"| node_bluetooth
node_bluetooth -->|"updates gains"| node_pid
node_main_loop -->|"sends telemetry"| node_uart
node_uart -->|"streams telemetry"| node_dashboard
node_robot -->|"tunes gains"| node_dashboard
node_dashboard -->|"sends tuning commands"| node_uart
node_main_loop -.->|"uses helpers"| node_utils

click node_adc_dma "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c"
click node_sensor_sync "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c"
click node_sensor_processing "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c"
click node_junction "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c"
click node_line_error "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c"
click node_pid "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c"
click node_main_loop "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c"
click node_motor_control "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/motor.c"
click node_bluetooth "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/bluetooth.c"
click node_dashboard "https://github.com/git-jaishnu/line_follower/blob/main/pid_tuner.py"
click node_uart "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c"
click node_utils "https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/utils.c"

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_adc_dma,node_sensor_sync,node_main_loop,node_utils toneBlue
class node_sensor_processing,node_junction,node_line_error,node_pid,node_motor_control toneAmber
class node_bluetooth,node_dashboard toneMint
class node_sensor_bar,node_battery,node_motors,node_uart toneRose
class node_robot toneIndigo
```

## Components

### Robot firmware

- [ADC and DMA](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Sensor synchronization](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c): `Core/Src/sensor_module.c`
- [Control loop](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [Utility helpers](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/utils.c): `Core/Src/utils.c`

### Navigation and control

- [Sensor processing](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c): `Core/Src/sensor_module.c`
- [Junction detection](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c): `Core/Src/sensor_module.c`
- [Line error](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c): `Core/Src/sensor_module.c`
- [PID steering](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/sensor_module.c): `Core/Src/sensor_module.c`
- [Motor control](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/motor.c): `Core/Src/motor.c`

### Telemetry and tuning

- [Bluetooth protocol](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/bluetooth.c): `Core/Src/bluetooth.c`
- [PID tuner dashboard](https://github.com/git-jaishnu/line_follower/blob/main/pid_tuner.py): `pid_tuner.py`

### Robot hardware

- **IR sensor array**
- **Battery divider**
- **H-bridge motors**
- [Bluetooth UART](https://github.com/git-jaishnu/line_follower/blob/main/Core/Src/main.c): `Core/Src/main.c`

### Other components

- **Robot operator**

## Connections

- IR sensor array → ADC and DMA: supplies readings (evidence: `README.md`)
- Battery divider → ADC and DMA: supplies voltage (evidence: `README.md`)
- ADC and DMA → Sensor synchronization: transfers samples (evidence: `README.md`)
- Control loop → Sensor synchronization: synchronizes inputs (evidence: `README.md`)
- Control loop → Sensor processing: processes sensors (evidence: `README.md`)
- Control loop → Junction detection: checks junctions (evidence: `README.md`)
- Control loop → Line error: calculates error (evidence: `README.md`)
- Control loop → PID steering: calculates steering (evidence: `README.md`)
- Control loop → Motor control: sets motor output (evidence: `README.md`)
- Motor control → H-bridge motors: drives motors (evidence: `README.md`)
- Control loop → Bluetooth protocol: handles commands (evidence: `README.md`)
- Bluetooth protocol → PID steering: updates gains (evidence: `README.md`)
- Control loop → Bluetooth UART: sends telemetry (evidence: `README.md`)
- Bluetooth UART → PID tuner dashboard: streams telemetry (evidence: `README.md`)
- Robot operator → PID tuner dashboard: tunes gains (evidence: `README.md`)
- PID tuner dashboard → Bluetooth UART: sends tuning commands (evidence: `README.md`)
- Control loop → Utility helpers: uses helpers
