Impulse Guard

Inspiration

Impulse Guard came from thinking about how often people make bad decisions online when they are tired, distracted, or drunk. Things like impulsive purchases, gambling, or sending messages are often done without thinking properly. Once the action is taken it can be difficult or impossible to undo.

The idea behind this project was to introduce a short checkpoint before a sensitive action is allowed. Instead of asking the user to confirm again with a button, the system checks whether the user appears capable of making a deliberate decision.

To do this, the project runs two simple tests that measure cognitive ability in real time: a speech test and a mouse tracking test.


What the project does

Impulse Guard runs two tests in sequence:

  1. Speech test – the user reads a sentence aloud.
  2. Mouse tracking test – the user follows a moving line with their mouse.

Both tests measure accuracy. The final result is calculated from the average of the two scores:

[ \text{Average Accuracy} = \frac{\text{Speech Accuracy} + \text{Mouse Accuracy}}{2} ]

If the average score is above 70%, the test passes and the system generates a temporary unlock key.

If the score is below the threshold, the user is asked to try again.

The unlock key can then be used by a browser extension or another system to allow the protected action.


How it was built

The project consists of a Python backend and a web interface.

Backend

The backend is written in Python using Flask. It manages the full test flow:

  • starting and stopping tests
  • generating sentences for the speech test
  • tracking mouse movement accuracy
  • monitoring the webcam to ensure only one face is present
  • generating temporary unlock keys

Shared state objects are used to keep track of the test progress:

test_state = {
    "running": False,
    "phase": "idle",
    "speech_accuracy": None,
    "mouse_accuracy": None,
    "average_accuracy": None,
    "passed": False
}
Share this project:

Updates