# sergiye/ratiomaster architecture

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

- Interactive diagram: https://gitdiagram.com/sergiye/ratiomaster
- Repository: https://github.com/sergiye/ratiomaster

## Overview

RatioMaster is a standalone Windows application that simulates BitTorrent tracker activity and reports fabricated upload/download counters; it does not transfer torrent files through a BitTorrent client. The main workflow is to configure a torrent and client profile in the UI, then have an RM session generate tracker requests, communicate with trackers, and update displayed counters. The graph includes torrent parsing, client emulation, peer/network support, and socket infrastructure. Some subsystem links rely on the SOURCE INDEX or README because their implementation excerpts were not provided.

Main entry points: [`RatioMaster/RM.cs`](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RM.cs) (Session controller), [`RatioMaster/MainForm.cs`](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/MainForm.cs) (Session UI), [`RatioMaster/TorrentClientFactory.cs`](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TorrentClientFactory.cs) (Client profiles), [`RatioMaster/BitTorrent/Torrent.cs`](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/Torrent.cs) (Torrent metadata)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_program["Application entry<br/>[Program.cs]"]
  node_mainform["Session UI<br/>[MainForm.cs]"]
  node_prompt["Input prompts<br/>[Prompt.cs]"]
  node_session_collection["Session collection<br/>[RMCollection.cs]"]
end

subgraph group_session["Announce simulation"]
  node_session_manager["Session controller<br/>[RM.cs]"]
  node_tracker_response["Tracker response<br/>[TrackerResponse.cs]"]
  node_peer_list["Peer list<br/>[PeerList.cs]"]
  node_peer["Peer record<br/>[Peer.cs]"]
  node_functions["Shared utilities<br/>[Functions.cs]"]
  node_memory_reader["Client memory reader"]
end

subgraph group_torrent["Torrent and profiles"]
  node_client_profiles["Client profiles"]
  node_client_profile_data["Client profile data<br/>[TorrentClient.cs]"]
  node_random_ids["Identity generator"]
  node_torrent_metadata["Torrent metadata<br/>[Torrent.cs]"]
  node_bencode["Bencode values<br/>[BEncode.cs]"]
  node_value_dictionary["Value dictionary<br/>[ValueDictionary.cs]"]
end

subgraph group_network["Networking"]
  node_socket_facade["Socket facade<br/>[SocketEx.cs]"]
  node_socket_base["Socket operations<br/>[SocketBase.cs]"]
  node_async_results["Async results<br/>[AsyncResultBase.cs]"]
  node_proxy_sockets["Proxy transports"]
  node_trace["Network tracing<br/>[NSTrace.cs]"]
  node_trace_options["Trace configuration<br/>[NSTraceOptions.cs]"]
  node_trace_listeners["Trace listeners"]
end

node_user(("User"))
node_tracker(("BitTorrent trackers"))

node_user -->|"launches"| node_program
node_program -->|"opens"| node_mainform
node_user -->|"configures"| node_mainform
node_mainform -->|"creates sessions"| node_session_manager
node_mainform -->|"stores sessions"| node_session_collection
node_mainform -->|"opens prompts"| node_prompt
node_session_manager -->|"loads torrent"| node_torrent_metadata
node_session_manager -->|"selects profile"| node_client_profiles
node_client_profiles -->|"builds profile"| node_client_profile_data
node_client_profiles -->|"generates identifiers"| node_random_ids
node_torrent_metadata -->|"parses and encodes"| node_bencode
node_torrent_metadata -->|"uses metadata values"| node_value_dictionary
node_bencode -->|"creates dictionaries"| node_value_dictionary
node_session_manager -->|"parses replies"| node_tracker_response
node_session_manager -->|"sends announces"| node_tracker
node_tracker -->|"returns responses"| node_session_manager
node_session_manager -->|"uses peer list"| node_peer_list
node_peer_list -->|"stores peers"| node_peer
node_session_manager -->|"uses sockets"| node_socket_facade
node_socket_facade -->|"delegates operations"| node_socket_base
node_socket_base -->|"supports async work"| node_async_results
node_session_manager -->|"selects proxy transport"| node_proxy_sockets
node_trace -->|"uses options"| node_trace_options
node_trace -->|"dispatches traces"| node_trace_listeners
node_session_manager -->|"uses utilities"| node_functions
node_session_manager -->|"checks client process"| node_memory_reader

