# ranamauro/tracemynet architecture

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

- Interactive diagram: https://gitdiagram.com/ranamauro/tracemynet
- Repository: https://github.com/ranamauro/tracemynet

## Overview

##### Project type and purpose
- TraceMyNet is a Windows desktop network‐tracing tool built in C#/.NET using WinForms.
- It acts as a TCP proxy (man-in-the-middle), capturing both cleartext and SSL-encrypted traffic, displaying each connection as a node in a tree view.

##### File structure
- Top level
- TraceMyNet.sln – Visual Studio solution
- azure-pipelines.yml – CI pipeline definition
- img/ – UI screenshots
- TraceMyNet/ (project folder)
- Program.cs – application entry point
- TraceMyNet.Designer.cs + TraceMyNet.cs – main UI form
- FindForm, Options, PasswordForm – additional modal dialogs for search, settings, password entry
- MultiSelectTreeView.cs – custom TreeView control for displaying conversations
- BinaryFormatReader.cs & BinaryFormatStructs.cs – helpers for reading/writing packet data
- CapFile.cs – .cap file read/write manager
- RemotingFormatter.cs – serialization helper (for IPC or plugin comms)
- Native.cs – P/Invoke wrappers for low-level socket or Windows API calls
- TraceMyNet.csproj – project configuration

##### Insights from README
- Core functionality centers on intercepting TCP sockets (including SSL) as a proxy.
- Visualizes each conversation in a hierarchical treeview.
- Extensible rendering pipeline via data-parser plugins.

a. Main components
1. UI Layer (WinForms)
2. Proxy Engine (TCP listener + connection manager)
3. SSL Decryption Module
4. CapFile Manager (persistent storage)
5. Plugin System (data parsers)
6. Native Interop Layer (low-level networking)
7. External Network & Local Applications

b. Relationships & interactions
- UI Layer ↔ Proxy Engine:
– UI sends start/stop/config commands
– Proxy Engine pushes parsed data/events back to UI
- Proxy Engine ↔ Native Interop:
– Uses P/Invoke wrappers (Native.cs) to create/manipulate raw sockets, certificates
- Proxy Engine ↔ SSL Module:
– Decrypts/encrypts SSL streams in-flight
- Proxy Engine → CapFile Manager:
– Writes raw packet streams to .cap files
- Proxy Engine → Plugin System:
– Feeds raw or decrypted data into parser interface
- Plugin System → UI Layer:
– Returns structured events/messages to render in TreeView

c. Architectural patterns
- Layered architecture (UI / business logic / data / native)
- Proxy pattern for intercepting and forwarding TCP streams
- Plugin pattern (interface-based extensibility for data parsers)

d. Key technologies
- C#/.NET WinForms – UI and application framework
- P/Invoke (Native.cs) – low-level socket and certificate APIs
- BinaryFormatReader & Structs – custom binary I/O
- RemotingFormatter – optional IPC/serialization for plugins
- Azure Pipelines – automated build/test/deploy

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        P["Program.cs"]:::ui
        MF["TraceMyNet.cs"]:::ui
        MFD["TraceMyNet.Designer.cs"]:::ui
        FF["FindForm.cs"]:::ui
        FFD["FindForm.Designer.cs"]:::ui
        OF["Options.cs"]:::ui
        OFD["Options.Designer.cs"]:::ui
        PF["PasswordForm.cs"]:::ui
        PFD["PasswordForm.Designer.cs"]:::ui
        MSTV["MultiSelectTreeView.cs"]:::ui
        AI["AssemblyInfo.cs"]:::ui
    end

    %% Core Engine
    subgraph "Core Engine"
        PE["Proxy Engine"]:::core
        SSL["SSL Decryption Module"]:::core
    end

    %% Storage
    subgraph "Storage"
        Cap["CapFile Manager"]:::storage
    end

    %% Plugin System
    subgraph "Plugin System"
        IData["IDataParser Interface"]:::plugin
        PFmt["RemotingFormatter"]:::plugin
    end

    %% Binary I/O Helpers
    subgraph "Binary I/O"
        BFR["BinaryFormatReader.cs"]:::core
        BFS["BinaryFormatStructs.cs"]:::core
    end

    %% Native Interop
    subgraph "Native Interop"
        NI["Native.cs"]:::external
    end

    %% External Entities and Config
    subgraph "External & Config"
        LA["Local Applications"]:::external
        RS["Remote Servers"]:::external
        IMG["img/ (Screenshots)"]:::external
        SLN["TraceMyNet.sln"]:::external
        CSP["azure-pipelines.yml"]:::external
        CSP2["TraceMyNet.csproj"]:::external
    end

    %% Relationships
    LA -->|"sends TCP traffic"| PE
    PE -->|"forwards traffic"| RS
    PE -->|"writes packet streams"| Cap
    PE -->|"decrypts SSL streams"| SSL
    PE -->|"uses P/Invoke wrappers"| NI
    PE -->|"feeds data into"| IData
    IData -->|"returns parsed events"| MSTV
    PE -->|"uses binary I/O"| BFR
    PE -->|"uses binary structs"| BFS
    P -->|"initializes"| PE
    OF -->|"sends configuration"| PE
    PE -->|"pushes UI events"| MSTV

    %% Click Events
    click P "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/Program.cs"
    click MF "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/TraceMyNet.cs"
    click MFD "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/TraceMyNet.Designer.cs"
    click FF "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/FindForm.cs"
    click FFD "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/FindForm.Designer.cs"
    click OF "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/Options.cs"
    click OFD "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/Options.Designer.cs"
    click PF "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/PasswordForm.cs"
    click PFD "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/PasswordForm.Designer.cs"
    click MSTV "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/MultiSelectTreeView.cs"
    click AI "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/Properties/AssemblyInfo.cs"
    click Cap "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/CapFile.cs"
    click NI "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/Native.cs"
    click BFR "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/BinaryFormatReader.cs"
    click BFS "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/BinaryFormatStructs.cs"
    click PFmt "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/RemotingFormatter.cs"
    click CSP2 "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet/TraceMyNet.csproj"
    click SLN "https://github.com/ranamauro/tracemynet/blob/master/TraceMyNet.sln"
    click CSP "https://github.com/ranamauro/tracemynet/blob/master/azure-pipelines.yml"
    click IMG "https://github.com/ranamauro/tracemynet/tree/master/img/"

    %% Styles
    classDef ui fill:#cde4fc,stroke:#0366d6
    classDef core fill:#d4f4dd,stroke:#22863a
    classDef storage fill:#fff5b1,stroke:#dbab09
    classDef plugin fill:#ffe8d6,stroke:#d15704
    classDef external fill:#e1e4e8,stroke:#586069
```
