# jordimunozflorensa/hackupc_2024 architecture

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

- Interactive diagram: https://gitdiagram.com/jordimunozflorensa/hackupc_2024
- Repository: https://github.com/jordimunozflorensa/hackupc_2024

## Overview

##### Main Components
- Entry/Control Module: At the center, you have main.py, which acts as the application’s entry point. It likely coordinates invoking the various submodules and handling input (including redirection of error messages to errores.log).
- Data Layer: Represent the CSV files (both in the root and inside the “data” folder, such as products.csv, medicaments.csv, lista_productos*.csv, etc.) as the primary data sources. They function as simple flat-file “databases” storing product information and order lists.
- Algorithm Layer: Include algorithm.py, tsp.py, and sa.py. These files handle the core optimization routines (e.g., solving the TSP problem) – with “sa.py” likely implementing a simulated annealing method as an optimization technique.
- Service Layer: The “services” directory holds modules like name_matcher.py, order_item_manager.py, and order_list_manager.py. These components encapsulate business logic (for instance, matching product names using fuzzy matching, managing items and lists) and provide separation of concerns.
- Utility/Generation Layer: Files like generar_listas.py and lambda_function.py likely assist in generating lists and integrating with cloud services (for speech recognition using google-cloud-speech) or even AWS Lambda if the name is literal.

##### Demonstrate Relationships and Interactions
- That main.py orchestrates the overall flow by reading CSV data, calling the service layer (for matching and ordering items), and then invoking the algorithm components for optimization (TSP implementation).
- The Data Layer supplies raw input to main.py and other modules.
- The Service Layer (name_matcher, order_item_manager, etc.) processes and refines the data (e.g., matching product names with fuzzy logic).
- The Algorithm Layer uses the processed data to execute TSP routines and possibly simulated annealing as implemented in sa.py.
- The results (optimized order lists) are either logged, stored back into CSV files, or passed to further modules (e.g., generar_listas.py) for final output.
- Integration points with external libraries (for speech recognition and fuzzy matching) and external services (if lambda_function.py is deployed as a cloud function).

##### Architectural Patterns and Design Principles
- Modular Design: Highlight that the project is organized into distinct modules (data, business logic/services, and algorithms) – each handling a specific concern.
- Separation of Concerns: Demonstrate that data handling, business logic, and optimization computations are kept in separate files/folders (for instance, by separating algorithm functions from service functions).
- Dependency Management: Note that external libraries (SpeechRecognition, fuzzywuzzy, etc.) are dependencies that integrate into the modules handling speech and text processing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        csv["CSV Data Sources"]:::data
    end

    %% Control Layer
    subgraph "Control Layer"
        main["Main Controller (main.py)"]:::control
    end

    %% Service Layer
    subgraph "Service Layer"
        nm["Name Matcher (services/name_matcher.py)"]:::service
        oim["Order Item Manager (services/order_item_manager.py)"]:::service
        olm["Order List Manager (services/order_list_manager.py)"]:::service
    end

    %% Algorithm Layer
    subgraph "Algorithm Layer"
        algo["Algorithm (algorithm.py)"]:::algorithm
        tsp["TSP Solver (tsp.py)"]:::algorithm
        sa["Simulated Annealing (sa.py)"]:::algorithm
    end

    %% Utility/Generation Layer
    subgraph "Utility/Generation Layer"
        gen["List Generator (generar_listas.py)"]:::utility
        lamb["Cloud Integration (lambda_function.py)"]:::utility
    end

    %% External Libraries/Services
    subgraph "External Libraries/Services"
        sr["SpeechRecognition"]:::external
        fw["FuzzyWuzzy"]:::external
        gcs["Google Cloud Speech"]:::external
    end

    %% Relationships
    csv -->|"supplies_data"| main
    main -->|"calls_matcher"| nm
    main -->|"calls_orderItem"| oim
    main -->|"calls_orderList"| olm
    main -->|"invokes_optimization"| algo
    nm -->|"uses_fuzzy"| fw
    oim -->|"feeds_into"| algo
    olm -->|"feeds_into"| algo
    algo -->|"delegates_to"| tsp
    algo -->|"delegates_to"| sa
    main -->|"triggers_listGen"| gen
    main -->|"invokes_cloud"| lamb
    lamb -->|"uses_speech"| sr
    lamb -->|"uses_cloudAPI"| gcs

    %% Styles
    classDef data fill:#fbe7c6,stroke:#d2691e,stroke-width:2px;
    classDef control fill:#c6f5c6,stroke:#2e8b57,stroke-width:2px;
    classDef service fill:#c6e2ff,stroke:#4682b4,stroke-width:2px;
    classDef algorithm fill:#ffe4e1,stroke:#cd5c5c,stroke-width:2px;
    classDef utility fill:#e6e6fa,stroke:#9370db,stroke-width:2px;
    classDef external fill:#fafad2,stroke:#bdb76b,stroke-width:2px;

    %% Click Events
    click main "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/main.py"
    click csv "https://github.com/jordimunozflorensa/hackupc_2024/tree/main/data/"
    click algo "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/algorithm.py"
    click tsp "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/tsp.py"
    click sa "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/sa.py"
    click nm "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/services/name_matcher.py"
    click oim "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/services/order_item_manager.py"
    click olm "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/services/order_list_manager.py"
    click gen "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/generar_listas.py"
    click lamb "https://github.com/jordimunozflorensa/hackupc_2024/blob/main/lambda_function.py"
```
