# tekshteint/pmap architecture

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

- Interactive diagram: https://gitdiagram.com/tekshteint/pmap
- Repository: https://github.com/tekshteint/pmap

## Overview

##### Project type and purpose
- PMAP is an open-source, command-line network scanning tool implemented in PowerShell.
- It provides a multithreaded alternative to Nmap for environments where PowerShell is available but you lack elevated privileges or external binaries.

##### File structure
- Top-level scripts and module files:
- pmap.ps1 – the entry-point script that users invoke from the CLI.
- pmap.psm1 – the core PowerShell module containing the scanning functions.
- pmap.psd1 – the module manifest that declares metadata, exported functions, versioning.
- demos/ – example output and animated demo assets.
- README.md, LICENSE, .gitignore, .gitattributes – documentation and project metadata.

##### README for additional insights
- Core features: multithreading, flexible target specification, quick vs full scans, custom port ranges, verbose output, host discovery.
- No external dependencies; runs on PowerShell 5.0+.
- Flags and switches drive behavior—this implies a CLI parser component feeding into the scanning engine.

##### Main components and interactions
a. CLI Interface (pmap.ps1)
– Parses command-line parameters (targets, port ranges, flags).
– Validates inputs and invokes the module’s public functions.
b. Parameter/Config Manager
– Normalizes targets (single IP, comma list, CIDR).
– Determines port lists based on quick/full/custom flags.
c. Scanning Engine (pmap.psm1)
– Core function that receives a list of targets and ports.
– Delegates work to a thread manager for concurrency.
d. Thread Manager
– Spawns PowerShell runspaces or jobs to parallelize port checks.
– Balances workload across threads.
e. Network Connector
– Performs individual TCP connection attempts (socket open/close).
– Reports status (open/closed) back to the engine.
f. Output Formatter
– Aggregates results from all threads.
– Formats console output (table, verbose logs, discovery-only).
– Handles redirection to files if requested.
g. Module Manifest (pmap.psd1)
– Ensures proper export of public functions for import by the entry script.

##### Architectural patterns and design principles
- Modular separation: CLI parsing separated from scanning logic and threading.
- Concurrency via a thread (runspace/job) pool.
- Single-responsibility for each component (parsing, scanning, threading, output).
- No external dependencies ensures portability.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Synchronous Operations"
        CLI["CLI Parser"]:::cli
        Config["Config Manager"]:::cli
    end

    subgraph "Core Scanning Logic"
        Engine["Scanning Engine"]:::core
        Threads["Thread Manager"]:::core
    end

    subgraph "I/O Operations"
        Net["Network Connector"]:::io
        Output["Output Formatter"]:::io
    end

    Manifest["Module Manifest"]:::meta
    Demos["Demo Assets"]:::meta
    Docs["Project Documentation & Metadata"]:::meta

    CLI -->|"parameters"| Config
    Config -->|"PortList, Targets"| Engine
    Engine -->|"Tasks"| Threads
    Threads -->|"Connection Request"| Net
    Net -->|"ScanResult"| Threads
    Threads -->|"Results"| Engine
    Engine -->|"Results"| Output

    click CLI "https://github.com/tekshteint/pmap/blob/main/pmap.ps1"
    click Config "https://github.com/tekshteint/pmap/blob/main/pmap.psm1"
    click Engine "https://github.com/tekshteint/pmap/blob/main/pmap.psm1"
    click Threads "https://github.com/tekshteint/pmap/blob/main/pmap.psm1"
    click Net "https://github.com/tekshteint/pmap/blob/main/pmap.psm1"
    click Output "https://github.com/tekshteint/pmap/blob/main/pmap.psm1"
    click Manifest "https://github.com/tekshteint/pmap/blob/main/pmap.psd1"
    click Demos "https://github.com/tekshteint/pmap/tree/main/demos/"
    click Docs "https://github.com/tekshteint/pmap/blob/main/README.md"

    classDef cli fill:#D0E8FF,stroke:#000,stroke-width:1px
    classDef core fill:#D0F2D8,stroke:#000,stroke-width:1px
    classDef io fill:#FFE6B3,stroke:#000,stroke-width:1px
    classDef meta fill:#E0E0E0,stroke:#000,stroke-width:1px
```
