MCPcopy Index your code
hub / github.com/Zyell/beelay-iroh-chat

github.com/Zyell/beelay-iroh-chat @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
55 symbols 67 edges 17 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Tauri + Leptos + TailwindCSS + Iroh + Keyhive/Beelay

[!CAUTION] This is an experiment, proof of concept, integrating rapidly developing technologies. It should not be relied on for Production!

This is a simple chat application to demonstrate Iroh P2P connections and Beelay/Keyhive using an Iroh Beelay/Keyhive custom protocol. It is a technical exploration and proof of concept of the underlying technologies. It is not a polished application and many todos, notes, and warnings reside within. The primary exploratory goals were the following:

  • Integrate the Iroh Beelay/Keyhive custom protocol into a "real" application to understand the needs and challenges of doing so.
  • Explore cross-platform application development in Rust using Tauri
  • Explore how the lack of IPC type safety can be overcome when you have a Rust frontend like Leptos coupled with a Tauri backend, without resorting to external DSL tools.

Development Environment

Note: RustRover was used as the development IDE and some configuration for it is contained in this repository, in particular directory exclusion rules

TailwindCSS

You can follow the instructions to setup TailwindCSS here. The CLI tool is recommended and was used for this application's development.

Dev:

npx @tailwindcss/cli -i tailwind_input.css -o tailwind_output.css --watch

Release:

npx @tailwindcss/cli -i tailwind_input.css -o tailwind_output.css --minify

Note: Integration of tailwind with Leptos is also an option

Tauri + Leptos Application

This application was generated using the Tauri command line tools with cargo using the Leptos template and subsequently updated to Leptos v0.82 without issue.

IPC Type Safety

Tauri does not by default provide type safety across the IPC boundary. Given that most Tauri apps target a JS/TS frontend, there are options to generate TS interface code for type safety. There are very few for Rust frontends. Tauri-bindgen exists, but requires a DSL in the middle. This is not desirable when going from Rust to Rust only. I found inspiration from tauri-ipc-macros and tauri-sys. While command invocation was well covered using tauri-ipc-macros, it did not enforce complete type safety around events and required enum setups for events that make integration with event streams in tauri-sys difficult. The workspace for this app contains an ipc_macros crate for applying type safety on the IPC layer while maintaining good IDE ergonomics using feature flags. It isn't perfect, but manages to find a sweet spot ergonomically, while enforcing type safety for this project's needs. Hopefully with enough iterations to provide inspiration, we can solve this problem with Tauri elegantly for everyone using Rust frontends. :-)

Note: Please see documentation notes in the ipc_macros and ipc_layer crates in the workspace for more details

Cross-Platform build Linux & Android

To support identification of a mobile build to exclude/include the barcode scanner logic, it is important to indicate through trunk that Leptos should run with the mobile feature enabled. Otherwise, only Tauri will know it is targeting a mobile environment.

The tauri.android.conf.json was created to pass a feature flag like so:

{
  "build": {
    "beforeDevCommand": "trunk serve --features mobile",
    "beforeBuildCommand": "trunk build --features mobile"
  }
}

This will automatically build Leptos properly when running

cargo tauri android dev

This application has been built and configured for Linux and Android only thus far.

For android apk signing, configuration is in place, according to the Tauri docs; however, you will need to create your own keystore.properties to allow for a signed apk to be automatically built when building for release. (This facilitates sideloading over adb without issues.)

Extension points exported contracts — how you extend this code

API (Interface)
(no doc)
ipc_layer/src/lib.rs
Commands (Interface)
(no doc)
ipc_macros/tests/test_derivations_commands_tauri.rs
Commands (Interface)
(no doc)
ipc_macros/tests/test_derivations_commands_ui.rs

Core symbols most depended-on inside this repo

timestamp
called by 2
src/app.rs
unpack_for_html_integration
called by 2
ipc_layer/src/lib.rs
set_document_id
called by 1
ipc_layer/src/tauri.rs
set_node_ticket
called by 1
ipc_layer/src/tauri.rs
apply
called by 1
src-tauri/gen/android/buildSrc/src/main/java/com/beelay_chat/app/kotlin/RustPlugin.kt
handle_doc_events
called by 1
src-tauri/src/lib.rs
handle_connections
called by 1
src-tauri/src/lib.rs
setup
called by 1
src-tauri/src/lib.rs

Shape

Class 17
Function 17
Method 15
Enum 3
Interface 3

Languages

Rust87%
Kotlin13%

Modules by API surface

ipc_macros/src/lib.rs14 symbols
ipc_layer/src/lib.rs10 symbols
ipc_layer/src/tauri.rs8 symbols
src/app.rs5 symbols
src-tauri/src/lib.rs4 symbols
src-tauri/gen/android/buildSrc/src/main/java/com/beelay_chat/app/kotlin/RustPlugin.kt3 symbols
src-tauri/gen/android/buildSrc/src/main/java/com/beelay_chat/app/kotlin/BuildTask.kt3 symbols
ipc_macros/tests/test_derivations_commands_tauri.rs2 symbols
src/main.rs1 symbols
src-tauri/src/main.rs1 symbols
src-tauri/gen/android/app/src/main/java/com/beelay_chat/app/MainActivity.kt1 symbols
src-tauri/build.rs1 symbols

For agents

$ claude mcp add beelay-iroh-chat \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact