# andrestorres123/delve architecture

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

## Overview

##### Main Components
- Input / Data Ingestion: Represent how raw unstructured text data is provided to the system.
- Configuration & Setup: Include the configuration aspects (e.g., setting API keys like ANTHROPIC_API_KEY using environment variables) and supporting files (like pyproject.toml, .env.example).
- Core Taxonomy Generation Engine:
- Graph Orchestrator: In the “src/taxonomy_generator/graph.py” module, this central component orchestrates the taxonomy generation process.
- Nodes Subsystem: Under “src/taxonomy_generator/nodes”, list the different nodes/modules (doc_labeler, minibatches_generator, runs_retriever, summary_generator, taxonomy_generator, taxonomy_reviewer, taxonomy_updater). Each node performs a specific step in the multi-stage taxonomy generation process.
- Prompts Module: Capture how prompts (in “src/taxonomy_generator/prompts.py”) are used to interact with LLMs.
- Routing & Decision Making:
- Routing: Indicate the “src/taxonomy_generator/routing” directory’s role, especially modules such as “should_review.py”, which seem to control decision flows (for example, when to trigger a taxonomy review).
- State Management & Utilities:
- Components for managing state (e.g., “src/taxonomy_generator/state.py”) and other utility functions (“src/taxonomy_generator/utils.py”).
- External Checkpoints & Persistence:
- “.langgraph_api” folder which stores various checkpoints (serialized with pickle). This might reflect system state persistence or caching used in the taxonomy generation process.
- Output Generation:
- System’s outputs (messages, clusters, documents) as described in the README, showing how the processed data flows out from the central engine for reporting and further use.

##### Relationships and Data Flow
- A clear flow where raw text data is input into the system through an ingestion module.
- Demonstrate the initialization phase where configuration settings and API keys are loaded.
- How routing decisions (like whether to review a taxonomy) influence the path through the nodes.
- Handoff from LLM-driven processes to the final generation of structured outputs (messages, clusters, documents).

##### Architectural Patterns and Design Principles
- Modular Design: Emphasize that the system is divided into discrete nodes and modules, each responsible for a particular step in the process. This modularity promotes maintainability and scalability.
- Orchestration via a Graph Pattern: Highlight the use of a “graph” approach where various nodes interact based on a predetermined sequence or decision tree.
- Separation of Concerns: Clearly distinguish between modules handling configuration, processing, state management, and output generation.
- Robust State Handling: Include how the system uses checkpoints (.pckl files) to manage process state or retries, ensuring reliability.

##### Final Touches
- Keep it detailed, ensuring that even minor modules (like routing decisions or state management) are represented if they play a critical role.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input and Configuration
    subgraph "Preprocessing Layer"
        IN["Input / Data Ingestion"]:::ingestion
        CONFIG["Configuration & Setup"]:::config
        ENV[".env.example"]:::config
        PYPROJ["pyproject.toml"]:::config
    end

    %% Core Taxonomy Generation Engine
    subgraph "Core Engine"
        GO["Graph Orchestrator"]:::engine
        subgraph "Nodes Subsystem"
            DOC["Document Labeling"]:::node
            MINI["Minibatches Generation"]:::node
            RUNS["Runs Retrieval"]:::node
            SUMMARY["Summary Generation"]:::node
            TAXGEN["Taxonomy Generation"]:::node
            TAXREV["Taxonomy Reviewing"]:::node
            TAXUPD["Taxonomy Updating"]:::node
        end
        PROMPT["Prompts Module"]:::node
        ROUTE["Routing Decision (should_review)"]:::routing
        STATE["State Management"]:::utils
        UTILS["Utility Functions"]:::utils
    end

    %% External Persistence and Output
    subgraph "Post Processing"
        STORAGE["Checkpoint Persistence (.langgraph_api)"]:::storage
        OUTPUT["Output Generation (Messages/Clusters/Documents)"]:::output
    end

    %% Data Flow
    IN -->|"provides raw data"| CONFIG
    CONFIG -->|"loads env and configs"| ENV
    CONFIG --> PYPROJ
    CONFIG -->|"initializes"| GO
    GO --> DOC
    DOC --> MINI
    MINI --> RUNS
    RUNS --> SUMMARY
    SUMMARY --> TAXGEN
    TAXGEN -->|"triggers review"| TAXREV
    TAXREV --> TAXUPD
    GO --> PROMPT
    GO --> STATE
    GO --> UTILS
    GO --> ROUTE
    ROUTE --> TAXREV
    TAXUPD --> STORAGE
    TAXREV --> STORAGE
    STORAGE --> OUTPUT
    TAXGEN --> OUTPUT

    %% Click Events
    click ENV "https://github.com/andrestorres123/delve/blob/main/.env.example"
    click PYPROJ "https://github.com/andrestorres123/delve/blob/main/pyproject.toml"
    click GO "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/graph.py"
    click DOC "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/doc_labeler.py"
    click MINI "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/minibatches_generator.py"
    click RUNS "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/runs_retriever.py"
    click SUMMARY "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/summary_generator.py"
    click TAXGEN "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/taxonomy_generator.py"
    click TAXREV "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/taxonomy_reviewer.py"
    click TAXUPD "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/nodes/taxonomy_updater.py"
    click PROMPT "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/prompts.py"
    click ROUTE "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/routing/should_review.py"
    click STATE "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/state.py"
    click UTILS "https://github.com/andrestorres123/delve/blob/main/src/taxonomy_generator/utils.py"
    click STORAGE "https://github.com/andrestorres123/delve/blob/main/.langgraph_api"

    %% Styles
    classDef ingestion fill:#8dd3c7,stroke:#333,stroke-width:2px;
    classDef config fill:#ffffb3,stroke:#333,stroke-width:2px;
    classDef engine fill:#bebada,stroke:#333,stroke-width:2px;
    classDef node fill:#fb8072,stroke:#333,stroke-width:2px;
    classDef routing fill:#80b1d3,stroke:#333,stroke-width:2px;
    classDef utils fill:#ccebc5,stroke:#333,stroke-width:2px;
    classDef storage fill:#fdb462,stroke:#333,stroke-width:2px;
    classDef output fill:#fccde5,stroke:#333,stroke-width:2px;
```
