# trexlernoah/tap-rewrite architecture

> Architecture diagram of the GitHub repository trexlernoah/tap-rewrite, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trexlernoah/tap-rewrite
- Repository: https://github.com/trexlernoah/tap-rewrite

## Overview

##### Main Components Identification
The system consists of three major components:
- GUI Interface (Tkinter-based menu system)
- Game Interface (Pygame-based subject interaction)
- Hardware Interface (NI-DAQ USB-6001 communication)

**[User Interface Layer]**
- Menu System (Tkinter)
- Game Interface (Pygame)

**[Application Logic Layer]**
- Thread Handler
- Event Queue
- Shock Task Processor

**[Hardware Interface Layer]**
- DAQ Interface
- Coulbourn Shocker Control

**[Thread 1]**
- Tkinter Menu
- PyGame Experiment

**[Thread 2]**
- DAQ Interface
- Shock Processing

##### Component Details

- Blue: User Interface components (Tkinter, Pygame)
- Green: Processing components (Thread Handler, Queue)
- Red: Hardware interface components (DAQ, Shocker)

##### Key Interactions

Specific data flows:
**Menu System → Thread Handler → DAQ Interface**
**Game Interface → Thread Handler → DAQ Interface**
**Thread Handler ←→ Event Queue ←→ Shock Task Processor**

##### Technical Specifications

Annotations for:
- ShockTask parameters (milliamps, duration, cooldown)
- Thread communication methods (Queue, Events)
- Hardware specifications (USB-6001, signal types)

##### Implementation Details

Classes and their relationships:
**ThreadHandler**
- ↓
**ShockTask**
- ↓
**DAQ Interface**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        Menu["Menu System (Tkinter)"]
        Game["Game Interface (Pygame)"]
        Draw["Drawing System"]
        Params["Parameter Handler"]
        Subject["Subject Config"]
    end

    subgraph Logic
        Thread["Thread Handler"]
        Queue["Event Queue"]
        Shock["Shock Task Processor"]
        Constants["Game Constants"]
        Reaction["Reaction System"]
        MenuUtils["Menu Utilities"]
        GameUtils["Game Utilities"]
    end

    subgraph Hardware
        DAQ["DAQ Interface"]
        Shocker["Coulbourn Shocker"]
    end

    %% UI Layer Connections
    Menu --> Thread
    Game --> Thread
    Menu --> Params
    Menu --> Subject
    Game --> Draw
    Game --> GameUtils
    Menu --> MenuUtils

    %% Logic Layer Connections
    Thread --> Queue
    Queue --> Shock
    Shock --> DAQ
    Game --> Constants
    Game --> Reaction
    
    %% Hardware Layer Connections
    DAQ --> Shocker

    %% Component Styles
    classDef ui fill:#a8d1f0
    classDef logic fill:#b7e3b7
    classDef hardware fill:#f5a9a9

    class Menu,Game,Draw,Params,Subject ui
    class Thread,Queue,Shock,Constants,Reaction,MenuUtils,GameUtils logic
    class DAQ,Shocker hardware

    %% Click Events
    click Menu "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/menu/main_menu.py"
    click Game "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/game.py"
    click DAQ "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/daq.py"
    click Shock "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/shock.py"
    click Thread "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/classes.py"
    click Draw "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/drawer.py"
    click Params "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/menu/profile_parameters.py"
    click Subject "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/menu/subject_threshold.py"
    click Constants "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/constants.py"
    click Reaction "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/reaction.py"
    click MenuUtils "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/menu/utils.py"
    click GameUtils "https://github.com/trexlernoah/TAP-Rewrite/blob/main/tap/game/utils.py"
```
