| Crates.io | brk |
| lib.rs | brk |
| version | 0.0.109 |
| created_at | 2025-02-23 23:40:35.363808+00 |
| updated_at | 2025-09-20 17:22:54.06403+00 |
| description | The Bitcoin Research Kit is a suite of tools designed to extract, compute and display data stored on a Bitcoin Core node |
| homepage | https://bitcoinresearchkit.org |
| repository | https://github.com/bitcoinresearchkit/brk |
| max_upload_size | |
| id | 1566730 |
| size | 153,802 |
Unified Bitcoin Research Kit crate providing optional feature-gated access to all BRK components.
This crate serves as a unified entry point to the Bitcoin Research Kit ecosystem, providing feature-gated re-exports of all BRK components. It allows users to selectively include only the functionality they need while maintaining a single dependency declaration, with the brk_cli component always available for command-line interface access.
Key Features:
full feature for complete BRK functionality inclusionTarget Use Cases:
[dependencies]
# Minimal installation with CLI only
brk = "0.0.107"
# Full functionality
brk = { version = "0.0.107", features = ["full"] }
# Selective features
brk = { version = "0.0.107", features = ["indexer", "computer", "server"] }
// CLI is always available
use brk::cli;
// Feature-gated components
#[cfg(feature = "indexer")]
use brk::indexer::Indexer;
#[cfg(feature = "computer")]
use brk::computer::Computer;
#[cfg(feature = "server")]
use brk::server::Server;
// Build complete pipeline with selected features
#[cfg(all(feature = "indexer", feature = "computer", feature = "server"))]
fn build_pipeline() -> Result<(), Box<dyn std::error::Error>> {
let indexer = Indexer::build("./data")?;
let computer = Computer::build("./analytics", &indexer)?;
let interface = brk::interface::Interface::build(&indexer, &computer);
let server = Server::new(interface, None);
Ok(())
}
The crate provides feature-gated access to BRK components organized by functionality:
Core Data Processing:
structs - Bitcoin-aware data structures and type systemerror - Centralized error handling across componentsstore - Transactional key-value storage wrapperBlockchain Processing:
parser - Multi-threaded Bitcoin block parsingindexer - Blockchain data indexing with columnar storagecomputer - Analytics computation engineData Access:
interface - Unified query interface with fuzzy searchfetcher - Multi-source price data aggregationService Layer:
server - HTTP API server with caching and compressionmcp - Model Context Protocol bridge for LLM integrationlogger - Enhanced logging with colored outputWeb Infrastructure:
bundler - Web asset bundling using Rolldowncli: Command-line interface module (no feature gate required)
Provides access to the complete BRK command-line interface for running full instances.
use brk::parser::Parser;
fn parse_blocks() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(feature = "parser")]
{
let parser = Parser::new("/path/to/blocks", None, rpc_client);
// Parse blockchain data
Ok(())
}
#[cfg(not(feature = "parser"))]
{
Err("Parser feature not enabled".into())
}
}
use brk::{indexer, computer, interface};
#[cfg(all(feature = "indexer", feature = "computer", feature = "interface"))]
fn analytics_pipeline() -> Result<(), Box<dyn std::error::Error>> {
// Initialize indexer
let indexer = indexer::Indexer::build("./blockchain_data")?;
// Compute analytics
let computer = computer::Computer::build("./analytics", &indexer)?;
// Create query interface
let interface = interface::Interface::build(&indexer, &computer);
// Query latest price
let params = interface::Params {
index: "date".to_string(),
ids: vec!["price-close".to_string()].into(),
from: Some(-1),
..Default::default()
};
let result = interface.search_and_format(params)?;
println!("Latest Bitcoin price: {:?}", result);
Ok(())
}
use brk::{server, interface, indexer, computer};
#[cfg(all(feature = "server", feature = "interface", feature = "indexer", feature = "computer"))]
async fn web_server() -> Result<(), Box<dyn std::error::Error>> {
let indexer = indexer::Indexer::build("./data")?;
let computer = computer::Computer::build("./analytics", &indexer)?;
let interface = interface::Interface::build(&indexer, &computer);
let server = server::Server::new(interface, None);
server.serve(true).await?;
Ok(())
}
use brk::{mcp, interface, indexer, computer};
#[cfg(all(feature = "mcp", feature = "interface"))]
fn mcp_server(interface: &'static interface::Interface) -> mcp::MCP {
mcp::MCP::new(interface)
}
Data Processing: ["structs", "parser", "indexer"]
Basic blockchain data processing and indexing.
Analytics: ["indexer", "computer", "fetcher", "interface"]
Complete analytics pipeline with price data integration.
API Server: ["interface", "server", "logger"]
HTTP API server with logging capabilities.
Full Stack: ["full"]
All components for complete BRK functionality.
Feature selection allows for significant dependency reduction:
# Minimal parser-only dependency
brk = { version = "0.0.107", features = ["parser"] }
# Analytics without web server
brk = { version = "0.0.107", features = ["indexer", "computer", "interface"] }
# Web server without parsing
brk = { version = "0.0.107", features = ["interface", "server"] }
The crate uses #[doc(inline)] re-exports to provide seamless access to component APIs:
#[cfg(feature = "component")]
#[doc(inline)]
pub use brk_component as component;
This pattern ensures:
all-features = true for complete docs.rs documentationbrk_cli always available without feature gates| Feature | Component | Description |
|---|---|---|
bundler |
brk_bundler |
Web asset bundling |
computer |
brk_computer |
Analytics computation |
error |
brk_error |
Error handling |
fetcher |
brk_fetcher |
Price data fetching |
indexer |
brk_indexer |
Blockchain indexing |
interface |
brk_interface |
Data query interface |
logger |
brk_logger |
Enhanced logging |
mcp |
brk_mcp |
Model Context Protocol |
parser |
brk_parser |
Block parsing |
server |
brk_server |
HTTP server |
store |
brk_store |
Key-value storage |
structs |
brk_structs |
Data structures |
full |
All components | Complete functionality |
Documentation is aggregated from all components with #![doc = include_str!("../README.md")] ensuring comprehensive API reference across all features.
Main Structure: Feature-gated re-export crate providing unified access to 12 BRK components
Feature System: Cargo features enabling selective compilation and dependency optimization
CLI Integration: Always-available brk_cli access without feature requirements
Documentation: Inline re-exports with comprehensive docs.rs integration
Dependency Management: Optional dependencies for all components except CLI
Build Configuration: Optimized compilation with all-features documentation
Architecture: Modular aggregation crate enabling flexible BRK ecosystem usage
This README was generated by Claude Code