# timfadmv/netcat architecture

> Architecture diagram of the GitHub repository timfadmv/netcat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/timfadmv/netcat
- Repository: https://github.com/timfadmv/netcat

## Overview

Netcat Web provides a browser UI and JSON API for TCP connect, local TCP listen, port scanning, sending messages, and closing connections. The main workflow is browser action → Flask route → NetcatCore operation → TCP socket/result → browser display. Connections are tracked in process memory. The shown excerpts establish the principal calls; README documents the broader feature set, while unsampled templates and core sections limit detail on rendering and internal helper relationships.

Main entry points: [`netcat_core.py`](https://github.com/timfadmv/netcat/blob/main/netcat_core.py) (NetcatCore), [`static/script.js`](https://github.com/timfadmv/netcat/blob/main/static/script.js) (Web UI), [`app.py`](https://github.com/timfadmv/netcat/blob/main/app.py) (Flask app), [`templates`](https://github.com/timfadmv/netcat/tree/main/templates) (Interface page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Browser interface"]
  node_browser["Web UI<br/>[script.js]"]
  node_page["Interface page"]
end

subgraph group_web["Web API"]
  node_flask["Flask app<br/>[app.py]"]
end

subgraph group_tcp["TCP operations"]
  node_core["NetcatCore<br/>[netcat_core.py]"]
  node_connect["TCP connect<br/>[netcat_core.py]"]
  node_listen["TCP listen<br/>[netcat_core.py]"]
  node_scan["Port scanning<br/>[netcat_core.py]"]
  node_sendclose["Send and close<br/>[netcat_core.py]"]
end

subgraph group_state["Connection state"]
  node_sessions[("Active connections<br/>[netcat_core.py]")]
end

node_operator(("User"))
node_remote(("Remote TCP host"))
node_localpeer(("Local TCP peer"))

node_operator -->|"uses"| node_browser
node_browser -.->|"loads"| node_page
node_browser -->|"requests API"| node_flask
node_flask -->|"returns results"| node_browser
node_flask -->|"dispatches operations"| node_core
node_core -->|"provides"| node_connect
node_core -->|"provides"| node_listen
node_core -->|"provides"| node_scan
node_core -->|"provides"| node_sendclose
node_connect -->|"opens TCP"| node_remote
node_listen -->|"accepts TCP"| node_localpeer
node_scan -->|"probes ports"| node_remote
node_connect -->|"stores socket"| node_sessions
node_listen -->|"stores socket"| node_sessions
node_sendclose -->|"uses and removes"| node_sessions
node_browser -.->|"sends messages"| node_remote

click node_browser "https://github.com/timfadmv/netcat/blob/main/static/script.js"
click node_page "https://github.com/timfadmv/netcat/tree/main/templates"
click node_flask "https://github.com/timfadmv/netcat/blob/main/app.py"
click node_core "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"
click node_connect "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"
click node_listen "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"
click node_scan "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"
click node_sendclose "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"
click node_sessions "https://github.com/timfadmv/netcat/blob/main/netcat_core.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_page,node_operator toneBlue
class node_flask toneAmber
class node_core,node_connect,node_listen,node_scan,node_sendclose toneMint
class node_sessions toneRose
class node_remote,node_localpeer toneIndigo
```

## Components

### Browser interface

- [Web UI](https://github.com/timfadmv/netcat/blob/main/static/script.js): `static/script.js`
- [Interface page](https://github.com/timfadmv/netcat/tree/main/templates): `templates`

### Web API

- [Flask app](https://github.com/timfadmv/netcat/blob/main/app.py): `app.py`

### TCP operations

- [NetcatCore](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`
- [TCP connect](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`
- [TCP listen](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`
- [Port scanning](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`
- [Send and close](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`

### Connection state

- [Active connections](https://github.com/timfadmv/netcat/blob/main/netcat_core.py): `netcat_core.py`

### Other components

- **User**
- **Remote TCP host**
- **Local TCP peer**

## Connections

- User → Web UI: uses (evidence: `README.md`)
- Web UI → Interface page: loads
- Web UI → Flask app: requests API (evidence: `static/script.js`)
- Flask app → Web UI: returns results (evidence: `app.py`)
- Flask app → NetcatCore: dispatches operations (evidence: `app.py`)
- NetcatCore → TCP connect: provides (evidence: `netcat_core.py`)
- NetcatCore → TCP listen: provides (evidence: `netcat_core.py`)
- NetcatCore → Port scanning: provides (evidence: `netcat_core.py`)
- NetcatCore → Send and close: provides (evidence: `netcat_core.py`)
- TCP connect → Remote TCP host: opens TCP (evidence: `netcat_core.py`)
- TCP listen → Local TCP peer: accepts TCP (evidence: `netcat_core.py`)
- Port scanning → Remote TCP host: probes ports (evidence: `README.md`)
- TCP connect → Active connections: stores socket (evidence: `netcat_core.py`)
- TCP listen → Active connections: stores socket (evidence: `netcat_core.py`)
- Send and close → Active connections: uses and removes (evidence: `netcat_core.py`)
- Web UI → Remote TCP host: sends messages
