# nouuu/gopeek architecture

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

- Interactive diagram: https://gitdiagram.com/nouuu/gopeek
- Repository: https://github.com/nouuu/gopeek

## Overview

##### Main Components
- CLI Entry Point: Represented by the “cmd/gopeek” directory, which contains the main.go file (plus its associated test file). This is where the program starts.
- Internal Modules:
- Scanner Module: Found under “internal/scanner” (with files like scanner.go, config.go, types.go). This module handles the recursive scanning of directories, file handling, binary detection, file size constraints, and assembling the project tree.
- Ignore Module: Located in “internal/ignore”. This component manages the configurable ignore patterns (e.g., from .gitignore) to filter out unwanted directories or files.
- Logger Module: Present under “internal/logger”. This module is responsible for logging information during execution and likely helps with verbose output and error reporting.
- Supporting Components: Although not directly shown as separate directories, the project configuration files (Makefile, go.mod, GitHub Actions workflow files, etc.) represent the build, test, and release pipeline which are integral for CI/CD but less impactful on runtime architecture.

##### Relationships and Interactions
- The CLI entry point (main.go) initializes the application, processes command-line flags, and then orchestrates the scanning process.
- It calls upon the scanner module to recursively explore directories and generate the documentation.
- The scanner module, in turn, utilizes the ignore module to filter out directories and files based on user-defined or .gitignore patterns.
- Throughout the process, the logger module is used to log runtime information (debug, error, info) which aids in monitoring the tool’s operation.
- Once the scanning is complete, the scanner module formats the results into a structured Markdown document that encompasses both a project tree view and file contents.

##### Architectural Patterns and Design Principles
- Modular Design: The system is split into distinct packages (scanner, ignore, logger) to separate concerns and simplify testing.
- CLI Application Design: Uses a clear command-line interface with parsed flags (such as output options and ignore patterns), typical of Go CLI tools, potentially built with Cobra given the README reference.
- Recursion and File I/O Management: The scanner implements recursive directory traversal with conditions for binary file detection and file size handling.
- CI/CD Integration: The GitHub Actions workflows indicate automated builds, linting, tests, and releases, reflecting a robust development lifecycle.

##### Relevant Technologies and Frameworks
- Programming Language: Go.
- CLI Framework: Likely Cobra, based on the README notes.
- Build and Dependency Management: go.mod, Makefile.
- CI/CD Tools: GitHub Actions workflows (build, lint, tests, security, release).
- Logging: The logger package (could be custom or built atop a known logging library).

- Via the main application flow:
User/CLI Input  →  CLI Main (cmd/gopeek) →  Scanner Module.
- Inside Scanner Module, show two internal interactions:
- Finally, highlight that the Scanner Module’s end function produces the comprehensive Markdown document which is then output to a file.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    U("User/CLI Input"):::external
    M("CLI Entry Point (main.go)"):::core
    S("Scanner Module"):::core
    I("Ignore Module"):::core
    L("Logger Module"):::core
    O("Markdown Output"):::output
    C("CI/CD Workflows"):::cicd

    %% Main Application Flow
    U -->|"provides flags"| M
    M -->|"initiates scanning"| S
    M -->|"logs start"| L
    S -->|"filters files"| I
    S -->|"logs status"| L
    S -->|"generates documentation"| O

    %% CI/CD Integration (separate process)
    C -.->|"ensures quality"| M
    C -.->|"ensures quality"| S
    C -.->|"ensures quality"| L

    %% Click Events
    click M "https://github.com/nouuu/gopeek/blob/main/cmd/gopeek/main.go"
    click S "https://github.com/nouuu/gopeek/tree/main/internal/scanner"
    click I "https://github.com/nouuu/gopeek/blob/main/internal/ignore/ignore.go"
    click L "https://github.com/nouuu/gopeek/blob/main/internal/logger/logger.go"
    click C "https://github.com/nouuu/gopeek/tree/main/.github/workflows"

    %% Styles
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#cfc,stroke:#333,stroke-width:2px;
    classDef output fill:#ffc,stroke:#333,stroke-width:2px;
    classDef cicd fill:#fdd,stroke:#333,stroke-width:2px;
```
