# yorak/verypy architecture

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

- Interactive diagram: https://gitdiagram.com/yorak/verypy
- Repository: https://github.com/yorak/verypy

## Overview

##### Project Type and Purpose
- VeRyPy is a specialized library rather than a typical full-stack application. Its primary goal is to provide reproducible implementations of classical CVRP (and some TSP) heuristics.
- The README emphasizes that it is “easy to use” and allows users to avoid reimplementing well-known algorithms. This implies that the library is modular and intended for both direct use (via command line or as a module) and extension by researchers or developers.
- It also provides integration hooks (wrappers) for external solvers such as LKH and Gurobi, and has visualization components.

##### Key Architectural Components Identified from the File Tree
- Core Library (Directory: verypy)
⁃ Contains the main entry points: VeRyPy.py, VeRyPyGui.py, shared_cli.py, and __main__.py which is used for a command-line interface.
⁃ Submodules here include:
▸ classic_heuristics: Implementations of classical algorithms (e.g., cheapest insertion, savings-based, sweep heuristics).
▸ local_search: Provides intra- and inter-route local search operators.
▸ tsp_solvers: Contains different TSP solvers/wrappers (e.g., LKH, acotsp, gurobi-based TSP solver).
▸ Config and utility modules (config.py, util.py, routedata.py, cvrp_io.py) provide central configuration, data I/O and utility functions.
- Examples (Directory: examples)
⁃ Contains sample problems, demonstration scripts and even an integration example (e.g., using Bing maps API) which utilizes the library.
- Scripts (Directory: scripts)
⁃ Provides helper scripts for running experiments and printing diagnostics (e.g., checking package licenses, printing Python info).
- Tests (Directory: tests)
⁃ Organized with replication tests for verifying algorithm correctness along with additional unit tests.
- Documentation (Directory: doc)
- Installation and Setup Files (e.g., setup.py, requirements.txt, LICENSE, etc.)
⁃ Indicate that the project is packaged for distribution and dependency management.

##### Relationships and Interactions between Components
- User Entry: Users interact with the system either via the CLI (using VeRyPy.py or the __main__.py module) or by importing modules programmatically in their own Python scripts.
- Data Input/Output: The cvrp_io module reads problem instance files (e.g., TSPLIB or TSPLIB95 formatted files) and formats inputs (such as distance matrices and demand lists) which are then passed into algorithm modules.
- Algorithm Components:
▸ The “classic_heuristics” submodule holds implementations of various deterministic heuristics (like Parallel Savings, Sweep, etc.).
▸ The “local_search” submodule provides neighborhood search and improvement operators that might be invoked as part of enhancing a solution.
▸ The “tsp_solvers” module offers wrappers to delegate TSP subproblems to external solvers like LKH or Gurobi.
- Visualization: The “visualizers” submodule takes the resulting solutions and generates graphical outputs that can be displayed or saved.
- External Dependencies: Certain heuristic implementations require external solvers such as LKH (detailed in LKH_install_notes.md) or Gurobi’s Python bindings. These are referenced within the heuristic modules and are integrated as separate components.
- Testing & Experimentation: The “tests” directory encapsulates unit and replication tests that ensure reliability of each module. There are also example scripts and experiments to compare performance and results.

##### Final Review for Detail Capture
- Main component is clearly labeled and its role is briefly annotated.
- If applicable, include notes on external dependency requirements and how they are integrated into, for example, the TSP solvers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::user

    subgraph "VeRyPy Core Library"
        CORE("Core Library"):::core
        CLI("CLI Interface"):::interface
        GUI("GUI Interface"):::interface
        IO("Input/Output (cvrp_io)"):::io
        CH("Classic Heuristics"):::core
        LS("Local Search Operators"):::core
        TS("TSP Solvers"):::core
        VIS("Visualization Components"):::core
        CONFIG("Config & Utility"):::config
    end

    EXTERNAL("External Dependency (LKH)"):::external

    EXAMPLES("Examples & Demos"):::aux
    SCRIPTS("Experiment & Diagnostics Scripts"):::aux
    TESTS("Testing Suite"):::aux
    DOCS("Documentation"):::aux

    User -->|"uses"| CLI
    User -->|"uses"| GUI
    CLI -->|"triggers"| IO
    GUI -->|"triggers"| IO
    IO -->|"provides_data"| CH
    IO -->|"provides_data"| LS
    IO -->|"provides_data"| TS
    CONFIG -->|"supports"| CH
    CONFIG -->|"supports"| LS
    CONFIG -->|"supports"| TS
    CH -->|"generates_solution"| VIS
    LS -->|"optimizes_solution"| VIS
    TS -->|"delegates_to"| EXTERNAL
    TS -->|"generates_solution"| VIS
    VIS -->|"outputs_solution"| User

    CORE --- EXAMPLES
    CORE --- SCRIPTS
    CORE --- TESTS
    CORE --- DOCS

    %% Click Events
    click CORE "https://github.com/yorak/verypy/tree/master/verypy/"
    click CLI "https://github.com/yorak/verypy/blob/master/verypy/VeRyPy.py"
    click CLI "https://github.com/yorak/verypy/blob/master/verypy/__main__.py"
    click GUI "https://github.com/yorak/verypy/blob/master/verypy/VeRyPyGui.py"
    click CH "https://github.com/yorak/verypy/tree/master/verypy/classic_heuristics/"
    click LS "https://github.com/yorak/verypy/tree/master/verypy/local_search/"
    click TS "https://github.com/yorak/verypy/tree/master/verypy/tsp_solvers/"
    click VIS "https://github.com/yorak/verypy/tree/master/verypy/visualizers/"
    click IO "https://github.com/yorak/verypy/blob/master/verypy/cvrp_io.py"
    click CONFIG "https://github.com/yorak/verypy/blob/master/verypy/config.py"
    click CONFIG "https://github.com/yorak/verypy/blob/master/verypy/util.py"
    click CONFIG "https://github.com/yorak/verypy/blob/master/verypy/routedata.py"
    click CONFIG "https://github.com/yorak/verypy/blob/master/verypy/shared_cli.py"
    click EXTERNAL "https://github.com/yorak/verypy/blob/master/LKH_install_notes.md"
    click EXAMPLES "https://github.com/yorak/verypy/tree/master/examples/"
    click SCRIPTS "https://github.com/yorak/verypy/tree/master/scripts/"
    click TESTS "https://github.com/yorak/verypy/tree/master/tests/"
    click DOCS "https://github.com/yorak/verypy/tree/master/doc/"

    %% Styles
    classDef user fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef core fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef interface fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef io fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef config fill:#F5CBA7,stroke:#873600,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef aux fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;
```
