|
| 1 | +# Torrust Tracker Package Architecture |
| 2 | + |
| 3 | +- [Package Conventions](#package-conventions) |
| 4 | +- [Package Catalog](#package-catalog) |
| 5 | +- [Architectural Philosophy](#architectural-philosophy) |
| 6 | +- [Protocol Implementation Details](#protocol-implementation-details) |
| 7 | +- [Architectural Philosophy](#architectural-philosophy) |
| 8 | + |
| 9 | +```output |
| 10 | +packages/ |
| 11 | +├── axum-health-check-api-server |
| 12 | +├── axum-http-tracker-server |
| 13 | +├── axum-rest-tracker-api-server |
| 14 | +├── axum-server |
| 15 | +├── clock |
| 16 | +├── configuration |
| 17 | +├── http-protocol |
| 18 | +├── http-tracker-core |
| 19 | +├── located-error |
| 20 | +├── primitives |
| 21 | +├── rest-tracker-api-client |
| 22 | +├── rest-tracker-api-core |
| 23 | +├── server-lib |
| 24 | +├── test-helpers |
| 25 | +├── torrent-repository |
| 26 | +├── tracker-client |
| 27 | +├── tracker-core |
| 28 | +├── udp-protocol |
| 29 | +├── udp-tracker-core |
| 30 | +└── udp-tracker-server |
| 31 | +``` |
| 32 | + |
| 33 | +```output |
| 34 | +console/ |
| 35 | +└── tracker-client # Client for interacting with trackers |
| 36 | +``` |
| 37 | + |
| 38 | +```output |
| 39 | +contrib/ |
| 40 | +└── bencode # Community-contributed Bencode utilities |
| 41 | +``` |
| 42 | + |
| 43 | +## Package Conventions |
| 44 | + |
| 45 | +| Prefix | Responsibility | Dependencies | |
| 46 | +|-----------------|-----------------------------------------|---------------------------| |
| 47 | +| `axum-*` | HTTP server components using Axum | Axum framework | |
| 48 | +| `*-server` | Server implementations | Corresponding *-core | |
| 49 | +| `*-core` | Domain logic & business rules | Protocol implementations | |
| 50 | +| `*-protocol` | BitTorrent protocol implementations | BitTorrent protocol | |
| 51 | +| `udp-*` | UDP Protocol-specific implementations | Tracker core | |
| 52 | +| `http-*` | HTTP Protocol-specific implementations | Tracker core | |
| 53 | + |
| 54 | +Key Architectural Principles: |
| 55 | + |
| 56 | +1. **Separation of Concerns**: Servers contain only network I/O logic. |
| 57 | +2. **Protocol Compliance**: `*-protocol` packages strictly implement BEP specifications. |
| 58 | +3. **Extensibility**: Core logic is framework-agnostic for easy protocol additions. |
| 59 | + |
| 60 | +## Package Catalog |
| 61 | + |
| 62 | +| Package | Description | Key Responsibilities | |
| 63 | +|---------|-------------|----------------------| |
| 64 | +| **axum-*** | | | |
| 65 | +| `axum-server` | Base Axum HTTP server infrastructure | HTTP server lifecycle management | |
| 66 | +| `axum-http-tracker-server` | BitTorrent HTTP tracker (BEP 3/23) | Handle announce/scrape requests | |
| 67 | +| `axum-rest-tracker-api-server` | Management REST API | Tracker configuration & monitoring | |
| 68 | +| `axum-health-check-api-server` | Health monitoring endpoint | System health reporting | |
| 69 | +| **Core Components** | | | |
| 70 | +| `http-tracker-core` | HTTP-specific implementation | Request validation, Response formatting | |
| 71 | +| `udp-tracker-core` | UDP-specific implementation | Connectionless request handling | |
| 72 | +| `tracker-core` | Central tracker logic | Peer management | |
| 73 | +| **Protocols** | | | |
| 74 | +| `http-protocol` | HTTP tracker protocol (BEP 3/23) | Announce/scrape request parsing | |
| 75 | +| `udp-protocol` | UDP tracker protocol (BEP 15) | UDP message framing/parsing | |
| 76 | +| **Domain** | | | |
| 77 | +| `torrent-repository` | Torrent metadata storage | InfoHash management, Peer coordination | |
| 78 | +| `configuration` | Runtime configuration | Config file parsing, Environment variables | |
| 79 | +| `primitives` | Domain-specific types | InfoHash, PeerId, Byte handling | |
| 80 | +| **Utilities** | | | |
| 81 | +| `clock` | Time abstraction | Mockable time source for testing | |
| 82 | +| `located-error` | Diagnostic errors | Error tracing with source locations | |
| 83 | +| `test-helpers` | Testing utilities | Mock servers, Test data generation | |
| 84 | +| **Client Tools** | | | |
| 85 | +| `tracker-client` | CLI client | Tracker interaction/testing | |
| 86 | +| `rest-tracker-api-client` | API client library | REST API integration | |
| 87 | + |
| 88 | +## Protocol Implementation Details |
| 89 | + |
| 90 | +### HTTP Tracker (BEP 3/23) |
| 91 | + |
| 92 | +- `http-protocol` implements: |
| 93 | + - URL parameter parsing |
| 94 | + - Response bencoding |
| 95 | + - Error code mapping |
| 96 | + - Compact peer formatting |
| 97 | + |
| 98 | +### UDP Tracker (BEP 15) |
| 99 | + |
| 100 | +- `udp-protocol` handles: |
| 101 | + - Connection ID management |
| 102 | + - Message framing (32-bit big-endian) |
| 103 | + - Transaction ID tracking |
| 104 | + - Error response codes |
| 105 | + |
| 106 | +## Architectural Philosophy |
| 107 | + |
| 108 | +1. **Testability**: Core packages have minimal dependencies for easy unit testing |
| 109 | +2. **Observability**: Health checks and metrics built into server packages |
| 110 | +3. **Modularity**: Protocol implementations decoupled from transport layers |
| 111 | +4. **Extensibility**: New protocols can be added without modifying core logic |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +> Diagram shows clean separation between network I/O (servers), protocol handling, and core tracker logic |
0 commit comments