# crr004/bowling-game architecture

> Architecture diagram of the GitHub repository crr004/bowling-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crr004/bowling-game
- Repository: https://github.com/crr004/bowling-game

## Overview

##### Main components
- Process Manager: The central process “A” which initiates the game and spawns child processes.
- Child Processes: Each pin in the bowling game is represented as a process (e.g., B, C, D, etc.). The README provides two different trees: one representing the actual process tree and another representing the “logical” pyramid of pins.
- Signal Handling Module: The mechanism by which SIGTERM is sent to a chosen process (pin) to trigger downstream propagation.
- User Interaction: The terminal interface that starts the game (executing “./bolos”) and then the user’s subsequent use of system utilities (ps, kill) to interact with the processes.

##### Relationships and interactions
- How the signal is sent from the user to process A (or one of its children, based on PID lookup) and then how each process conditionally propagates that signal down to one or both of its children.

##### Architectural patterns/design principles
- Process Tree Structure: The use of a hierarchical process tree is central—both the actual system process tree (parent-child relationships) and the logical gameplay pyramid.
- Asynchronous Event Handling: The reliance on system signals (SIGTERM) for inter-process communication leverages asynchronous event handling.
- Modularity: Even though the implementation is in a single C file, the logical separation (initialization, process creation, signal handling) should be clearly represented.

##### Relevant technologies and system calls
- C Programming Language
- System Calls (fork, kill, signal handling functions)
- Standard Unix/Linux utilities (ps for listing processes) and signal sending.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    U["User (Terminal)"]:::user

    %% Physical Process Tree
    subgraph "Physical Process Tree"
        A_phys["Pin A (Process Manager)"]:::physicalProc
        B_phys["Pin B"]:::physicalProc
        C_phys["Pin C"]:::physicalProc
        D_phys["Pin D"]:::physicalProc
        E_phys["Pin E"]:::physicalProc
        F_phys["Pin F"]:::physicalProc
        G_phys["Pin G"]:::physicalProc
    end

    %% Signal Handling Module
    SH["Signal Handling Module"]:::signal

    %% Logical Bowling Pyramid
    subgraph "Logical Bowling Pyramid"
        A_log["Pin A"]:::logicalProc
        B_log["Pin B"]:::logicalProc
        C_log["Pin C"]:::logicalProc
        D_log["Pin D"]:::logicalProc
        E_log["Pin E"]:::logicalProc
        F_log["Pin F"]:::logicalProc
        G_log["Pin G"]:::logicalProc
    end

    %% Connections from User to Physical Process Tree
    U -->|"SIGTERM"| A_phys

    %% Physical Process Tree: Process creation (fork)
    A_phys -->|"fork"| B_phys
    A_phys -->|"fork"| C_phys
    B_phys -->|"fork"| D_phys
    B_phys -->|"fork"| E_phys
    C_phys -->|"fork"| F_phys
    C_phys -->|"fork"| G_phys

    %% Signal Handling: Integration between layers
    A_phys -->|"handles"| SH
    SH -->|"propagates"| A_log

    %% Vertical mapping from Physical to Logical Nodes
    A_phys -.->|"maps"| A_log
    B_phys -.->|"maps"| B_log
    C_phys -.->|"maps"| C_log
    D_phys -.->|"maps"| D_log
    E_phys -.->|"maps"| E_log
    F_phys -.->|"maps"| F_log
    G_phys -.->|"maps"| G_log

    %% Logical Bowling Pyramid: Signal propagation ("fall" simulation)
    A_log -.->|"fall"| B_log
    A_log -.->|"fall"| C_log
    B_log -.->|"fall"| D_log
    B_log -.->|"fall"| E_log
    C_log -.->|"fall"| F_log
    C_log -.->|"fall"| G_log

    %% Click Events
    click A_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click B_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click C_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click D_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click E_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click F_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click G_phys "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click SH "https://github.com/crr004/bowling-game/blob/main/bolos.c"
    click U "https://github.com/crr004/bowling-game/blob/main/bolos.c"

    %% Styles
    classDef user fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef physicalProc fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef logicalProc fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef signal fill:#F5B7B1,stroke:#333,stroke-width:2px;
```
