The project
This page describes a TypeScript game. A Luau game has the same shape in Luau’s names (src/features/<feature>/server/, and the same four layers), with plain modules for services and controllers and remotes declared with Remo: see Luau games.
Where code goes
Section titled “Where code goes”Code in src/ sits in four layers, and imports only go down:
app/: the entry scripts:server/main.server.tsandclient/main.client.tsstart Flamework. It may import every layer.features/<feature>/: what the game could ship without, such as a shop or a season.mise run feature <name>writes the first. It may importgame,platformand other features, but never in a cycle between feature folders.game/<system>/: the always-on systems: the one receipt handler, the player’s saved data, what features build on, concepts several features write. It never imports a feature orapp.platform/<module>/: game-agnostic Roblox code that would move unchanged to another game. It imports none of the others.
To tell a feature from a system, delete the folder: if the game still works it was a feature. The children of game/ and platform/ are named folders, with no loose files and no util(s) or lib(s). Inside a feature or module, and in app/, the folder a file sits in decides where it runs:
server/: only on the server, never sent to clients.client/: only on the player’s device.shared/: both. It can’t import server or client code.
Side folders sit only at app/<side>/ and <layer>/<module>/<side>/. mise run check fails on anything else: ESLint on an import that goes up, the source check on a cycle between features, a file outside a side folder or a folder under src/ that is no layer, each with the next move in its message.
Code meets in three ways: a direct import by default; a registry in game/ when one owner has many contributors (the one ProcessReceipt handler, with the features registering their product handlers), so game/ never imports a feature; and a typed signal the emitter exports, for a fact others react to. Never a string-keyed event bus.
Adding a feature
Section titled “Adding a feature”mise run feature <name> writes the first two steps, the service’s spec and the end-to-end test: the network file, a service, a controller, their imports in the entry scripts, and tests/e2e/<name>.luau, which sends the feature’s request through the real server. In a multi-place game the feature goes in the shared code; mise run feature <name> <place> keeps it to one place. The add-feature skill walks an agent through the rest.
- Network events in
shared/<feature>-network.ts. - A Flamework service in
server/and, if the client takes part, a controller inclient/. Import each in the matchingmainfile. - UI as a React component in
client/, with a story. - A spec for the service, and an end-to-end test for each request a client sends. The check fails on a service with no spec, a feature with remotes and no end-to-end test, and a component with no story.
The rules
Section titled “The rules”- Never trust the client. Clients ask; services decide, and check every request.
mise run checkfails on a client-to-server event or function the server takes without middleware: give it the template’srateLimitmiddleware (src/platform/network/server/rate-limit.ts;rateLimitFunctionfor a function), or mark its handler// trusts-client: <why>. A rate limit is a floor; the service still checks the request. - Services own server state. Other code calls their methods.
- Controllers run the client side and keep what the UI shows.