{"id":21659772,"url":"https://github.com/fluencelabs/marine","last_synced_at":"2025-05-16T10:08:01.845Z","repository":{"id":38192363,"uuid":"256785733","full_name":"fluencelabs/marine","owner":"fluencelabs","description":"Marine runs multi-module WebAssembly applications with interface-types and shared-nothing linking scheme","archived":false,"fork":false,"pushed_at":"2024-09-04T15:48:56.000Z","size":15480,"stargazers_count":202,"open_issues_count":27,"forks_count":27,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-29T14:47:27.213Z","etag":null,"topics":["interface-types","runtime","virtual-machine","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluencelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2020-04-18T15:20:56.000Z","updated_at":"2025-03-20T06:17:44.000Z","dependencies_parsed_at":"2022-07-12T01:47:41.627Z","dependency_job_id":"7a41f477-47bd-4946-a87d-86d8a1281728","html_url":"https://github.com/fluencelabs/marine","commit_stats":{"total_commits":504,"total_committers":17,"mean_commits":"29.647058823529413","dds":0.5436507936507937,"last_synced_commit":"609edabf1a92eac85d65ca20227c595bfbbb2cd2"},"previous_names":["fluencelabs/fce"],"tags_count":240,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluencelabs%2Fmarine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluencelabs%2Fmarine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluencelabs%2Fmarine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluencelabs%2Fmarine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluencelabs","download_url":"https://codeload.github.com/fluencelabs/marine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252790047,"owners_count":21804536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["interface-types","runtime","virtual-machine","wasm"],"created_at":"2024-11-25T09:31:31.382Z","updated_at":"2025-05-16T10:07:56.838Z","avatar_url":"https://github.com/fluencelabs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Marine\n\n![marine version on crates.io](https://img.shields.io/crates/v/marine?color=green\u0026style=flat-square)\n[![Coverage Status](https://coveralls.io/repos/github/fluencelabs/marine/badge.svg)](https://coveralls.io/github/fluencelabs/marine)\n\nMarine is a modern general purpose Wasm runtime based on the [component model](https://github.com/WebAssembly/component-model) capable of running multi-module Wasm applications, aka services, with [interface-types](https://github.com/WebAssembly/interface-types) and a [shared-nothing linking](https://training.linuxfoundation.org/blog/how-and-why-to-link-webassembly-modules/) scheme. This execution model is well suited for a variety of scenarios and especially applicable to implementations following the [entity component system](https://en.wikipedia.org/wiki/Entity_component_system) (ECS) pattern or plugin-based architectures.\n\n[Fluence](https://fluence.network) peers, such as Fluence [Rust node](https://github.com/fluencelabs/fluence), include Marine to execute the hosted Wasm services composed with [Aqua](https://github.com/fluencelabs/aqua).\n\n\n## Motivational example\n\nTo illustrate the capabilities of Marine, let's have a look at a multi-module Wasm service as implemented in [this](./examples/motivational-example) example.\n\n`cd` into the `examples/motivational-example` directory and have a look at the  [`shrek/src/main.rs`](./examples/motivational-example/shrek/src/main.rs) file: \n\n```rust\n// examples/motivational-example/shrek/src/main.rs\nuse marine_rs_sdk::marine;\n\nfn main() {}\n\n#[marine]\npub fn greeting(name: \u0026str) -\u003e Vec\u003cString\u003e {\n    let donkey_greeting = donkey::greeting(name);         // 1\n    let shrek_greeting = format!(\"Shrek: hi, {}\", name);  // 2\n    \n    vec![shrek_greeting, donkey_greeting]                 \n}\n\nmod donkey {                                               // 3\n    use super::*;\n\n    #[marine]\n    #[link(wasm_import_module = \"donkey\")]                 // 4\n    extern \"C\" {\n        pub fn greeting(name: \u0026str) -\u003e String;\n    }\n}\n```\n\nIn this Marine (Wasm) module (and namespace) `shrek`, we declare a function `greeting` that creates a `donkey_greeting` (1) from the `donkey` module's (3)`greeting` function, which itself is dependent on importing the `donkey` **Wasm module** with Rust's FFI [`link`](https://doc.rust-lang.org/nomicon/ffi.html) (4) from [`donkey/src/main.rs`](./examples/motivational-example/donkey/src/main.rs) (see below).\n\n```rust\n// examples/motivational-example/donkey/src/main.rs\nuse marine_rs_sdk::marine;\n\nfn main() {}\n\n#[marine]\npub fn greeting(name: \u0026str) -\u003e String {\n    format!(\"Donkey: hi, {}\", name)\n}\n```\n\nIn summary, our example is comprised of two independent Wasm modules, `shrek` and `donkey`, and illustrates how to link one module into another one, i.e., use the `donkey` module in the `shrek` module. Please note that the `shrek` module is called a *facade* module following the [facade pattern]((https://en.wikipedia.org/wiki/Facade_pattern)) and there can only be one *facade* module per service. \n\n\nMake sure you have the Marine tools [installed](https://fluence.dev/docs/marine-book/quick-start/setting-up-the-development-environment) and compile the `donkey` and `shrek`, respectively, which we can do with the `build.sh` script:\n\n```bash\n$\u003e ./build.sh\n```\n\nwhich creates two independent Wasm modules that are placed in the `artifacts` directory:\n\n```bash\n$\u003e ls artifacts\ndonkey.wasm    shrek.wasm\n```\n\nNow that we have our modules, we can explore them with the Marine REPL. Note that we use the  `Config.toml` file to help out the REPL by providing the module location and names. Once we got the REPL up and running, we can interact with both modules and, as expected, the `shrek` module is successfully able to access the `donkey` module's exposed functions.\n\n```bash\n$\u003e marine repl Config.toml\n...\n1\u003e interface\nLoaded modules interface:\n\nshrek:\n  fn greeting(name: string) -\u003e []string\ndonkey:\n  fn greeting(name: string) -\u003e string\n\n2\u003e call donkey greeting \"no link module\"\nresult: \"Donkey: hi, no link module\"\n elapsed time: 42.985µs\n\n3\u003e call shrek greeting \"facade with link module\"\nresult: [\n  \"Shrek: hi, facade with link module\",\n  \"Donkey: hi, facade with link module\"\n]\n elapsed time: 39.25µs\n\n4\u003e q\n```\n\nLooks like everything is in order and the modules are ready for [deployment to the network](https://fluence.dev/docs/build/quick-start/hosted-services/#deploying-a-wasm-module-to-the-network) and [composition with Aqua](https://fluence.dev/docs/build/quick-start/service-composition-and-reuse/).\n\n\n## Documentation\n\n- [Marine Book](https://fluence.dev/docs/marine-book/introduction)\n- [Marine Examples](https://github.com/fluencelabs/examples/tree/main/marine-examples)\n- [Marine Quick start](https://fluence.dev/docs/marine-book/quick-start/)\n\nDo not forget to check our [YouTube channel](https://www.youtube.com/@fluencelabs).\n\n## Repository structure\n\n- [**crates**](./crates)\n    - [it-generator](./crates/it-generator): a generator of IT\n    - [it-interfaces](./crates/it-interfaces): a handy structure for interface types handling\n    - [it-json-serde](./crates/it-json-serde): a crate for conversion between IT and JSON\n    - [min-it-version](./crates/min-it-version) keeps minimal supported versions of IT and SDK by runtime\n    - [module-info-parser](./crates/module-info-parser): a parser of the module manifest and the SDK version\n    - [module-interface](./crates/module-interface): a parser of module IT\n    - [utils](./crates/utils): some utility functions and consts\n- [**examples**](./examples): several Marine examples used mostly for tests\n- [**fluence-faas**](./fluence-faas): a Fluence FaaS layer that provides host closures, IT\u003c-\u003eJSON conversion, logger, config handling and other things\n- [**fluence-app-service**](./fluence-app-service): a Fluence Application Service layer that provides basic API for service running\n- [**runtime**](./runtime): a runtime layer that provides basic functionality for loading, unloading and calling modules\n- [**marine-js**](./marine-js): a web runtime layer aimed to run Marine in a browser\n- [**tools**](./tools)\n    - [REPL](./tools/repl): a REPL intended to test Marine Wasm modules\n    - [CLI](./tools/cli): a CLI intended to build and extract some info from Marine Wasm modules\n\n\n## Support\n\nPlease, [file an issue](https://github.com/fluencelabs/marine/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project).  We will do our best to resolve the issue ASAP.\n\n\n## Contributing\n\nAny interested person is welcome to contribute to the project. Please, make sure you read and follow some basic [rules](./CONTRIBUTING.md).\n\n\n## License\n\nAll software code is copyright (c) Fluence DAO under the [AGPLv3](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluencelabs%2Fmarine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluencelabs%2Fmarine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluencelabs%2Fmarine/lists"}