External Standalone Subsystems
Overview: For modular enterprise platforms and plugin ecosystems, Foundry supports External Standalone Subsystems, allowing dynamic discovery and mounting of subsystem directories via
subsystem.jsonmanifests without recompiling the main Rust binary.
1. Directory Structure
Section titled “1. Directory Structure”my-app/├── Cargo.toml├── src/main.rs└── external_systems/ └── analytics/ ├── subsystem.json # Subsystem manifest specification └── custom_pages/ # Sandboxed admin views └── dashboard.html2. Manifest Specification (subsystem.json)
Section titled “2. Manifest Specification (subsystem.json)”{ "slug": "analytics", "display_name": "Analytics Dashboard", "description": "Real-time traffic and conversion insights", "version": "1.0.0", "custom_pages": [ { "key": "dashboard", "title": "Traffic Monitor", "icon": "BarChart3", "page_type": "iframe", "entry": "/api/v1/s/analytics/ext/custom-pages/dashboard.html", "required_role": null } ]}3. Dynamic Discovery in main.rs
Section titled “3. Dynamic Discovery in main.rs”use foundry::prelude::*;use foundry_engine::external::load_external_subsystems;use std::path::PathBuf;
#[foundry::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { let config = FoundryConfig::from_env(); let external_dirs = vec![PathBuf::from("./external_systems")];
let modules = load_external_subsystems(&external_dirs); let mut builder = FoundryApp::builder().config(config);
for m in modules { builder = builder.register_boxed_subsystem(m); }
let app = builder.build().await?; app.run().await?; Ok(())}