docs / Getting Started / Multi-File Projects

Multi-File Projects

Programs can span multiple .mi files. The compiler discovers, parses, and links all files in a project automatically. Local files are imported using the local prefix, with the path mapping directly to the file system relative to the project root.

// models/user.mi
use system.io

class User
    public name String

    fn init(n String)
        self.name = n

    public fn greet()
        println(f"Hello, {self.name}")

// main.mi
use local.models.user

fn main()
    let u = User(n: "Alice")
    u.greet()

Compile and run multi-file projects the same way — point the compiler at your entry file and it resolves all dependencies:

./target/release/miri run main.mi