# bear2305/fakesensor architecture

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

- Interactive diagram: https://gitdiagram.com/bear2305/fakesensor
- Repository: https://github.com/bear2305/fakesensor

## Overview

This repository is an ESP32/Wokwi fake fingerprint sensor that lets a master board use the Adafruit fingerprint protocol without physical sensor hardware. The principal workflow is: the master sends UART commands, the emulator parses and dispatches them, switch inputs supply a simulated finger identity, and command handlers return status or template data while maintaining buffers and stored templates. The README documents enrollment, search, template transfer, password protection, database management, and diagnostics. The sampled source shows dispatch and several handlers; links for omitted internals are not asserted.

Main entry points: [`wokwi custom chip/claude1_chip.cpp`](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp) (Command dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["External interface"]
end

subgraph group_protocol["Protocol runtime"]
  node_uart_parser["UART parser<br/>[claude1_chip.cpp]"]
  node_dispatcher["Command dispatcher<br/>[claude1_chip.cpp]"]
  node_responses["Packet responses<br/>[claude1_chip.cpp]"]
end

subgraph group_sensor["Sensor emulation"]
  node_finger_capture["Finger capture<br/>[claude1_chip.cpp]"]
  node_enrollment_match["Enrollment and matching<br/>[claude1_chip.cpp]"]
  node_template_db[("Template database<br/>[claude1_chip.cpp]")]
  node_template_transfer["Template transfer<br/>[claude1_chip.cpp]"]
  node_device_management["Device management<br/>[claude1_chip.cpp]"]
  node_diagnostics["Diagnostics<br/>[claude1_chip.cpp]"]
end

node_master(("Master board"))
node_switches(("Finger switches"))

node_master -->|"sends UART commands"| node_uart_parser
node_switches -->|"set simulated identity"| node_finger_capture
node_uart_parser -.->|"dispatches parsed commands"| node_dispatcher
node_dispatcher -->|"routes capture"| node_finger_capture
node_dispatcher -->|"routes operations"| node_enrollment_match
node_dispatcher -->|"routes transfers"| node_template_transfer
node_dispatcher -->|"routes management"| node_device_management
node_dispatcher -.->|"routes diagnostics"| node_diagnostics
node_enrollment_match -->|"stores and searches"| node_template_db
node_template_transfer -->|"transfers stored templates"| node_template_db
node_finger_capture -->|"returns capture status"| node_responses
node_enrollment_match -->|"returns operation results"| node_responses
node_template_transfer -->|"sends template packets"| node_responses
node_device_management -.->|"returns status"| node_responses
node_responses -->|"replies over UART"| node_master

click node_uart_parser "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_dispatcher "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_responses "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_finger_capture "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_enrollment_match "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_template_db "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_template_transfer "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_device_management "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"
click node_diagnostics "https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp"

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_uart_parser,node_dispatcher,node_responses toneAmber
class node_finger_capture,node_enrollment_match,node_template_db,node_template_transfer,node_device_management,node_diagnostics toneMint
class node_master,node_switches toneIndigo
```

## Components

### Protocol runtime

- [UART parser](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Command dispatcher](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Packet responses](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`

### Sensor emulation

- [Finger capture](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Enrollment and matching](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Template database](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Template transfer](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Device management](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`
- [Diagnostics](https://github.com/bear2305/fakesensor/blob/main/wokwi%20custom%20chip/claude1_chip.cpp): `wokwi custom chip/claude1_chip.cpp`

### Other components

- **Master board**
- **Finger switches**

## Connections

- Master board → UART parser: sends UART commands (evidence: `README.md`)
- Finger switches → Finger capture: set simulated identity (evidence: `wokwi custom chip/claude1_chip.cpp`)
- UART parser → Command dispatcher: dispatches parsed commands (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Command dispatcher → Finger capture: routes capture (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Command dispatcher → Enrollment and matching: routes operations (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Command dispatcher → Template transfer: routes transfers (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Command dispatcher → Device management: routes management (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Command dispatcher → Diagnostics: routes diagnostics (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Enrollment and matching → Template database: stores and searches (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Template transfer → Template database: transfers stored templates (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Finger capture → Packet responses: returns capture status (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Enrollment and matching → Packet responses: returns operation results (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Template transfer → Packet responses: sends template packets (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Device management → Packet responses: returns status (evidence: `wokwi custom chip/claude1_chip.cpp`)
- Packet responses → Master board: replies over UART (evidence: `README.md`)
