Marine 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.
[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).
To illustrate the capabilities of Marine, let's have a look at a multi-module Wasm service as implemented in [this](./examples/motivational-example) example.
`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:
In 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).
In 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.
Make 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:
Now 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.
Looks 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/).
Please, [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.
## Contributing
Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic [rules](./CONTRIBUTING.md).
## License
All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](./LICENSE) license.