# nopals-sub/dir-scan architecture

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

- Interactive diagram: https://gitdiagram.com/nopals-sub/dir-scan
- Repository: https://github.com/nopals-sub/dir-scan

## Overview

##### Main Components
- CLI/Input Handler: The entry point where the user provides the domain URL and optional flags (e.g., resume scan).
- URL/Protocol Validator: A component that confirms the URL format and adds "http://" if needed.
- Recursive Scanner Engine: The core component that implements the recursive directory and file scanning.
- Duplicate Filtering Module: A layer/functionality that ensures duplicates are filtered out before being output.
- Output Handler: The mechanism to display or save the results (including support for stopping/resuming the scan).

##### Out the Relationships and Interactions
- The user invokes the tool from the command line providing a domain URL.
- The URL/Protocol Validator processes the input, ensuring a valid HTTP/HTTPS URL.
- Next, the Recursive Scanner Engine uses the validated URL to start scanning directories and files recursively.
- Within this scanning process, the Duplicate Filtering module is used to check and eliminate duplicates.
- Finally, the Output Handler manages how the results are displayed to or stored for the user.

##### Architectural Patterns and Principles
- Modularity & Separation of Concerns: Even though implemented in a single file, conceptually separate the program into distinct responsibilities (input, validation, scanning, filtering, and output).
- Recursive Processing: Emphasize the recursive nature of the directory scan and the handling of multiple protocols.
- Error Handling & Interruption Management: The design should allow for resume or stop functionality if the scan is interrupted.

##### Specify the Technologies and Frameworks
- Go (Golang) is the core language, so note that the architecture leverages Go's concurrency and even possibly its context cancellation features for interruptible scanning.
- While no external libraries are specified, consider the built-in Go libraries (like net/http, os, etc.) which support these functionalities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U("User Command"):::external
    CLI("CLI/Input Handler"):::cli
    VAL("URL/Protocol Validator"):::validator
    SCN("Recursive Scanner Engine"):::scanner
    DUP("Duplicate Filtering Module"):::duplicate
    OUT("Output Handler"):::output

    U -->|"submits"| CLI
    CLI -->|"validates"| VAL
    VAL -->|"invokesScanning"| SCN
    SCN -->|"filtersDuplicates"| DUP
    DUP -->|"deliversOutput"| OUT

    click CLI "https://github.com/nopals-sub/dir-scan/blob/main/dir.go"
    click VAL "https://github.com/nopals-sub/dir-scan/blob/main/dir.go"
    click SCN "https://github.com/nopals-sub/dir-scan/blob/main/dir.go"
    click DUP "https://github.com/nopals-sub/dir-scan/blob/main/dir.go"
    click OUT "https://github.com/nopals-sub/dir-scan/blob/main/dir.go"

    classDef external fill:#E8F6FF,stroke:#007ACC,stroke-width:2px
    classDef cli fill:#FFD700,stroke:#DAA520,stroke-width:2px
    classDef validator fill:#ADFF2F,stroke:#32CD32,stroke-width:2px
    classDef scanner fill:#87CEFA,stroke:#4682B4,stroke-width:2px
    classDef duplicate fill:#FFB6C1,stroke:#FF1493,stroke-width:2px
    classDef output fill:#90EE90,stroke:#32CD32,stroke-width:2px
```
