# megabluejay/mini_choice architecture

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

- Interactive diagram: https://gitdiagram.com/megabluejay/mini_choice
- Repository: https://github.com/megabluejay/mini_choice

## Overview

##### Main components
- CLI/Entry Point: The tool is invoked via the command line (see usage “choice”), with the main entry point in mini_choice/main.py.
- File Reader / Scene Loader: The module mini_choice/fileHandler.py is likely responsible for reading the scene files (from the “scenes” folder).
- Lexer / Parser: The mini_choice/lexer.py module handles tokenizing or parsing the contents of the scene files.
- Utility Modules: Additional modules like mini_choice/curried_mods.py, mini_choice/mio.py, and mini_choice/tabdetect.py support the processing. For example, “tabdetect” may be used to handle indentation or formatting concerns in scene files.
- Scene Data: The “scenes” folder holds several text files (e.g., animal.txt, death.txt, startup.txt) that serve as the input narrative data.

##### Relationships and interactions
- The CLI component (main.py) accepts command-line arguments (including optionally a custom directory) and initiates the processing workflow.
- It calls the File Handler to load scene files from the specified directory.
- After loading, the content is passed to the Lexer to tokenize and analyze the narrative text.
- Utility modules then assist in transforming, formatting, or otherwise processing these tokens (e.g., using tab detection to handle indentation or employing curried functions for modular transformations).
- Finally, the processed data is used to drive the interactive narrative flow, likely resulting in formatted console output (possibly using termcolor for colorized text and tabulate for display tables).

##### Architectural patterns and design principles
- Modularity: Clearly separated modules for CLI, file handling, lexical analysis, and auxiliary utilities.
- Pipeline processing: The flow resembles a pipeline where input (scene files) is read, tokenized, and then processed before output is generated.
- Dependency Injection via Configuration: Although not extensive, the use of setup/config files (setup.py, setup.cfg, MANIFEST.in) ensures this project is packaged as a shareable tool – encouraging reuse and maintainability.
- Lightweight and focused: As a command-line tool built for interactive narratives, the number of components is minimal, yet each plays a distinct role in the workflow.

##### Final advice for the Engineer
– Separate the project into as many specific components as possible to clearly show responsibility and interactions.
– Emphasize the sequential data transformation: from raw scene files (input) through file reading, lexing/parsing, auxiliary processing, to final interactive output.

## Diagram (Mermaid)

```mermaid
graph TD
    SceneData["Scene Data Input"]:::input
    CLI["CLI & Main Controller"]:::cli
    FileLoader["File Loader"]:::module
    Lexer["Lexer / Parser"]:::module
    Curried["Curried Mods"]:::utility
    MIO["MIO"]:::utility
    TabDetect["Tab Detect"]:::utility
    InterOutput["Interactive Narrative Output"]:::output

    CLI -->|"invokes"| FileLoader
    SceneData -->|"providesFiles"| FileLoader
    FileLoader -->|"readsAndPassesContent"| Lexer
    Lexer -->|"tokenizes"| Curried
    Lexer -->|"tokenizes"| MIO
    Lexer -->|"tokenizes"| TabDetect
    Curried -->|"processesTokens"| InterOutput
    MIO -->|"processesTokens"| InterOutput
    TabDetect -->|"processesTokens"| InterOutput

    click CLI "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/main.py"
    click FileLoader "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/fileHandler.py"
    click Lexer "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/lexer.py"
    click Curried "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/curried_mods.py"
    click MIO "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/mio.py"
    click TabDetect "https://github.com/megabluejay/mini_choice/blob/master/mini_choice/tabdetect.py"
    click SceneData "https://github.com/megabluejay/mini_choice/tree/master/scenes/"

    classDef cli fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef module fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef utility fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef input fill:#f8961e,stroke:#333,stroke-width:2px;
    classDef output fill:#577590,stroke:#333,stroke-width:2px;
```
