Engines
Engines are mini-applications that can be mounted at specific URL paths. Each engine has its own controllers, models, views, routes, and migrations—completely isolated from the main application.
Why Engines?
Build modular architectures, plugin systems, or simply organize code into self-contained units that can be reused across projects.
Engine Structure
engines/shop/
├── engine.sl # Engine manifest
├── app/
│ ├── controllers/
│ ├── models/
│ ├── views/
│ └── helpers/
├── config/
│ └── routes.sl # Engine-specific routes
└── db/
└── migrations/ # Engine-specific migrations
Engine Manifest
Each engine has a manifest file engine.sl:
engine "shop" {
version: "1.0.0",
dependencies: []
}
Routes
Engine routes are relative to their mount point. If mounted at /shop, a route get("/products", "shop#products") responds to GET /shop/products.
get("/", "shop#index")
get("/products", "shop#products")
get("/products/:id", "shop#product_detail")
Mounting Engines
Define engines in config/engines.sl:
mount "shop", at: "/shop"
mount "blog", at: "/blog"
Template Engine Integration
When you call render("shop/index", data), the template engine first checks app/views/shop/index.html.slv, then engines/shop/app/views/shop/index.html.slv. This lets engines extend views while maintaining their own view directory.
Creating Engines
Use the scaffold generator to create a new engine:
soli engine create shop
File Resolution
| File Type | Main App | Engine |
|---|---|---|
| Controllers | app/controllers/ | engines/<name>/app/controllers/ |
| Models | app/models/ | engines/<name>/app/models/ |
| Views | app/views/ | engines/<name>/app/views/ |
| Routes | config/routes.sl | engines/<name>/config/routes.sl |
| Migrations | db/migrations/ | engines/<name>/db/migrations/ |