How abinthomasonline/repo2txt works
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).