{"id":29953777,"url":"https://github.com/kodebarinn/kode-bridge","last_synced_at":"2026-01-18T09:02:29.584Z","repository":{"id":300983591,"uuid":"1007682181","full_name":"KodeBarinn/kode-bridge","owner":"KodeBarinn","description":"A modern Rust library that implements HTTP Over IPC for cross-platform","archived":false,"fork":false,"pushed_at":"2025-12-27T08:42:09.000Z","size":2858,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2025-12-29T00:52:37.525Z","etag":null,"topics":["client","http","ipc","rust","rust-crate","server"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KodeBarinn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-24T11:17:21.000Z","updated_at":"2025-12-17T13:27:53.000Z","dependencies_parsed_at":"2025-06-24T15:44:59.227Z","dependency_job_id":"f78e2266-132f-4301-9b5e-e1eb5682a237","html_url":"https://github.com/KodeBarinn/kode-bridge","commit_stats":null,"previous_names":["kodebarinn/kode-bridge"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/KodeBarinn/kode-bridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KodeBarinn%2Fkode-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KodeBarinn%2Fkode-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KodeBarinn%2Fkode-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KodeBarinn%2Fkode-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KodeBarinn","download_url":"https://codeload.github.com/KodeBarinn/kode-bridge/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KodeBarinn%2Fkode-bridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","http","ipc","rust","rust-crate","server"],"created_at":"2025-08-03T15:12:19.017Z","updated_at":"2026-01-18T09:02:29.562Z","avatar_url":"https://github.com/KodeBarinn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kode-bridge\n\n[![Rust](https://img.shields.io/badge/rust-stable-brightgreen.svg)](https://www.rust-lang.org/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Crates.io](https://img.shields.io/crates/v/kode-bridge.svg)](https://crates.io/crates/kode-bridge)\n\n\u003c!-- **[中文](./README_CN.md) | English** --\u003e\n\n**kode-bridge** is a modern Rust library that implements **HTTP Over IPC** for cross-platform (macOS, Linux, Windows) communication. It provides both **client and server** capabilities with elegant HTTP-style request/response and real-time streaming through Unix Domain Sockets or Windows Named Pipes, featuring a fluent API similar to reqwest with comprehensive connection pooling, advanced error handling, and high-performance streaming.\n\n## ✨ Features\n\n- **🌍 True Cross-Platform**: Automatically detects the platform and uses optimal IPC methods\n  - **Unix/Linux/macOS**: Unix Domain Sockets\n  - **Windows**: Named Pipes\n- **🚀 Complete Client/Server Architecture**: \n  - **Client**: `IpcHttpClient` (HTTP-style request/response) + `IpcStreamClient` (real-time streaming)\n  - **Server**: `IpcHttpServer` (HTTP routing service) + `IpcStreamServer` (streaming broadcast service)\n- **💎 Fluent API**: Reqwest-inspired method chaining with type-safe JSON handling\n- **📦 Auto Serialization**: Built-in JSON request and response processing\n- **⚡ High Performance**: Optimized connection management strategies for different platforms\n- **🔧 Easy Integration**: Based on [interprocess](https://github.com/kotauskas/interprocess) and Tokio async runtime\n- **🔄 Backward Compatible**: Old API methods still work alongside new fluent interface\n- **📖 Complete Support**: Includes examples, benchmarks, and comprehensive documentation\n\n## 🚀 Quick Start\n\n### Add Dependencies\n\n```toml\n[dependencies]\n# Client only (default)\nkode-bridge = \"0.1\"\n\n# Server only  \nkode-bridge = { version = \"0.1\", features = [\"server\"] }\n\n# Both client and server\nkode-bridge = { version = \"0.1\", features = [\"full\"] }\n\n# Required runtime\ntokio = { version = \"1\", features = [\"full\"] }\nserde = { version = \"1.0\", features = [\"derive\"] }\nserde_json = \"1.0\"\n```\n\n### Available Features\n\n- **`client`** (default) - HTTP and streaming client functionality\n- **`server`** - HTTP and streaming server functionality  \n- **`full`** - Both client and server capabilities\n\n### Basic Usage\n\n```rust\nuse dotenvy::dotenv;\nuse kode_bridge::{IpcHttpClient, Result};\nuse std::env;\nuse std::time::Duration;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    dotenv().ok();\n\n    // Use platform-appropriate environment variable with fallback\n    #[cfg(unix)]\n    let ipc_path = env::var(\"CUSTOM_SOCK\").unwrap_or_else(|_| \"/tmp/example.sock\".to_string());\n    #[cfg(windows)]\n    let ipc_path = env::var(\"CUSTOM_PIPE\").unwrap_or_else(|_| r\"\\\\.\\pipe\\example\".to_string());\n\n    println!(\"📡 Connecting to: {}\", ipc_path);\n\n    // Create client with modern API\n    let client = IpcHttpClient::new(\u0026ipc_path)?;\n\n    // Use the new fluent API with custom headers and timeout\n    let response = client\n        .get(\"/version\")\n        .header(\"Authorization\", \"Bearer token123\")\n        .header(\"X-Custom-Header\", \"custom-value\")\n        .timeout(Duration::from_secs(10))\n        .send()\n        .await?;\n\n    println!(\"🔍 Response Details:\");\n    println!(\"  Status: {}\", response.status());\n    println!(\"  Success: {}\", response.is_success());\n    println!(\"  Content Length: {}\", response.content_length());\n\n    // Parse and display JSON response\n    match response.json_value() {\n        Ok(json) =\u003e println!(\"📄 JSON Response: {:#}\", json),\n        Err(e) =\u003e {\n            println!(\"📄 Raw Response: {:?}\", response.body()?);\n            println!(\"⚠️  JSON parse error: {}\", e);\n        }\n    }\n\n    // Show pool stats if available\n    if let Some(stats) = client.pool_stats() {\n        println!(\"📊 Pool Stats: {}\", stats);\n    }\n\n    Ok(())\n}\n```\n\n### Server Usage\n\n```rust\nuse kode_bridge::{\n    ipc_http_server::{HttpResponse, IpcHttpServer, Router},\n    Result,\n};\nuse serde_json::json;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    // Create HTTP server with routing\n    let router = Router::new()\n        .get(\"/version\", |_| async move {\n            HttpResponse::json(\u0026json!({\"version\": \"1.0.0\"}))\n        })\n        .post(\"/api/data\", |ctx| async move {\n            let data: serde_json::Value = ctx.json()?;\n            HttpResponse::json(\u0026json!({\"received\": data}))\n        });\n\n    let mut server = IpcHttpServer::new(\"/tmp/server.sock\")?.router(router);\n\n    println!(\"🚀 Server listening on /tmp/server.sock\");\n    server.serve().await\n}\n```\n\n### Advanced Client Usage\n\n```rust\nuse kode_bridge::{IpcHttpClient, IpcStreamClient};\nuse tokio_stream::StreamExt;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let client = IpcHttpClient::new(\"/tmp/service.sock\")?;\n    \n    // All HTTP methods supported\n    let response = client.put(\"/api/config\")\n        .json_body(\u0026json!({\"key\": \"value\"}))\n        .send()\n        .await?;\n    \n    // Rich response inspection\n    println!(\"Status: {}\", response.status());\n    println!(\"Headers: {:?}\", response.headers());\n    println!(\"Content length: {}\", response.content_length());\n    println!(\"Is client error: {}\", response.is_client_error());\n    println!(\"Is server error: {}\", response.is_server_error());\n    \n    // Stream processing with real-time callbacks\n    let stream_client = IpcStreamClient::new(\"/tmp/service.sock\")?;\n    \n    stream_client\n        .get(\"/events\")\n        .send()\n        .await?\n        .process_lines(|line| {\n            println!(\"Real-time event: {}\", line);\n            Ok(())\n        })\n        .await?;\n    \n    Ok(())\n}\n```\n\n### Using Environment Variables\n\nCreate a `.env` file:\n\n```env\n# Unix systems\nCUSTOM_SOCK=/tmp/my_app.sock\n\n# Windows systems (each backslash needs to be escaped by doubling)\nCUSTOM_PIPE=\\\\\\\\.\\\\pipe\\\\\\my_app\n```\n\nThen in your code:\n\n```rust\nuse dotenv::dotenv;\nuse std::env;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    dotenv().ok();\n    \n    #[cfg(unix)]\n    let path = env::var(\"CUSTOM_SOCK\").unwrap_or(\"/tmp/default.sock\".to_string());\n    \n    #[cfg(windows)]\n    let path = env::var(\"CUSTOM_PIPE\").unwrap_or(r\"\\\\.\\pipe\\default\".to_string());\n    \n    let client = IpcHttpClient::new(\u0026path)?;\n    \n    // Use modern fluent API\n    let response = client\n        .get(\"/status\")\n        .timeout(Duration::from_secs(10))\n        .send()\n        .await?;\n    \n    // Or use legacy API for backward compatibility\n    let response = client.request(\"GET\", \"/status\", None).await?;\n    \n    Ok(())\n}\n```\n\n## 📋 Examples\n\nRun built-in examples:\n\n```bash\n# Basic request example\ncargo run --example request\n\n# Large data request example  \ncargo run --example request_large\n\n# Elegant HTTP client demo\ncargo run --example elegant_http\n\n# Elegant streaming client demo\ncargo run --example elegant_stream\n\n# Two client comparison\ncargo run --example two_clients\n\n# Real-time traffic monitoring\ncargo run --example traffic\n\n# HTTP server examples (requires server feature)\ncargo run --example http_server --features server\n\n# Streaming server examples (requires server feature)\ncargo run --example stream_server --features server\n\n# Using custom IPC path\nCUSTOM_SOCK=/tmp/my.sock cargo run --example request  # Unix\nCUSTOM_PIPE=\\\\\\\\.\\\\pipe\\\\my_pipe cargo run --example request  # Windows\n```\n\n## 🔥 Performance Benchmarks\n\nRun performance benchmarks:\n\n```bash\n# Run all benchmarks\ncargo bench\n\n# View benchmark reports\nopen target/criterion/report/index.html\n```\n\nBenchmarks automatically:\n- Detect the running platform\n- Use appropriate environment variables (`CUSTOM_SOCK` or `CUSTOM_PIPE`)\n- Apply platform-specific performance optimization strategies\n\n## 🏗️ Architecture Design\n\n```\n┌─────────────────────────────────────────┬─────────────────────────┐\n│              CLIENT SIDE                │     SERVER SIDE         │\n├─────────────────────────────────────────┼─────────────────────────┤\n│  IpcHttpClient   │  IpcStreamClient     │ IpcHttpServer │ IpcStreamServer │\n│ (HTTP Req/Res)   │  (Real-time Stream)  │ (HTTP Routing)│ (Stream Broadcast)  │\n├─────────────────────────────────────────┼─────────────────────────┤\n│              Fluent API                 │    Routing System       │\n│   (HTTP-like Methods \u0026 Method Chaining) │ (Request Handling \u0026 Response) │\n├─────────────────────────────────────────┼─────────────────────────┤\n│            http_client.rs               │   http_server.rs        │\n│        (HTTP Protocol Handler)          │  (HTTP Protocol Server) │\n├─────────────────────────────────────────┴─────────────────────────┤\n│                    interprocess                              │\n│                (Cross-Platform IPC Transport)                    │\n├─────────────────┬───────────────────────┬─────────────────────────┤\n│   Unix Sockets  │    Windows Pipes      │   Feature Flags         │\n│   (Unix/Linux)  │     (Windows)         │ (client/server/full)    │\n└─────────────────┴───────────────────────┴─────────────────────────┘\n```\n\n### Core Components\n\n#### Client Components\n- **`IpcHttpClient`**: HTTP-style request/response client with fluent API\n- **`IpcStreamClient`**: Real-time streaming client for continuous data monitoring\n- **Fluent API**: Method chaining with `get()`, `post()`, `timeout()`, `json_body()`, `send()`, etc.\n\n#### Server Components\n- **`IpcHttpServer`**: HTTP server with routing system and middleware support\n- **`IpcStreamServer`**: Real-time streaming server with broadcast and multi-client management\n- **Routing System**: Express.js-like routing patterns with path parameters and query parameter support\n\n#### Shared Components\n- **`http_client/server`**: Platform-agnostic HTTP protocol handling with chunked transfer encoding support\n- **Smart Platform Detection**: Compile-time automatic selection of optimal IPC implementation\n- **Feature Flags**: Flexible compile-time functionality selection\n\n### API Comparison\n\n| Feature | Old API | New Fluent API |\n|---------|---------|---------------|\n| GET Request | `client.request(\"GET\", \"/path\", None)` | `client.get(\"/path\").send()` |\n| POST with JSON | `client.request(\"POST\", \"/path\", Some(\u0026json))` | `client.post(\"/path\").json_body(\u0026json).send()` |\n| Timeout | Not supported | `client.get(\"/path\").timeout(Duration::from_secs(5)).send()` |\n| Response Status | `response.status` | `response.status()`, `response.is_success()` |\n| JSON Parsing | `response.json()?` | `response.json::\u003cT\u003e()?` with type inference |\n| Streaming | Not available | `stream_client.get(\"/events\").json_results().await?` |\n\n## 🎯 Use Cases\n\n- **Local Service Communication**: Communicate with local processes like Clash, Mihomo, proxy services, etc.\n- **Real-time Monitoring**: Stream traffic data, logs, metrics, and system events in real-time\n- **Microservice Architecture**: High-performance inter-process HTTP communication\n- **System Integration**: Replace traditional REST API local calls with IPC\n- **Performance-Critical Applications**: Scenarios requiring low-latency local communication\n- **Configuration Management**: Dynamic configuration updates with immediate feedback\n\n## 🛠️ Development\n\n### Build Project\n\n```bash\ngit clone https://github.com/KodeBarinn/kode-bridge.git\ncd kode-bridge\ncargo build\n```\n\n### Run Tests\n\n```bash\ncargo test\n```\n\n### Generate Documentation\n\n```bash\ncargo doc --open\n```\n\n## 📚 Resources\n\n- [Platform Guide](./PLATFORM_GUIDE.md) - Detailed cross-platform usage guide\n- [Server Guide](./SERVER_GUIDE.md) - Complete server development guide\n- [Examples](./examples/) - Complete example code (client and server)\n- [Benchmarks](./benches/) - Performance benchmarks\n\n## 🤝 Contributing\n\nWe welcome Issues and Pull Requests!\n\n## 📄 License\n\nThis project is licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\nSee the [Licence](./Licence) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodebarinn%2Fkode-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodebarinn%2Fkode-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodebarinn%2Fkode-bridge/lists"}