# orebenson/keystroke_analyser architecture

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

- Interactive diagram: https://gitdiagram.com/orebenson/keystroke_analyser
- Repository: https://github.com/orebenson/keystroke_analyser
- Video tour (about a minute): https://gitdiagram.com/orebenson/keystroke_analyser/video

## Overview

Keystroke Analysis is a React and FastAPI research application for collecting typing-timing samples, training user classifiers, and testing authentication. The user enters credentials, types a fixed prompt, and submits samples for training or classifier-based testing; the backend stores training data and returns acceptance or rejection feedback. The graph preserves the UI, API, persistence, and classifier responsibilities. Relationships are limited to calls and data transfers visible in the excerpts or README; classifier internals are represented at the sampled module level.

Main entry points: [`backend/app/main.py`](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/main.py) (Sample API route), [`backend/app/matcher.py`](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py) (Matcher workflow), [`react_frontend/src/components/MainForm.js`](https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/components/MainForm.js) (Sample form), [`backend/app/database.py`](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/database.py) (Database configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Application shell<br/>[App.js]"]
  node_sample_form["Sample form<br/>[MainForm.js]"]
  node_palette["Palette picker<br/>[PalettePicker.js]"]
end

subgraph group_api["API and workflow"]
  node_api_route["Sample API route<br/>[main.py]"]
  node_request_schema["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_data["Sample persistence"]
  node_user_model["User records<br/>[models.py]"]
  node_sample_model["Sample records<br/>[models.py]"]
  node_db_config["Database configuration<br/>[database.py]"]
  node_sqlite[("SQLite database")]
end

subgraph group_analysis["Classifier analysis"]
  node_matcher["Matcher workflow<br/>[matcher.py]"]
  node_sample_format["Sample formatting<br/>[matcher.py]"]
  node_training["Classifier training<br/>[matcher.py]"]
  node_classifiers["ML classifiers<br/>[matcher.py]"]
  node_authentication["User classification<br/>[matcher.py]"]
end

node_user(("Research user"))

node_user -->|"enters samples"| node_sample_form
node_app -->|"renders"| node_sample_form
node_app -->|"renders"| node_palette
node_sample_form -->|"posts sample"| node_api_route
node_api_route -->|"returns feedback"| node_sample_form
node_api_route -->|"validates and responds"| node_request_schema
node_api_route -->|"queries and creates"| node_user_model
node_api_route -->|"stores training sample"| node_sample_model
node_user_model -->|"uses ORM base"| node_db_config
node_sample_model -->|"uses ORM base"| node_db_config
node_api_route -->|"creates tables and sessions"| node_db_config
node_db_config -->|"configures connection"| node_sqlite
node_api_route -->|"loads and dispatches"| node_matcher
node_matcher -->|"reads existing samples"| node_sqlite
node_matcher -->|"formats samples"| node_sample_format
node_matcher -->|"adds data and trains"| node_training
node_matcher -->|"requests match"| node_authentication
node_training -->|"fits models"| node_classifiers
node_authentication -->|"predicts with selected model"| node_classifiers

click node_app "https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/App.js"
click node_sample_form "https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/components/MainForm.js"
click node_palette "https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/components/PalettePicker.js"
click node_api_route "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/main.py"
click node_request_schema "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/schemas.py"
click node_user_model "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/models.py"
click node_sample_model "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/models.py"
click node_db_config "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/database.py"
click node_matcher "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py"
click node_sample_format "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py"
click node_training "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py"
click node_classifiers "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py"
click node_authentication "https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.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_app,node_sample_form,node_palette,node_user toneBlue
class node_api_route,node_request_schema toneAmber
class node_user_model,node_sample_model,node_db_config,node_sqlite toneMint
class node_matcher,node_sample_format,node_training,node_classifiers,node_authentication toneRose
```

## Components

### User interface

- [Application shell](https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/App.js): `react_frontend/src/App.js`
- [Sample form](https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/components/MainForm.js): `react_frontend/src/components/MainForm.js`
- [Palette picker](https://github.com/orebenson/keystroke_analyser/blob/main/react_frontend/src/components/PalettePicker.js): `react_frontend/src/components/PalettePicker.js`

### API and workflow

- [Sample API route](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/main.py): `backend/app/main.py`
- [Request and response schemas](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### Sample persistence

- [User records](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/models.py): `backend/app/models.py`
- [Sample records](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database configuration](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/database.py): `backend/app/database.py`
- **SQLite database**

### Classifier analysis

- [Matcher workflow](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py): `backend/app/matcher.py`
- [Sample formatting](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py): `backend/app/matcher.py`
- [Classifier training](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py): `backend/app/matcher.py`
- [ML classifiers](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py): `backend/app/matcher.py`
- [User classification](https://github.com/orebenson/keystroke_analyser/blob/main/backend/app/matcher.py): `backend/app/matcher.py`

### Other components

- **Research user**

## Connections

- Research user → Sample form: enters samples (evidence: `README.md`)
- Application shell → Sample form: renders (evidence: `react_frontend/src/App.js`)
- Application shell → Palette picker: renders (evidence: `react_frontend/src/App.js`)
- Sample form → Sample API route: posts sample (evidence: `react_frontend/src/components/MainForm.js`)
- Sample API route → Sample form: returns feedback (evidence: `react_frontend/src/components/MainForm.js`)
- Sample API route → Request and response schemas: validates and responds (evidence: `backend/app/main.py`)
- Sample API route → User records: queries and creates (evidence: `backend/app/main.py`)
- Sample API route → Sample records: stores training sample (evidence: `backend/app/main.py`)
- User records → Database configuration: uses ORM base (evidence: `backend/app/models.py`)
- Sample records → Database configuration: uses ORM base (evidence: `backend/app/models.py`)
- Sample API route → Database configuration: creates tables and sessions (evidence: `backend/app/main.py`)
- Database configuration → SQLite database: configures connection (evidence: `backend/app/database.py`)
- Sample API route → Matcher workflow: loads and dispatches (evidence: `backend/app/main.py`)
- Matcher workflow → SQLite database: reads existing samples (evidence: `backend/app/matcher.py`)
- Matcher workflow → Sample formatting: formats samples (evidence: `backend/app/matcher.py`)
- Matcher workflow → Classifier training: adds data and trains (evidence: `backend/app/matcher.py`)
- Matcher workflow → User classification: requests match (evidence: `backend/app/main.py`)
- Classifier training → ML classifiers: fits models (evidence: `backend/app/matcher.py`)
- User classification → ML classifiers: predicts with selected model (evidence: `backend/app/matcher.py`)
