# franciscodominguezmateos/ai architecture

> Architecture diagram of the GitHub repository franciscodominguezmateos/ai, 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/franciscodominguezmateos/ai
- Repository: https://github.com/franciscodominguezmateos/ai

## Overview

##### Main Components
- AI Search Algorithms: Separate modules for each search strategy (pyAIExpectiMax.py, pyAIMinMax.py, and pyAIMinMaxAlphaBeta.py).
- Problem Definition & Domain Modeling: Modules under pyAISearchProblem (pyPathPlanning.py, pyProblem.py, pyState.py) that represent the problem context and state space.
- Data Structures / Collections: The pyAISearchCollections package and its underlying implementation (pyAISearchCollection.py), used to store and manage nodes or states.
- Node Representation: Individual modules such as pyAISearchNode.py, which likely encapsulate the properties of each node in the search tree.
- Solver Implementations: Different solver approaches are evident from pyAISearchSolver, pyAISearchSolverGraph, and pyAISearchSolverTree which indicate implementations for exploring the problem space.
- Main Application Entrypoints: The main modules (pyMainPathPlanning.py, pyMainTicToc.py) that likely serve as execution points for different use cases or problem scenarios.

##### Relationships and Interactions
- The Problem Definition layer (within pyAISearchProblem) should be depicted as the foundation that defines the rules, states, and dynamics of the specific scenarios (like path planning or Tic Tac Toe).
- Search Nodes and Collections: The node representations (pyAISearchNode) are used by both the search algorithms and solvers. The search collections provide the data structure (e.g., queues, stacks, or priority queues) required for managing these nodes.
- Search Algorithms: Each algorithm (MinMax, ExpectiMax, and MinMaxAlphaBeta) will interact with the solver components by consulting the problem definitions and using the collections to traverse the state space.
- Solver Variants: The difference between graph and tree solvers should be clearly noted. Specify how the solvers use either tree or graph-based expansions to manage the search process.
- Main Application Entry Points: These modules (pyMainPathPlanning and pyMainTicToc) interact with the problem definitions, initiate the appropriate search and solve flows, and then output or handle the results.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The design clearly segments the problem modeling, algorithmic logic, data management, and solver control.
- Modularity: Each search algorithm and problem type is implemented in separate modules, making it easier to extend or replace individual components.
- Reusability: The collections and node modules are abstracted out to be reused across different algorithm implementations and problem instances.

##### Relevant Technologies and Frameworks
- Python as the primary programming language.
- If any additional libraries or design patterns (e.g., MVC-like separation, dependency injection) are used, mention them based on common practices; however, the file tree itself suggests a focus on algorithmic implementations rather than a web framework or full-stack application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Application Entrypoints
    subgraph "Main Application Entrypoints"
        E1["Path Planning Entry Point"]:::entry
        E2["Tic Tac Toe Entry Point"]:::entry
    end

    %% Problem Modeling Layer
    subgraph "Problem Modeling"
        P1["General Problem Definition"]:::problem
        P2["Path Planning"]:::problem
        P3["State Modeling"]:::problem
        P4["Tic Tac Toe Problem"]:::problem
    end

    %% AI Search Algorithms
    subgraph "AI Search Algorithms"
        A1["MinMax"]:::algo
        A2["ExpectiMax"]:::algo
        A3["MinMax with Alpha-Beta Pruning"]:::algo
    end

    %% Data Structures & Node Representation
    subgraph "Data Structures & Node Representation"
        D1["Search Collections"]:::datastruct
        D2["Search Node"]:::nodeStyle
    end

    %% Solvers
    subgraph "Solvers"
        S1["General Solver"]:::solver
        S2["Graph-based Solver"]:::solver
        S3["Tree-based Solver"]:::solver
    end

    %% Connections from Main Entrypoints to Problem Modeling
    E1 -->|"uses"| P1
    E1 -->|"specifies"| P2
    E2 -->|"uses"| P1
    E2 -->|"specifies"| P4

    %% Connections from Problem Modeling to AI Algorithms and Solvers
    P1 -->|"informs"| A1
    P1 -->|"informs"| A2
    P1 -->|"informs"| A3
    P1 -->|"directs"| S1
    P1 -->|"directs"| S2
    P1 -->|"directs"| S3
    P3 -->|"supports"| S1
    P3 -->|"supports"| S2
    P3 -->|"supports"| S3

    %% Connections from AI Algorithms to Data Structures/Node Representation
    A1 -->|"processes"| D2
    A1 -->|"utilizes"| D1
    A2 -->|"processes"| D2
    A2 -->|"utilizes"| D1
    A3 -->|"processes"| D2
    A3 -->|"utilizes"| D1

    %% Connections from Solvers to Data Structures/Node Representation
    S1 -->|"expands"| D2
    S1 -->|"manages"| D1
    S2 -->|"expands"| D2
    S2 -->|"manages"| D1
    S3 -->|"expands"| D2
    S3 -->|"manages"| D1

    %% Click Events for Main Application Entrypoints
    click E1 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyMainPathPlanning.py"
    click E2 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyMainTicToc.py"

    %% Click Events for Problem Modeling Components
    click P1 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchProblem/pyProblem.py"
    click P2 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchProblem/pyPathPlanning.py"
    click P3 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchProblem/pyState.py"
    click P4 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAITicTocProblem.py"

    %% Click Events for AI Search Algorithms
    click A1 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAIMinMax.py"
    click A2 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAIExpectiMax.py"
    click A3 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAIMinMaxAlphaBeta.py"

    %% Click Events for Data Structures / Node Representation
    click D1 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchCollections/pyAISearchCollection.py"
    click D2 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchNode.py"

    %% Click Events for Solvers
    click S1 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchSolver.py"
    click S2 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchSolverGraph.py"
    click S3 "https://github.com/franciscodominguezmateos/ai/blob/main/pyAISearch/src/pyAISearchSolverTree.py"

    %% Styles
    classDef problem fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef algo fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef datastruct fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef nodeStyle fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef solver fill:#d2b4de,stroke:#7d3c98,stroke-width:2px;
    classDef entry fill:#fadbd8,stroke:#c0392b,stroke-width:2px;
```
