# abinthomasonline/repo2txt architecture

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

- Interactive diagram: https://gitdiagram.com/abinthomasonline/repo2txt
- Repository: https://github.com/abinthomasonline/repo2txt

## Overview

##### Project Type and Purpose
- This is a frontend-only web application designed to convert the structure and contents of a GitHub repository or local directory into a formatted text file that is compatible with LLM prompts.
- Its key focus is on in-browser processing, ensuring privacy by not involving server-side code.

##### Analyzing the File Structure
- Top-level files include HTML pages (index.html and local.html) which serve as entry points for different modes (GitHub repository vs. local directory).
- The “js” directory holds all the JavaScript code responsible for the application’s functionality:
- index.js appears to orchestrate the main logic for handling GitHub repository conversion.
- local.js likely manages file reading and directory conversion for local directories.
- utils.js contains general helper functions.
- zip-utils.js handles the zip file generation for downloading selected files.
- Other files such as LICENSE, README.md, and CNAME are related to project metadata and deployment configuration.

##### Key Components and Their Relationships
- User Interface: Represented by index.html and local.html which render the UI and accept user inputs (like repository selection, file inclusion filters, etc.).
- JavaScript Controllers:
- index.js: Ties the UI actions to the conversion process, starting with fetching GitHub repository details.
- local.js: Handles the special case of local directory support, processing input files selected from the user.
- Utility Modules:
- utils.js: Provides shared utility functions used by other scripts.
- zip-utils.js: Offers capabilities for packaging selected files into a zip for download.
- Data Flow & Interactions:
- The UI triggers events (such as file selection, filtering, and conversion).
- Those events call functions in index.js or local.js.
- These controllers use shared functionality from utils.js.
- If the user opts to download selected files, zip-utils.js handles the packaging process.

##### Architectural Patterns and Design Principles
- Client-Side Processing: All operations are executed in the browser, emphasizing a separation between UI (HTML) and logic (JavaScript).
- Modular Design: Functionality is partitioned into multiple JS files which promote separation of concerns.
- Dynamic Processing: Based on user inputs, different modules interact (e.g., filtering with utils.js, working with zips through zip-utils.js).

##### Technologies / Libraries
- Vanilla HTML/JavaScript is used to build the tool.
- While there is no explicit mention of frameworks, the project uses modular JavaScript to separate functionality.
- Future plans (like compiling Tailwind CSS for styling, as mentioned in the README) suggest potential inclusion of CSS tooling and possibly integration with GitHub Actions.

##### Detail
- Module is annotated with its key responsibilities.
- Direct dependencies among the modules (for instance, how index.js uses utils.js for processing file lists and zip-utils.js for download functionality).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface"
        A["Home (index.html)"]:::ui
        B["Local (local.html)"]:::ui
    end

    subgraph "Controllers"
        C["GitHub Repository Controller (index.js)"]:::ctrl
        D["Local Directory Controller (local.js)"]:::ctrl
    end

    subgraph "Utility Modules"
        E["Utility Functions Module (utils.js)"]:::util
        F["Zip File Generation Module (zip-utils.js)"]:::util
    end

    A -->|"UserInteraction(GitHubRepoSel)"| C
    B -->|"LocalDirInput"| D
    C -->|"UsesUtils"| E
    C -->|"UsesZip"| F
    D -->|"UsesUtils"| E
    D -->|"UsesZip"| F

    %% Click Events
    click A "https://github.com/abinthomasonline/repo2txt/blob/master/index.html"
    click B "https://github.com/abinthomasonline/repo2txt/blob/master/local.html"
    click C "https://github.com/abinthomasonline/repo2txt/blob/master/js/index.js"
    click D "https://github.com/abinthomasonline/repo2txt/blob/master/js/local.js"
    click E "https://github.com/abinthomasonline/repo2txt/blob/master/js/utils.js"
    click F "https://github.com/abinthomasonline/repo2txt/blob/master/js/zip-utils.js"

    %% Styles
    classDef ui fill:#f9c,stroke:#333,stroke-width:2px;
    classDef ctrl fill:#ccf,stroke:#333,stroke-width:2px,rx:10,ry:10;
    classDef util fill:#cfc,stroke:#333,stroke-width:2px;
```
