# yunisnasla/reaction-wheel-inverted-pendulum architecture

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

- Interactive diagram: https://gitdiagram.com/yunisnasla/reaction-wheel-inverted-pendulum
- Repository: https://github.com/yunisnasla/reaction-wheel-inverted-pendulum

## Overview

This repository combines Arduino firmware for a reaction-wheel inverted pendulum with a small React landing page. The principal physical workflow reads encoder motion, selects swing-up or stabilization control, and drives the motor; the README documents the firmware stages and algorithms, while the sampled source shows the web entry point and landing page. The firmware internals are all attributed to RWIP.ino because its contents were not sampled. The advertised Live Control link and telemetry types do not establish a working control interface or backend in the available evidence.

Main entry points: [`RWIP.ino`](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino) (Swing-up control), [`client/src/main.tsx`](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/main.tsx) (Web entry), [`client/src/App.tsx`](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/App.tsx) (App router), [`client/src/pages/Home.tsx`](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/pages/Home.tsx) (Landing page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web presentation"]
  node_entry["Web entry<br/>[main.tsx]"]
  node_router["App router<br/>[App.tsx]"]
  node_landing["Landing page<br/>[Home.tsx]"]
  node_telemetrytypes["Telemetry types<br/>[telemetry.ts]"]
end

subgraph group_control["Firmware control"]
  node_state["Mode selection<br/>[RWIP.ino]"]
  node_swingup["Swing-up control<br/>[RWIP.ino]"]
  node_decelerator["Approach decelerator<br/>[RWIP.ino]"]
  node_near_miss["Near-miss handling<br/>[RWIP.ino]"]
  node_rotation["Rotation detection<br/>[RWIP.ino]"]
  node_stabilization["PID stabilization<br/>[RWIP.ino]"]
  node_desaturation["Wheel desaturation<br/>[RWIP.ino]"]
  node_serial["Serial diagnostics<br/>[RWIP.ino]"]
end

subgraph group_hardware["Physical system"]
  node_encoder["Quadrature encoder<br/>[RWIP.ino]"]
  node_pendulum["Pendulum motion<br/>[RWIP.ino]"]
  node_motor["Motor driver<br/>[RWIP.ino]"]
  node_wheel["Reaction wheel<br/>[RWIP.ino]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens"| node_entry
node_entry -->|"renders"| node_router
node_router -->|"routes to"| node_landing
node_landing -->|"offers navigation"| node_visitor
node_encoder -->|"provides angle and velocity"| node_state
node_pendulum -->|"measured by"| node_encoder
node_state -->|"selects"| node_swingup
node_state -->|"selects"| node_stabilization
node_swingup -->|"applies near upright"| node_decelerator
node_swingup -->|"adjusts next pump"| node_near_miss
node_swingup -->|"checks rotation"| node_rotation
node_swingup -->|"commands"| node_motor
node_decelerator -->|"brakes"| node_motor
node_rotation -->|"stops pumping"| node_motor
node_stabilization -->|"biases setpoint"| node_desaturation
node_stabilization -->|"commands"| node_motor
node_motor -->|"drives"| node_wheel
node_wheel -->|"reacts against"| node_pendulum
node_state -->|"reports mode"| node_serial
node_stabilization -->|"reports balance data"| node_serial

click node_entry "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/main.tsx"
click node_router "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/App.tsx"
click node_landing "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/pages/Home.tsx"
click node_telemetrytypes "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/types/telemetry.ts"
click node_encoder "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_pendulum "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_state "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_swingup "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_decelerator "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_near_miss "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_rotation "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_stabilization "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_desaturation "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_motor "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_wheel "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"
click node_serial "https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino"

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_entry,node_router,node_landing,node_telemetrytypes toneBlue
class node_state,node_swingup,node_decelerator,node_near_miss,node_rotation,node_stabilization,node_desaturation,node_serial toneAmber
class node_encoder,node_pendulum,node_motor,node_wheel toneMint
class node_visitor toneIndigo
```

## Components

### Web presentation

- [Web entry](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/main.tsx): `client/src/main.tsx`
- [App router](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Landing page](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [Telemetry types](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/client/src/types/telemetry.ts): `client/src/types/telemetry.ts`

### Firmware control

- [Mode selection](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Swing-up control](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Approach decelerator](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Near-miss handling](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Rotation detection](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [PID stabilization](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Wheel desaturation](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Serial diagnostics](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`

### Physical system

- [Quadrature encoder](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Pendulum motion](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Motor driver](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`
- [Reaction wheel](https://github.com/yunisnasla/reaction-wheel-inverted-pendulum/blob/main/RWIP.ino): `RWIP.ino`

### Other components

- **Visitor**

## Connections

- Visitor → Web entry: opens (evidence: `client/src/main.tsx`)
- Web entry → App router: renders (evidence: `client/src/main.tsx`)
- App router → Landing page: routes to (evidence: `client/src/App.tsx`)
- Landing page → Visitor: offers navigation (evidence: `client/src/pages/Home.tsx`)
- Quadrature encoder → Mode selection: provides angle and velocity (evidence: `README.md`)
- Pendulum motion → Quadrature encoder: measured by (evidence: `README.md`)
- Mode selection → Swing-up control: selects (evidence: `README.md`)
- Mode selection → PID stabilization: selects (evidence: `README.md`)
- Swing-up control → Approach decelerator: applies near upright (evidence: `README.md`)
- Swing-up control → Near-miss handling: adjusts next pump (evidence: `README.md`)
- Swing-up control → Rotation detection: checks rotation (evidence: `README.md`)
- Swing-up control → Motor driver: commands (evidence: `README.md`)
- Approach decelerator → Motor driver: brakes (evidence: `README.md`)
- Rotation detection → Motor driver: stops pumping (evidence: `README.md`)
- PID stabilization → Wheel desaturation: biases setpoint (evidence: `README.md`)
- PID stabilization → Motor driver: commands (evidence: `README.md`)
- Motor driver → Reaction wheel: drives (evidence: `README.md`)
- Reaction wheel → Pendulum motion: reacts against (evidence: `README.md`)
- Mode selection → Serial diagnostics: reports mode (evidence: `README.md`)
- PID stabilization → Serial diagnostics: reports balance data (evidence: `README.md`)
