# grandlay-e/pendu architecture

> Architecture diagram of the GitHub repository grandlay-e/pendu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grandlay-e/pendu
- Repository: https://github.com/grandlay-e/pendu

## Overview

##### Main Components
- Web Scrapping Module: This component is responsible for sending HTTP requests to the external website (https://usito.usherbrooke.ca) to retrieve words, using the functions such as all_words_in_link(link_to_scrap) and all_words_in_all_links(). It also includes regex validation and filtering logic.
- Word Definition Retrieval: A dedicated function (getWordDefinition) queries the external definition source to retrieve meaning for a given word.
- Hangman Game Engine: The interactive game flow is managed here – it chooses a random word (get_word) from words.txt, manages game state (lives, progress), and interacts with the user for letter inputs.
- Test Suite: Represented by testdef.py, this component ensures that specific functionalities (likely word retrieval or game functionality) are covered by tests.

##### Relationships and Interactions
- The File Handling module writes the scrapped words into words.txt and logs events in words.log.
- The Game Engine component reads the file (words.txt) to select a random word and makes use of the Word Definition Retrieval component when a word’s definition is needed.
- Testing is an auxiliary layer that interacts with some or all of these components to validate their functionality.

##### Important Architectural Patterns and Technologies
- Modularity – the project is organized into separate Python scripts that isolate scrapping, definition retrieval, and gameplay.
- Dependency on external libraries – such as requests (for HTTP), BeautifulSoup (for HTML parsing), regular expressions (for validation), and logging (for events/errors).
- The script-based command line interface provides a clear “control entry point” (via main.py) that coordinates higher-level operations.

##### Final Advice for Detail Orientation
- Be detailed in showing every significant component along with their sub-functions (for example, note that scrapping includes both data gathering and regex filtering).
- Even minor elements like log generation for debugging. This level of detail provides a clear understanding of the error-handling and system robustness components.
- Avoid oversimplification – it’s better to include as many concrete components as possible (from main.py coordination to testdef.py testing) to cover every aspect of the system’s function.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Acquisition Layer
    subgraph "Data Acquisition"
        WS["Web Scrapping Module"]:::internal
        EXT["External Website (https://usito.usherbrooke.ca)"]:::external
        WS -->|"HTTP-request"| EXT
    end

    %% Data Processing Layer
    subgraph "Data Processing"
        FH["File Handling & Logging"]:::internal
        WS -->|"ScrapedWords"| FH
    end

    %% Game Flow Layer
    subgraph "Game Flow"
        GE["Hangman Game Engine"]:::internal
        WD["Word Definition Retrieval"]:::internal
        USR["User Input"]:::external
        FH -->|"ReadWords"| GE
        USR -->|"StartsGame"| GE
        GE -->|"RetrieveDefinition"| WD
    end

    %% Testing Layer
    TS["Test Suite"]:::internal
    TS -->|"ValidatesScraping"| WS
    TS -->|"ValidatesGame"| GE

    %% Click Events
    click WS "https://github.com/grandlay-e/pendu/blob/main/mots.py"
    click FH "https://github.com/grandlay-e/pendu/blob/main/mots.py"
    click WD "https://github.com/grandlay-e/pendu/blob/main/mots.py"
    click GE "https://github.com/grandlay-e/pendu/blob/main/main.py"
    click TS "https://github.com/grandlay-e/pendu/blob/main/testdef.py"

    %% Styles
    classDef internal fill:#b3e5fc,stroke:#0277bd,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#dd2c00,stroke-width:2px;
```
