|
1 | | -## Funding |
| 1 | +<table><tr> |
| 2 | +<td colspan="1"> <h3 align="center"> <picture> |
| 3 | +<source media="(prefers-color-scheme: dark)" srcset="https://PlayForm.Cloud/Dark/Image/GitHub/Land.svg"> |
| 4 | +<source media="(prefers-color-scheme: light)" srcset="https://PlayForm.Cloud/Image/GitHub/Land.svg"> |
| 5 | +<img width="28" alt="Land Logo" src="https://PlayForm.Cloud/Image/GitHub/Land.svg"> |
| 6 | +</picture> </h3> </td> <td colspan="3" valign="top"> <h3 align="center"> Mountain ⛰️ |
| 7 | +</h3> </td> |
| 8 | +</tr></table> |
2 | 9 |
|
3 | | -This project is funded through |
4 | | -[NGI0 Commons Fund](https://nlnet.nl/commonsfund), a fund established by |
| 10 | +# **Mountain** ⛰️ The Bedrock of Land: Native Backend & Service Host |
| 11 | + |
| 12 | +[](https://github.com/CodeEditorLand/Mountain/blob/Current/LICENSE) |
| 13 | +[](https://www.rust-lang.org/) |
| 14 | +[](https://tauri.app/) |
| 15 | +[](https://github.com/hyperium/tonic) |
| 16 | + |
| 17 | +Welcome to **Mountain**! This element is the native Rust backend and Tauri |
| 18 | +application shell for the Land Code Editor. It serves as the foundational |
| 19 | +bedrock for the entire system, managing the application lifecycle, orchestrating |
| 20 | +native OS operations, and providing high-performance services to the `Wind` |
| 21 | +frontend and the `Cocoon` extension host. |
| 22 | + |
| 23 | +**Mountain** is engineered to: |
| 24 | + |
| 25 | +1. **Be the Native Core:** Act as the primary Rust application, leveraging |
| 26 | + Tauri to create a lightweight, cross-platform windowing and webview host. |
| 27 | +2. **Provide High-Performance Services:** Implement the abstract service traits |
| 28 | + defined in the `Common` crate, offering native-speed implementations for |
| 29 | + filesystem I/O, process management, secure storage, and more. |
| 30 | +3. **Orchestrate Sidecars:** Reliably launch, manage, and communicate with the |
| 31 | + `Cocoon` (Node.js) extension host sidecar via a robust gRPC interface. |
| 32 | +4. **Power the UI:** Serve as the backend for the `Wind` UI layer, responding |
| 33 | + to requests via Tauri commands and pushing state updates via Tauri events. |
| 34 | + |
| 35 | +## Key Features 🔐 |
| 36 | + |
| 37 | +- **Declarative Effect System:** Built on a custom Rust `ActionEffect` system |
| 38 | + defined in the `Common` crate. All business logic is described as declarative, |
| 39 | + composable effects, which are executed by a central `AppRuntime`. |
| 40 | +- **gRPC-Powered IPC:** Hosts a `tonic`-based gRPC server (`Vine`) to provide a |
| 41 | + strongly-typed, high-performance communication channel for the `Cocoon` |
| 42 | + extension host. |
| 43 | +- **Centralized State Management:** Utilizes a thread-safe, Tauri-managed |
| 44 | + `AppState` to act as the single source of truth for the entire application's |
| 45 | + state, from open documents to provider registrations. |
| 46 | +- **Native PTY Management:** Implements a full-featured integrated terminal |
| 47 | + service by spawning and managing native pseudo-terminals (`PTY`) using the |
| 48 | + `portable-pty` crate. |
| 49 | +- **Secure Storage Integration:** Leverages the native OS keychain via the |
| 50 | + `keyring` crate to securely store sensitive data like authentication tokens. |
| 51 | +- **Robust Command Dispatching:** A central `Track` dispatcher intelligently |
| 52 | + routes all incoming requests from the UI (`Wind`) and extensions (`Cocoon`) to |
| 53 | + the appropriate native handlers or effects. |
| 54 | + |
| 55 | +## Core Architecture Principles 🏗️ |
| 56 | + |
| 57 | +| Principle | Description | Key Components Involved | |
| 58 | +| :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------- | |
| 59 | +| **Implementation of Contracts** | Faithfully implement the abstract service `trait`s defined in the `Common` crate, providing the concrete logic for the application's architecture. | `environment/*` providers | |
| 60 | +| **Separation of Concerns** | Isolate business logic in `handlers` modules, keeping the `environment` provider implementations clean and focused on delegation. | `environment/*`, `handlers/*` | |
| 61 | +| **Declarative Logic** | Express all operations as `ActionEffect`s, which are executed by the `AppRuntime`. This makes logic composable, testable, and robust. | `runtime/*`, `track/*`, `Common::effect` | |
| 62 | +| **Centralized State** | Maintain a single, thread-safe `AppState` struct managed by Tauri to ensure data consistency across the entire application. | `app_state/*` | |
| 63 | +| **Secure & Performant IPC** | Utilize gRPC for all communication with the `Cocoon` sidecar, ensuring a well-defined and high-performance API boundary. | `vine/*` | |
| 64 | +| **UI-Backend Decoupling** | Interact with the `Wind` frontend exclusively through asynchronous Tauri commands and events, ensuring the backend is UI-agnostic. | `main.rs` (invoke handler), `handlers/*` (emitters) | |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Deep Dive & Component Breakdown 🔬 |
| 69 | + |
| 70 | +To understand how `Mountain`'s internal components are structured and how they |
| 71 | +implement the application's core logic, please refer to the detailed technical |
| 72 | +breakdown in [`docs/Deep Dive.md`](docs/Deep%20Dive.md). This document explains |
| 73 | +the roles of the `AppRuntime`, `AppState`, `handlers`, `environment`, and the |
| 74 | +`Vine` gRPC layer. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +## `Mountain` in the Land Ecosystem ⛰️ + 🏞️ |
| 79 | + |
| 80 | +This diagram illustrates `Mountain`'s central role as the native orchestrator |
| 81 | +for the entire Land application. |
| 82 | + |
| 83 | +```mermaid |
| 84 | +graph LR |
| 85 | + classDef mountain fill:#f9f,stroke:#333,stroke-width:2px; |
| 86 | + classDef cocoon fill:#ccf,stroke:#333,stroke-width:2px; |
| 87 | + classDef wind fill:#9cf,stroke:#333,stroke-width:2px; |
| 88 | + classDef common fill:#cfc,stroke:#333,stroke-width:1px; |
| 89 | + classDef ipc fill:#ff9,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5; |
| 90 | +
|
| 91 | + subgraph "Mountain (Native Rust/Tauri Backend)" |
| 92 | + TauriRuntime[Tauri App & Window]:::mountain |
| 93 | + AppRuntime[AppRuntime Engine]:::mountain |
| 94 | + AppState["AppState (Shared State)"]:::mountain |
| 95 | + TrackDispatcher[Track Dispatcher]:::mountain |
| 96 | + VineGRPC[Vine gRPC Server]:::ipc |
| 97 | + NativeHandlers[Native Logic Handlers]:::mountain |
| 98 | + CommonCrate["Common Crate (Traits & DTOs)"]:::common |
| 99 | +
|
| 100 | + TauriRuntime -- Manages --> AppState |
| 101 | + TauriRuntime -- Manages --> AppRuntime |
| 102 | + AppRuntime -- Executes effects via --> NativeHandlers |
| 103 | + TrackDispatcher -- Routes requests to --> AppRuntime |
| 104 | + end |
| 105 | +
|
| 106 | + subgraph "Clients" |
| 107 | + WindUI["Wind/Sky UI (Webview)"]:::wind |
| 108 | + CocoonSidecar["Cocoon Extension Host (Node.js)"]:::cocoon |
| 109 | + end |
| 110 | +
|
| 111 | + TauriRuntime -- Hosts --> WindUI |
| 112 | + WindUI -- Tauri Commands --> TrackDispatcher |
| 113 | + TrackDispatcher -- Tauri Events --> WindUI |
| 114 | +
|
| 115 | + VineGRPC -- gRPC Protocol <--> CocoonSidecar; class VineGRPC,CocoonSidecar ipc |
| 116 | + VineGRPC -- Forwards requests to --> TrackDispatcher |
| 117 | +
|
| 118 | + NativeHandlers -- Implements traits from --> CommonCrate |
| 119 | +``` |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Project Structure Overview 🗺️ |
| 124 | + |
| 125 | +The `Mountain` repository is organized to clearly separate concerns, following |
| 126 | +the architectural patterns defined in `Common`. |
| 127 | + |
| 128 | +``` |
| 129 | +Mountain/ |
| 130 | +├── src/ |
| 131 | +│ ├── main.rs # Tauri application entry point and setup. |
| 132 | +│ ├── app_state/ # The central, thread-safe state store for the application. |
| 133 | +│ ├── environment/ # Concrete implementations of the `Common` provider traits. |
| 134 | +│ ├── handlers/ # The detailed business logic for each service domain. |
| 135 | +│ ├── runtime/ # The `AppRuntime` engine that executes effects. |
| 136 | +│ ├── track/ # The central request dispatcher. |
| 137 | +│ └── vine/ # The gRPC server implementation (using `tonic`). |
| 138 | +├── proto/ |
| 139 | +│ └── vine.proto # The gRPC contract definition file. |
| 140 | +└── build.rs # Build script to compile the .proto file into Rust code. |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +## Development Setup |
| 146 | + |
| 147 | +`Mountain` is a Rust crate and a core component of the main `Land` repository. |
| 148 | +It is not intended to be built or run standalone. Please follow the instructions |
| 149 | +in the main [Land Repository README](https://github.com/CodeEditorLand/Land) to |
| 150 | +set up, build, and run the entire application. |
| 151 | + |
| 152 | +**Key Dependencies:** |
| 153 | + |
| 154 | +- `tauri`: `^2.x` |
| 155 | +- `tokio`: For the asynchronous runtime. |
| 156 | +- `tonic`: For the gRPC server implementation. |
| 157 | +- `serde` & `serde_json`: For serialization. |
| 158 | +- `log` & `env_logger`: For logging. |
| 159 | +- `portable-pty`: For the integrated terminal feature. |
| 160 | +- `keyring`: For secure secret storage. |
| 161 | +- `Common` (local path dependency). |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +## License ⚖️ |
| 166 | + |
| 167 | +This project is released into the public domain under the **Creative Commons CC0 |
| 168 | +Universal** license. You are free to use, modify, distribute, and build upon |
| 169 | +this work for any purpose, without any restrictions. For the full legal text, |
| 170 | +see the [`LICENSE`](LICENSE) file. |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## Changelog 📜 |
| 175 | + |
| 176 | +Stay updated with our progress! See [`CHANGELOG.md`](CHANGELOG.md) for a history |
| 177 | +of changes specific to **Mountain**. |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## Funding & Acknowledgements 🙏 |
| 182 | + |
| 183 | +**Mountain** is a core element of the **Land** ecosystem. This project is funded |
| 184 | +through [NGI0 Commons Fund](https://nlnet.nl/commonsfund), a fund established by |
5 | 185 | [NLnet](https://nlnet.nl) with financial support from the European Commission's |
6 | 186 | [Next Generation Internet](https://ngi.eu) program. Learn more at the |
7 | 187 | [NLnet project page](https://nlnet.nl/project/Land). |
8 | 188 |
|
9 | | -| Land | PlayForm | NLnet | NGI0 Commons Fund | |
10 | | -| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | |
11 | | -| [<img src="https://raw.githubusercontent.com/CodeEditorLand/Asset/refs/heads/Current/Logo/Land.svg" height="80px" alt="Land" />](https://editor.land) | [<img src="https://raw.githubusercontent.com/PlayForm/Asset/refs/heads/Current/Logo/PlayForm.svg" height="80px" alt="PlayForm" />](https://playform.cloud) | [<img width="240px" src="https://nlnet.nl/logo/banner.svg" alt="NLnet" />](https://nlnet.nl) | [<img width="240px" src="https://nlnet.nl/image/logos/NGI0CommonsFund_tag_black_mono.svg" alt="NGI0 Commons Fund" />](https://nlnet.nl/commonsfund) | |
| 189 | +| **Land** | PlayForm | NLnet | NGI0 Commons Fund | |
| 190 | +| :-------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 191 | +| [<img src="https://raw.githubusercontent.com/CodeEditorLand/Asset/refs/heads/Current/Logo/Land.svg" height="80px" alt="Land">](https://editor.land) | [<img src="https://raw.githubusercontent.com/PlayForm/Asset/refs/heads/Current/Logo/PlayForm.svg" height="80px" alt="PlayForm">](https://playform.cloud) | [<img width="240px" src="https://nlnet.nl/logo/banner.svg" alt="NLnet">](https://nlnet.nl) | [<img width="240px" src="https://nlnet.nl/image/logos/NGI0CommonsFund_tag_black_mono.svg" alt="NGI0 Commons Fund">](https://nlnet.nl/commonsfund) | |
| 192 | + |
| 193 | +--- |
| 194 | + |
| 195 | +**Project Maintainers**: Source Open |
| 196 | +([Source/Open@Editor.Land](mailto:Source/Open@Editor.Land)) | |
| 197 | +[GitHub Repository](https://github.com/CodeEditorLand/Mountain) | |
| 198 | +[Report an Issue](https://github.com/CodeEditorLand/Mountain/issues) | |
| 199 | +[Security Policy](https://github.com/CodeEditorLand/Mountain/security/policy) |
0 commit comments