CAITSGet started

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.

FileWhat CAITS does with it
src/backend/<context>/di.tsThe bindings of the context in production: its default export, a list of bind(…)
src/backend/<context>/test.di.tsThe bindings of the tests: they replace those of di.ts
src/backend/<context>/application/<command or query>/<use-case>/<use-case>.dto.tsThe 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.tsThe handler of the use case, built for each DTO, with its dependencies
src/backend/<context>/presentation/<name>/<name>.controller.tsA controller: a route builds it with controller(…)
src/backend/context-map.tsThe context map: the events of a context, and the DTOs that they become
src/backend/shared/di.tsThe bindings that every backend context gets
src/frontend/<context>/di.ts, test.di.tsThe 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.tsThe same as in the backend: a handler of the frontend publishes events, and gives nothing back
src/frontend/<context>/presentation/store/<context>Store.tsThe store of the context: its default export, { initialState, reduce, send }
src/routes/_frontend/…/+page.marko, +layout.markoThe pages and their layouts (Marko Run)
src/routes/_backend/…/+handler.tsThe handlers of the HTTP API (Marko Run): each gives the request to a controller

The rules of the names

WhatThe ruleExample
A use caseOne 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 DTOThe Input DTO extends Input<Output>; in the frontend, Input<void>. One Input DTO in each DTO file.class AddMessageCommand extends Input<AddMessageOutput>
A handlerOne class with execute(input). In the backend, it gives new …Output(…).AddMessageHandler
A portdomain/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 adapterinfra/<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 backenddomain/event/<Name>.ts. It extends DomainEvent.domain/event/MessageAdded.ts
An event of the frontendapplication/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 controllerpresentation/<name>/<name>.controller.ts. It extends Controller<Input, Output>.presentation/add-message-http/add-message-http.controller.ts
A viewpresentation/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 frontendpresentation/<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.

ShortcutWhereIt leads to
#context/In a contextThe files of the same context. The package.json of the context gives it.
#shared/In a backend contextsrc/backend/shared/
#backend/, #frontend/In the routessrc/backend/, src/frontend/
@ingenioz-it/caits/…EverywhereThe 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.

Next pageGlossary The words of CAITS, each with a short definition.