# bebiksior/go-vhosts architecture

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

- Interactive diagram: https://gitdiagram.com/bebiksior/go-vhosts
- Repository: https://github.com/bebiksior/go-vhosts

## Overview

##### Main Executable & Entry Point
- Main.go as the entry point of the application where command‐line arguments are parsed and initial configurations are set up.
- This component instantiates the scanning process, incorporating CLI flags (target URL, wordlist, concurrency settings, etc.) from the README’s usage examples.

##### Core Scanner Package (pkg/scanner)
- Break this package into sub-components to capture its responsibilities:
a. Scanner Core (scanner.go): The heart of the scanning process that coordinates different tasks like iterating through wordlists and managing target requests.
b. Requester (requester.go): Manages HTTP requests to the specified target URL(s) with provisions for handling custom headers, User-Agent, proxy settings, etc.
c. Session Management (session.go): Potentially handles the lifecycle of a scanning session, maintaining state across multiple concurrent scans.
e. Utility Functions (utils.go): Provides helper functions and common utilities required by other modules.
f. Internal Hosts (internal_hosts.go): Likely contains definitions or logic regarding how virtual hosts are managed or discovered.

##### Architectural Patterns & Design Principles
- The separation of concerns: scanning, HTTP request handling, and output management are clearly divided.
- A modular design approach, where the “pkg/scanner” holds the logic for scanning independent of the CLI handling in main.go.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["main.go (Entry Point)"]:::entry

    subgraph "Scanner Module"
        B["scanner.go (Scanner Core)"]:::scanner
        C["requester.go (Requester)"]:::scanner
        D["session.go (Session Management)"]:::scanner
        E["output_writer.go (Output Writer)"]:::scanner
        F["utils.go (Utility Functions)"]:::scanner
        G["internal_hosts.go (Internal Hosts)"]:::scanner
    end

    H["HTTP Service"]:::external

    A -->|"ParseCLIArgs"| B
    B -->|"DispatchHTTP"| C
    B -->|"ManageSession"| D
    B -->|"OutputResults"| E
    C -->|"MakeHTTPCall"| H

    click A "https://github.com/bebiksior/go-vhosts/blob/main/main.go"
    click B "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/scanner.go"
    click C "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/requester.go"
    click D "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/session.go"
    click E "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/output_writer.go"
    click F "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/utils.go"
    click G "https://github.com/bebiksior/go-vhosts/blob/main/pkg/scanner/internal_hosts.go"

    classDef entry fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef scanner fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
```
