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.rsstarts by readingbackend/src/config.rsfor env variables (DATABASE_URL,SESSION_SECRET, etc.) and creates a Diesel connection pool (backend/src/db.rs). - Router construction:
backend/src/handlers/mod.rsre‑exports sub‑modules (auth,files,projects,simulations,simulation_socket,health). Each handler defines routes viaaxum::routing::Router. - File handling:
backend/src/handlers/files.rscallsbackend/src/access.rsfor permission checks and interacts withbackend/src/models.rsto read/write file blobs stored in PostgreSQL. - Simulation orchestration:
backend/src/handlers/simulations.rsqueues a run, spawns a background task inbackend/src/sim_worker.rs, which uses the in‑memory data model frombackend/src/models.rsand the simulation engine incrates/unlinked-sim/src/lib.rs. The worker streams results over the WebSocket defined inbackend/src/handlers/simulation_socket.rs. - Authentication:
backend/src/auth.rsimplements Google/GitHub OAuth viabackend/src/oauth.rs, creating session records inbackend/src/session.rs. - Front‑end entry:
frontend/src/api.rswraps the HTTP endpoints,frontend/src/diagram.rsrenders the SVG viafrontend/src/diagram.rs, andfrontend/src/diagnostics_worker.rsconnects 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:
- Commit
.mdlto Git. - Run
cargo run -p unlinked-cli -- import .mdl. - Open the model in the UI, tweak a parameter, and “Run Simulation.”
- Export the compiled Rust code and compile with
rustc.
Code Health & Issues
- Tests: 63 test files across
backend/,crates/unlinked-*, andfrontend/. - CI: GitHub Actions (
.github/workflows/ci.yml,container.yml) runcargo testand Docker image builds. - License: MIT (
LICENSE). - Observations: No obvious missing tests or CI failures. The
frontendcontains browser‑tests infrontend/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.