$ show librats/rats-search
Rats Search is a decentralized BitTorrent search engine implemented as a Qt6/C++ desktop application with a headless server mode. It crawls the BitTorrent DHT network to discover torrent metadata, indexes it using Manticore Search (a Sphinx-compatible full-text database), and provides a full-featured GUI for searching, downloading, and managing torrents. The application also includes a P2P replication layer for synchronizing databases between peers, a REST/WebSocket API for remote control, and support for torrent creation, seeding, and metadata export. The codebase is well-layered (domain, data, services, net, ui, rest) with clear separation of concerns, extensive unit and integration tests (15+ test files), and a professional CMake build system with CI for Windows, macOS, and Linux. A legacy Electron/Node.js version (v1.x) is preserved in the `legacy/` directory but is not actively developed. The project demonstrates high craftsmanship in its data layer (hash-based row IDs, safe SphinxQL query builders, resumable database dumps) and service architecture (cancel tokens, progress reporting, event-driven updates via Qt signals). However, the main window (`mainwindow.cpp`) exceeds 2400 lines, and the presence of the legacy codebase adds maintenance overhead.
The LLM identified 7 files worth highlighting for reuse:
Provides a generic Result<T> type and ResultCallback for propagating success/failure across service and API layers. Self-contained, no internal dependencies beyond standard library. Easily extractable for any C++ project needing a monadic error handling pattern.
Fluent SQL query builder for Manticore/SphinxQL with injection-safe ORDER BY (only accepts identifiers) and proper escaping for backslash and quotes. Isolated utility that can be reused in any project using Manticore Search.
Stateless classifier that maps file extensions to content types (video, audio, software, etc.) using JSON resource files and detects adult/bad content via word lists. Testable, pure logic with no dependencies on other internal modules. Reusable pattern for any content categorization task.
Generates a 63-bit row ID from a SHA-1 infohash for O(1) lookup in Manticore's integer-based docid. Includes collision detection and a RowSlot pattern for resolving collisions. Self-contained and critical for distributed database integrity.
Implements a versioned, resumable database dump/import format (.ratsdb) with streaming writer/reader, offset tracking, cancellation via CancelToken, and peer-to-peer pull protocol. The dump format and I/O pattern are reusable for any distributed database replication scenario.
Parallel tracker scraper that manages concurrent HTTP requests with a configurable concurrency limit and deduplication of tracker endpoints. Uses Qt's QNetworkAccessManager and a simple state machine. Reusable pattern for any multi-source HTTP scraping with rate limiting.
Defines a `add_rats_test()` CMake function that creates test executables, links them against the core library and Qt6::Test, and registers them with CTest. This is a self-contained CMake pattern that can be extracted to simplify test setup in any CMake project.