| semantic-links |
|
|---|
- Package Conventions
- Package Catalog
- Architectural Philosophy
- Design Decisions
- Protocol Implementation Details
packages/
├── axum-health-check-api-server
├── axum-http-server
├── axum-rest-api-server
├── axum-server
├── configuration
├── e2e-tools
├── events
├── http-protocol
├── http-core
├── persistence-benchmark
├── primitives
├── rest-api-client
├── rest-api-core
├── swarm-coordination-registry
├── test-helpers
├── torrent-repository-benchmarking
├── tracker-client
├── tracker-core
├── udp-protocol
├── udp-core
└── udp-server
console/
└── tracker-client # Client for interacting with trackers
contrib/
└── dev-tools # Developer tooling (git hooks, container scripts, etc.)
| Prefix | Responsibility | Dependencies |
|---|---|---|
axum-* |
HTTP server components using Axum | Axum framework |
*-server |
Server implementations | Corresponding *-core |
*-core |
Domain logic & business rules | Protocol implementations |
*-protocol |
BitTorrent protocol implementations | BitTorrent protocol |
udp-* |
UDP Protocol-specific implementations | Tracker core |
http-* |
HTTP Protocol-specific implementations | Tracker core |
Key Architectural Principles:
- Separation of Concerns: Servers contain only network I/O logic.
- Protocol Compliance:
*-protocolpackages strictly implement BEP specifications. - Extensibility: Core logic is framework-agnostic for easy protocol additions.
Dependencies between layers are enforced programmatically via
cargo deny check bans — configured in
deny.toml at the workspace root.
The layered architecture (servers → core → protocol → domain) prevents
coupling between concerns. Without automated enforcement, a misplaced
dependency (e.g., a core crate importing a server crate) compiles and
passes CI silently. cargo deny prohibits these edges at the lockfile
level, catching violations in pre-commit hooks and CI before merge.
| Edge | Description | Current violations |
|---|---|---|
core -> server |
Core must not depend on delivery-layer packages | rest-api-core -> udp-server |
tracker-core -> core |
Tracker core must not depend on its protocol-specific wrappers | None |
tracker-core -> protocol |
Tracker core must not depend on protocol parsing crates | None |
tracker-core -> server |
Tracker core must not depend on server crates | None |
protocol -> core |
Protocol crates must not depend on core logic | None |
protocol -> tracker-core |
Protocol crates must not depend on tracker core | None |
protocol -> server |
Protocol crates must not depend on server crates | None |
domain -> server |
Domain/shared packages must not depend on server crates | None |
cargo deny uses a bans with wrappers mechanism. For each server-layer
or protocol crate that should be restricted, deny.toml lists:
- The banned crate (the server/protocol package).
- A wrappers list — the set of packages that are legitimately allowed to depend on that crate directly. Any direct dependency outside this list, and any transitive dependency from a non-server package, is rejected.
For example, torrust-tracker-udp-server can only be depended on by:
torrust-tracker(root binary)torrust-tracker-axum-rest-api-servertorrust-tracker-axum-health-check-api-servertorrust-tracker-rest-api-core(known violation — see below)
A core package like torrust-tracker-http-core adding udp-server as a
dependency would be immediately rejected by cargo deny check bans.
torrust-tracker-rest-api-coredepends ontorrust-tracker-udp-server— a known violation tracked separately. Until it is fixed, the wrapper list forudp-serverincludesrest-api-core.
When adding a new dependency to a workspace package, run:
cargo deny check bansIf it fails, either:
- The new dependency is on a restricted crate — check whether your package belongs in that crate's wrappers list.
- The dependency is legitimate — add your package to the appropriate
wrapper entry in
deny.toml.
Adding a package to a wrapper list should be a deliberate architectural
decision, reviewed with the same care as any layer-crossing dependency.
See deny.toml for the complete configuration.
- Persistence trait boundaries and the aggregate supertrait choice: docs/adrs/20260429000000_keep_database_as_aggregate_supertrait.md
| Package | Description | Key Responsibilities |
|---|---|---|
| axum-* | ||
axum-server |
Base Axum HTTP server infrastructure | HTTP server lifecycle management |
axum-http-server |
BitTorrent HTTP tracker (BEP 3/23) | Handle announce/scrape requests |
axum-rest-api-server |
Management REST API | Tracker configuration & monitoring |
axum-health-check-api-server |
Health monitoring endpoint | System health reporting |
| Core Components | ||
http-core |
HTTP-specific implementation | Request validation, Response formatting |
udp-core |
UDP-specific implementation | Connectionless request handling |
tracker-core |
Central tracker logic | Peer management |
| Protocols | ||
http-protocol |
HTTP tracker protocol (BEP 3/23) | Announce/scrape request parsing |
udp-protocol |
UDP tracker protocol (BEP 15) | UDP message framing/parsing |
| Domain | ||
swarm-coordination-registry |
Peer swarm registry | Torrent/peer coordination |
configuration |
Runtime configuration | Config file parsing, Environment variables |
primitives |
Domain-specific types | PeerId, Peer, SwarmMetadata |
events |
Async event bus | Inter-package communication |
| Utilities | ||
test-helpers |
Testing utilities | Mock servers, Test data generation |
| Client Tools | ||
tracker-client (packages/) |
Tracker client library | Generic tracker client library |
rest-api-client |
API client library | REST API integration |
| Benchmarking | ||
torrent-repository-benchmarking |
Torrent storage benchmarks | Criterion benchmarks |
persistence-benchmark |
Persistence layer benchmarks | SQLite/MySQL/PostgreSQL benchmarks |
Packages that have been extracted to their own standalone repositories.
| Package | Standalone Repository | Crate Name | Description |
|---|---|---|---|
clock |
torrust/torrust-clock | torrust-clock |
Deterministic clock abstraction |
located-error |
torrust/torrust-located-error | torrust-located-error |
Diagnostic errors with source locations |
metrics |
torrust/torrust-metrics | torrust-metrics |
Prometheus-compatible metrics: counters, gauges, labels, samples |
net-primitives |
torrust/torrust-net-primitives | torrust-net-primitives |
Generic networking primitive types (ServiceBinding, Protocol) |
server-lib |
torrust/torrust-server-lib | torrust-server-lib |
Shared server library utilities |
http-protocolimplements:- URL parameter parsing
- Response bencoding
- Error code mapping
- Compact peer formatting
udp-protocolhandles:- Connection ID management
- Message framing (32-bit big-endian)
- Transaction ID tracking
- Error response codes
- Testability: Core packages have minimal dependencies for easy unit testing
- Observability: Health checks and metrics built into server packages
- Modularity: Protocol implementations decoupled from transport layers
- Extensibility: New protocols can be added without modifying core logic
Diagram shows clean separation between network I/O (servers), protocol handling, and core tracker logic