Files and names
CAITS finds the parts of the app by the place and the name of their files: you register nothing. This page lists the files that CAITS reads, and the names that the architecture rules check. When a handler is never called, or a view finds no frontend, look here first.
The files that CAITS finds
The Vite plugin of CAITS reads these files when it builds the app. <context> is the folder of a context.
| File | What CAITS does with it |
|---|---|
src/backend/<context>/di.ts | The bindings of the context in production: its default export, a list of bind(…) |
src/backend/<context>/test.di.ts | The bindings of the tests: they replace those of di.ts |
src/backend/<context>/application/<command or query>/<use-case>/<use-case>.dto.ts | The Input DTO of a use case: the message bus routes it to its handler |
src/backend/<context>/application/<command or query>/<use-case>/<use-case>.handler.ts | The handler of the use case, built for each DTO, with its dependencies |
src/backend/<context>/presentation/<name>/<name>.controller.ts | A controller: a route builds it with controller(…) |
src/backend/context-map.ts | The context map: the events of a context, and the DTOs that they become |
src/backend/shared/di.ts | The bindings that every backend context gets |
src/frontend/<context>/di.ts, test.di.ts | The same as in the backend, for a context of the frontend |
src/frontend/<context>/application/<command or query>/<use-case>/<use-case>.dto.ts, .handler.ts | The same as in the backend: a handler of the frontend publishes events, and gives nothing back |
src/frontend/<context>/presentation/store/<context>Store.ts | The store of the context: its default export, { initialState, reduce, send } |
src/routes/_frontend/…/+page.marko, +layout.marko | The pages and their layouts (Marko Run) |
src/routes/_backend/…/+handler.ts | The handlers of the HTTP API (Marko Run): each gives the request to a controller |
The rules of the names
| What | The rule | Example |
|---|---|---|
| A use case | One folder for each, in command/ (it changes something) or query/ (it reads). The folder holds one DTO file, one handler file, and its test. | command/add-message/add-message.dto.ts |
| A DTO | The Input DTO extends Input<Output>; in the frontend, Input<void>. One Input DTO in each DTO file. | class AddMessageCommand extends Input<AddMessageOutput> |
| A handler | One class with execute(input). In the backend, it gives new …Output(…). | AddMessageHandler |
| A port | domain/port/<port>/<Port>.ts: the interface and its token, with the same name, and nothing else. Its contract is next to it, <Port>.contract.ts. | domain/port/message-repository/MessageRepository.ts |
| An adapter | infra/<port>/<adapter>-<port>.ts: the folder has the name of the port. Its test runs the contract. | infra/message-repository/file-message-repository.ts |
| An event of the backend | domain/event/<Name>.ts. It extends DomainEvent. | domain/event/MessageAdded.ts |
| An event of the frontend | application/event/<Name>.ts, with readonly type = "<context>.<name>" as const: the name of the class in kebab case, without the name of the context. One event in each file, and all of them in the union <Context>Event.ts. | MessageAdditionRequested → "messages.addition-requested" |
| A controller | presentation/<name>/<name>.controller.ts. It extends Controller<Input, Output>. | presentation/add-message-http/add-message-http.controller.ts |
| A view | presentation/view/<view>/<View>.marko, with its test, its stylesheet, its presenter and its loader in the same folder. | presentation/view/message-board/MessageBoard.marko |
| The type of a frontend | presentation/<Context>Frontend.ts. It adds the context to Frontends, with the name of its folder. | presentation/MessagesFrontend.ts |
The shortcuts of the imports
No import goes up a folder (../), the tests included: an import does not change when its file moves.
| Shortcut | Where | It leads to |
|---|---|---|
#context/ | In a context | The files of the same context. The package.json of the context gives it. |
#shared/ | In a backend context | src/backend/shared/ |
#backend/, #frontend/ | In the routes | src/backend/, src/frontend/ |
@ingenioz-it/caits/… | Everywhere | The code of CAITS, by its name, never by a path |
A stylesheet loads the files of its folder, of the folders below, and the partials of src/routes/_frontend/style/ by their name. See Write the styles.