The Problem

Teams that use MATLAB/Simulink struggle to share models, keep version history, and run simulations in CI pipelines. Existing tools are proprietary, require a Windows stack, and provide no lightweight, cross‑platform way to view or execute a subset of Simulink blocks in the browser or as Rust binaries.

What This Does

Unlinked is a Rust‑based web stack that lets users upload .slx or legacy .mdl files, view the diagram as SVG, edit the model in the browser, and run supported simulations (Euler, RK4, Dormand–Prince). The backend is a single binary (backend/src/main.rs) that serves a Yew/WASM front‑end (frontend/src/*.rs) and exposes HTTP/WebSocket APIs for file operations, simulation jobs, and audit logging. A separate CLI (crates/unlinked-cli/src/main.rs) imports models into the database, while a MATLAB‑to‑Rust compiler (crates/unlinked-matlab/src/lib.rs) can translate blocks into Rust/LLVM IR for offline execution.

How It Is Wired

  • Entry point: backend/src/main.rs starts by reading backend/src/config.rs for env variables (DATABASE_URL, SESSION_SECRET, etc.) and creates a Diesel connection pool (backend/src/db.rs).
  • Router construction: backend/src/handlers/mod.rs re‑exports sub‑modules (auth, files, projects, simulations, simulation_socket, health). Each handler defines routes via axum::routing::Router.
  • File handling: backend/src/handlers/files.rs calls backend/src/access.rs for permission checks and interacts with backend/src/models.rs to read/write file blobs stored in PostgreSQL.
  • Simulation orchestration: backend/src/handlers/simulations.rs queues a run, spawns a background task in backend/src/sim_worker.rs, which uses the in‑memory data model from backend/src/models.rs and the simulation engine in crates/unlinked-sim/src/lib.rs. The worker streams results over the WebSocket defined in backend/src/handlers/simulation_socket.rs.
  • Authentication: backend/src/auth.rs implements Google/GitHub OAuth via backend/src/oauth.rs, creating session records in backend/src/session.rs.
  • Front‑end entry: frontend/src/api.rs wraps the HTTP endpoints, frontend/src/diagram.rs renders the SVG via frontend/src/diagram.rs, and frontend/src/diagnostics_worker.rs connects to the WebSocket to display simulation traces.

The chain has 3–4 hops from HTTP request to database write or WebSocket emit, keeping side‑effects localized. The most “blast‑radius” functions are backend/src/handlers/simulations.rs (spawns workers) and backend/src/handlers/files.rs (writes blobs), both of which touch the database and the worker queue.

How To Use It

Setup

# Install Rust and target
rustup target add wasm32-unknown-unknown
cargo install trunk --locked

# Prepare environment
cp .env.example .env
docker compose up -d db   # PostgreSQL (docker-compose.yml)

# Build front‑end and start backend
(cd frontend && trunk build)
cargo run -p backend -- --dev-mode

Configuration Adjust DATABASE_URL and SESSION_SECRET in .env. The backend reads these via backend/src/config.rs. OAuth client IDs are also configured in .env (keys not committed).

Running

  • Web UI: http://localhost:3000
  • CLI import: cargo run -p unlinked-cli -- import path/to/model.zip
  • Compiler: cargo run -p unlinked-matlab -- transpile model.mdl --output model.rs

Real‑World Use

A data‑science team can host Unlinked in a private Docker cluster. Engineers upload a Simulink model, share it with reviewers, and run a quick simulation from the browser to validate a control law. The resulting Rust binary (via crates/unlinked-matlab) can be deployed in an edge device that lacks MATLAB. Example workflow:

  1. Commit .mdl to Git.
  2. Run cargo run -p unlinked-cli -- import .mdl.
  3. Open the model in the UI, tweak a parameter, and “Run Simulation.”
  4. Export the compiled Rust code and compile with rustc.

Code Health & Issues

  • Tests: 63 test files across backend/, crates/unlinked-*, and frontend/.
  • CI: GitHub Actions (.github/workflows/ci.yml, container.yml) run cargo test and Docker image builds.
  • License: MIT (LICENSE).
  • Observations: No obvious missing tests or CI failures. The frontend contains browser‑tests in frontend/browser-tests/*.py; however, integration tests for the API are absent. No secrets are committed.

The Bottom Line

Unlinked delivers a complete, Rust‑only stack for Simulink model sharing and partial simulation. The codebase is modular, with clear separation between HTTP handling, database access, and simulation logic, making it approachable for a Rust team. The primary limitation is the incomplete simulation coverage and the need for manual setup of OAuth credentials. It is suitable for teams that value open‑source tooling and want to embed Simulink workflows into modern web or Rust environments.