Skip to main content

Project structure

You write code in two folders: Services for the server and Controllers for the client. Everything else is set up and kept current by the CLI.

The tree​

my-game/
├── default.project.json where each folder goes in Studio
├── rokit.toml pins the Rojo version (rokit install)
├── selene.toml linter settings
├── sourcemap.json generated for autocomplete, git-ignored
├── .gitignore
├── .vscode/settings.json Luau-LSP settings
├── loren/ the Loren runtime (loren update replaces it)
│ ├── shared/
│ └── server/
├── loren_packages/
│ └── Promise/ bundled, the runtime needs it
└── src/
├── shared/
│ ├── Loren.luau the shim you require
│ └── LorenTypes.luau generated
├── server/
│ ├── Server.server.luau
│ ├── LorenServerTypes.luau generated
│ └── Services/
│ └── ExampleService.luau
└── client/
├── Client.client.luau
└── Controllers/
└── ExampleController.luau

Where things land in Studio​

With Rojo or Argon, default.project.json maps each folder to a place in Studio:

FolderIn StudioWhat it is
src/sharedReplicatedStorage.SharedCode both sides can require, plus the shim
loren_packagesReplicatedStorage.LorenPackagesPackages from loren add, and Promise
loren/sharedReplicatedStorage.LorenRuntimeThe runtime both sides run
src/serverServerScriptService.ServerYour server bootstrap and Services
loren/serverServerScriptService.LorenServerThe server-only runtime. Clients never get it.
src/clientStarterPlayer.StarterPlayerScripts.ClientYour client bootstrap and Controllers

With Script Sync the folders on disk already have those names. The one difference is that the runtime sits inside the synced folders: ReplicatedStorage.Shared.LorenRuntime and ServerScriptService.Server.LorenServer.

When the server boots, it also creates ReplicatedStorage.LorenNet: a Folder with a State attribute and two remotes, Reliable (a RemoteEvent) and Unreliable (an UnreliableRemoteEvent). Loren sends everything through those two. Leave them alone.

The shim​

Your code requires Loren from the same place as in 1.5.1:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Loren = require(ReplicatedStorage.Shared.Loren)

Shared/Loren.luau is a shim: a six-line module that finds the real runtime (LorenRuntime next to it, or in ReplicatedStorage) and returns it. Don't edit it. loren update rewrites it, and loren doctor complains if it changed.

Services and Controllers​

Put Services in Services/ and Controllers in Controllers/. loren make creates them there:

loren make service ShopService
loren make controller ShopController

The bootstrap registers the direct children of each folder. A ModuleScript inside a sub-folder is skipped, and Studio shows a warning that names it. To register those too, pass { Recursive = true }:

src/server/Server.server.luau
Loren.AddServices(script.Parent.Services, { Recursive = true })

A Service and a Controller can't share a name. loren make refuses it, because the two would clash in Dependencies.

Generated type files​

LorenTypes.luau (shared) and LorenServerTypes.luau (server only) list the names of your Services and Controllers as Luau types. They give you autocomplete and typo checks in Dependencies. They hold no code: each one ends with return table.freeze({}).

loren make, inject, add, refresh, types and update rewrite them, so don't edit them. Using them is optional. See Dependencies for the pattern.

Packages and premades​

  • loren add user/repo downloads a GitHub repository into loren_packages/<Name>. Require it with require(ReplicatedStorage.LorenPackages.<Name>). Promise is bundled, and loren add refuses to replace loren_packages/Promise unless you pass --force (the runtime needs it).
  • loren inject copies a premade (a ready-made module) into your project. It looks in your own loren_premade/services, loren_premade/controllers and loren_premade/shared folders first, then in the premades that ship with the CLI. New projects don't have a loren_premade/ folder. Create one if you want your own premades.

Backups​

.loren-backup/ appears the first time the CLI replaces something: loren update, loren migrate, loren doctor --fix, or any --force. Each run gets a timestamped folder with the old files at their old paths. It's git-ignored. Delete it when you don't need it.

Next​

Your first service.