# jonathanleahy/folder-bundler architecture

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

- Interactive diagram: https://gitdiagram.com/jonathanleahy/folder-bundler
- Repository: https://github.com/jonathanleahy/folder-bundler

## Overview

##### Project type and purpose
- folder-bundler is a standalone Go-based CLI tool.
- Purpose: collect a directory’s full structure and file contents into a single document, then reconstruct the original tree elsewhere.
- Not a web service or microservice: it’s a developer tool for file-system documentation and recreation.

##### File structure
- Top-level:
- main.go, main_test.go – CLI entrypoint and test harness
- internal/ – core packages, hidden from external imports
- output/ – sample outputs (generated documentation, reconstructed files)
- test/ – additional test driver
- internal/collect – collector.go: scans directories, reads files, serializes into documentation
- internal/config – params.go: parses CLI flags (max-file, exclude-dirs, etc.)
- internal/fileutils – utils.go: low-level file reads/writes, splitting large files, metadata extraction
- internal/reconstruct – reconstructor.go: parses the document created by collector and rebuilds directory tree and files
- config files (go.mod, go.sum) and .gitignore confirm pure Go build, no external services.

##### README for additional insights
- Describes two main commands: “collect” and “reconstruct.”
- Highlights features: syntax highlighting, large-file splitting, metadata/timestamp preservation, exclusion rules.
- Use cases focus on documentation, archiving, code review—no network or real-time component.

##### Detail and essential elements
- Be explicit about metadata flow (timestamps, permissions) through FileUtils.
- How exclusion patterns (from Config) feed into Collector’s directory walker.
- Both CLI parsing logic and the two distinct pipelines (collect vs reconstruct).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI and project artifacts
    CLI["CLI Layer<br/>(main.go)"]:::code
    CLItest["CLI Test Harness<br/>(main_test.go)"]:::code
    TestDriver["Additional Test Driver<br/>(test/main.go)"]:::code
    GoMod["go.mod & go.sum"]:::code
    README["README.md"]:::code

    %% Core internal packages
    subgraph "Internal Packages"
        Config["Configuration Module<br/>(params.go)"]:::code
        Collector["Collection Engine<br/>(collector.go)"]:::code
        FileUtils["File Utilities<br/>(utils.go)"]:::code
        Reconstructor["Reconstruction Engine<br/>(reconstructor.go)"]:::code
    end

    %% File system and documents
    FileSystem["File System"]:::filesystem
    Document["Output Document<br/>(.md / serialized)"]:::document
    OutputDir["Sample Outputs<br/>(output/)"]:::filesystem

    %% Workflow arrows
    CLI -->|"parse flags"| Config
    CLI -->|"collect command"| Collector
    CLI -->|"reconstruct command"| Reconstructor
    Config --> Collector
    Config --> Reconstructor

    Collector -->|"uses"| FileUtils
    FileUtils -->|"reads"| FileSystem
    Collector -->|"writes"| Document

    Reconstructor -->|"reads"| Document
    Document -->|"provides data to"| FileUtils
    FileUtils -->|"writes"| FileSystem
    Reconstructor -->|"generates"| OutputDir

    %% Click events
    click CLI "https://github.com/jonathanleahy/folder-bundler/blob/main/main.go"
    click CLItest "https://github.com/jonathanleahy/folder-bundler/blob/main/main_test.go"
    click Config "https://github.com/jonathanleahy/folder-bundler/blob/main/internal/config/params.go"
    click Collector "https://github.com/jonathanleahy/folder-bundler/blob/main/internal/collect/collector.go"
    click FileUtils "https://github.com/jonathanleahy/folder-bundler/blob/main/internal/fileutils/utils.go"
    click Reconstructor "https://github.com/jonathanleahy/folder-bundler/blob/main/internal/reconstruct/reconstructor.go"
    click OutputDir "https://github.com/jonathanleahy/folder-bundler/tree/main/output/"
    click TestDriver "https://github.com/jonathanleahy/folder-bundler/blob/main/test/main.go"
    click GoMod "https://github.com/jonathanleahy/folder-bundler/blob/main/go.mod"
    click README "https://github.com/jonathanleahy/folder-bundler/blob/main/README.md"

    %% Styles
    classDef code fill:#D6EAF8,stroke:#1F618D,color:#1B2631;
    classDef filesystem fill:#A9DFBF,stroke:#196F3D,color:#145A32;
    classDef document fill:#F9E79F,stroke:#B9770E,color:#7E5109;
```