click node_program "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Program.cs"
click node_mainform "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/MainForm.cs"
click node_prompt "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Prompt.cs"
click node_session_manager "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RM.cs"
click node_session_collection "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RMCollection.cs"
click node_tracker_response "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TrackerResponse.cs"
click node_peer_list "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/PeerList.cs"
click node_peer "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Peer.cs"
click node_client_profiles "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TorrentClientFactory.cs"
click node_client_profile_data "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TorrentClient.cs"
click node_random_ids "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RandomStringGenerator.cs"
click node_torrent_metadata "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/Torrent.cs"
click node_bencode "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/BEncode.cs"
click node_value_dictionary "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/ValueDictionary.cs"
click node_socket_facade "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/SocketEx.cs"
click node_socket_base "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/SocketBase.cs"
click node_async_results "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/AsyncResultBase.cs"
click node_proxy_sockets "https://github.com/sergiye/ratiomaster/tree/master/RatioMaster/BytesRoads"
click node_trace "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTrace.cs"
click node_trace_options "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTraceOptions.cs"
click node_trace_listeners "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTraceListeners.cs"
click node_functions "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Functions.cs"
click node_memory_reader "https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/ProcessMemoryReader.cs"

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_program,node_mainform,node_prompt,node_session_collection,node_user toneBlue
class node_session_manager,node_tracker_response,node_peer_list,node_peer,node_functions,node_memory_reader toneAmber
class node_client_profiles,node_client_profile_data,node_random_ids,node_torrent_metadata,node_bencode,node_value_dictionary toneMint
class node_socket_facade,node_socket_base,node_async_results,node_proxy_sockets,node_trace,node_trace_options,node_trace_listeners toneRose
class node_tracker toneIndigo
```

## Components

### User interface

- [Application entry](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Program.cs): `RatioMaster/Program.cs`
- [Session UI](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/MainForm.cs): `RatioMaster/MainForm.cs`
- [Input prompts](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Prompt.cs): `RatioMaster/Prompt.cs`
- [Session collection](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RMCollection.cs): `RatioMaster/RMCollection.cs`

### Announce simulation

- [Session controller](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RM.cs): `RatioMaster/RM.cs`
- [Tracker response](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TrackerResponse.cs): `RatioMaster/TrackerResponse.cs`
- [Peer list](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/PeerList.cs): `RatioMaster/PeerList.cs`
- [Peer record](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Peer.cs): `RatioMaster/Peer.cs`
- [Shared utilities](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/Functions.cs): `RatioMaster/Functions.cs`
- [Client memory reader](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/ProcessMemoryReader.cs): `RatioMaster/ProcessMemoryReader.cs`

### Torrent and profiles

- [Client profiles](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TorrentClientFactory.cs): `RatioMaster/TorrentClientFactory.cs`
- [Client profile data](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/TorrentClient.cs): `RatioMaster/TorrentClient.cs`
- [Identity generator](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/RandomStringGenerator.cs): `RatioMaster/RandomStringGenerator.cs`
- [Torrent metadata](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/Torrent.cs): `RatioMaster/BitTorrent/Torrent.cs`
- [Bencode values](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/BEncode.cs): `RatioMaster/BitTorrent/BEncode.cs`
- [Value dictionary](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BitTorrent/ValueDictionary.cs): `RatioMaster/BitTorrent/ValueDictionary.cs`

### Networking

- [Socket facade](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/SocketEx.cs): `RatioMaster/BytesRoads/SocketEx.cs`
- [Socket operations](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/SocketBase.cs): `RatioMaster/BytesRoads/SocketBase.cs`
- [Async results](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/AsyncResultBase.cs): `RatioMaster/BytesRoads/AsyncResultBase.cs`
- [Proxy transports](https://github.com/sergiye/ratiomaster/tree/master/RatioMaster/BytesRoads): `RatioMaster/BytesRoads`
- [Network tracing](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTrace.cs): `RatioMaster/BytesRoads/NSTrace.cs`
- [Trace configuration](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTraceOptions.cs): `RatioMaster/BytesRoads/NSTraceOptions.cs`
- [Trace listeners](https://github.com/sergiye/ratiomaster/blob/master/RatioMaster/BytesRoads/NSTraceListeners.cs): `RatioMaster/BytesRoads/NSTraceListeners.cs`

### Other components

- **User**
- **BitTorrent trackers**

## Connections

- User → Application entry: launches (evidence: `RatioMaster/Program.cs`)
- Application entry → Session UI: opens (evidence: `RatioMaster/Program.cs`)
- User → Session UI: configures (evidence: `RatioMaster/MainForm.cs`)
- Session UI → Session controller: creates sessions (evidence: `RatioMaster/MainForm.cs`)
- Session UI → Session collection: stores sessions (evidence: `RatioMaster/MainForm.cs`)
- Session UI → Input prompts: opens prompts (evidence: `RatioMaster/MainForm.cs`)
- Session controller → Torrent metadata: loads torrent (evidence: `RatioMaster/RM.cs`)
- Session controller → Client profiles: selects profile (evidence: `RatioMaster/RM.cs`)
- Client profiles → Client profile data: builds profile (evidence: `RatioMaster/TorrentClientFactory.cs`)
- Client profiles → Identity generator: generates identifiers (evidence: `RatioMaster/TorrentClientFactory.cs`)
- Torrent metadata → Bencode values: parses and encodes (evidence: `RatioMaster/BitTorrent/Torrent.cs`)
- Torrent metadata → Value dictionary: uses metadata values (evidence: `RatioMaster/BitTorrent/Torrent.cs`)
- Bencode values → Value dictionary: creates dictionaries (evidence: `RatioMaster/BitTorrent/BEncode.cs`)
- Session controller → Tracker response: parses replies (evidence: `RatioMaster/RM.cs`)
- Session controller → BitTorrent trackers: sends announces (evidence: `RatioMaster/RM.cs`)
- BitTorrent trackers → Session controller: returns responses (evidence: `RatioMaster/RM.cs`)
- Session controller → Peer list: uses peer list (evidence: `RatioMaster/RM.cs`)
- Peer list → Peer record: stores peers (evidence: `RatioMaster/PeerList.cs`)
- Session controller → Socket facade: uses sockets (evidence: `RatioMaster/RM.cs`)
- Socket facade → Socket operations: delegates operations (evidence: `RatioMaster/BytesRoads/SocketEx.cs`)
- Socket operations → Async results: supports async work (evidence: `RatioMaster/BytesRoads/SocketBase.cs`)
- Session controller → Proxy transports: selects proxy transport (evidence: `RatioMaster/RM.cs`)
- Network tracing → Trace configuration: uses options (evidence: `RatioMaster/BytesRoads/NSTrace.cs`)
- Network tracing → Trace listeners: dispatches traces (evidence: `RatioMaster/BytesRoads/NSTrace.cs`)
- Session controller → Shared utilities: uses utilities (evidence: `RatioMaster/RM.cs`)
- Session controller → Client memory reader: checks client process (evidence: `RatioMaster/RM.cs`)
