Vinova Lab · Engineering

Anatomy of a module

How a Rainty module is made, file by file, with Agenda as the example.

Status: written on 2026-11-04. The reference module does not exist as code yet: this page describes it file by file, with Agenda as the example. The first module to arrive through a challenge becomes the de facto reference, and its review will take longer.

The rules are in the Rainty modules contract; how the work is organised is in the common brief of the module challenges. This page only shows how a module is made, piece by piece. The only module that really exists today is Manual Review (rainty/frontend/modules/manual-review/), and it has only the frontend part.

Identifiers in the code — keys, props, tables, routes — are in Italian, as they are in the repository. Use them as they are.

The pieces

# Piece File Written by
1 Proposal rainty/frontend/modules/agenda/PROPOSTA.md contributor
2 Manifest rainty/frontend/modules/agenda/manifest.ts contributor
3 Page rainty/frontend/modules/agenda/pages/AgendaPage.tsx contributor
4 Components rainty/frontend/modules/agenda/components/*.tsx contributor
5 API client rainty/frontend/modules/agenda/api/agenda.ts contributor
6 Customer-record tab rainty/frontend/modules/agenda/components/TabCliente.tsx contributor
7 Texts rainty/frontend/modules/agenda/i18n/{it,en}.json contributor
8 Registry line rainty/frontend/modules/index.ts contributor
9 Tests rainty/frontend/modules/agenda/test/*.test.ts(x) contributor
10 Catalogue migration backbone-core/db/postgres/migrations/NNN_rainty_agenda_catalogo.sql core team, from the proposal
11 Schema migration backbone-core/db/postgres/migrations/NNN_rainty_agenda_tabelle.sql core team, from the proposal
12 Routes backbone-core/services/data-service/routes/raintyModuli/agenda.js core team, from the proposal
13 Own service (if needed) rainty/services/agenda-service/ contributor

A module that is switched off is invisible: it is not in the menu, its frontend routes redirect to Overview, its API routes answer 403 MODULO_NON_ATTIVO. The module does not check by itself whether it is active: the shell and requireModulo do.

1. The proposal

The first file on the branch. It is one page, written in Markdown, and it lists the tables, the routes, the events and what the module uses from the core. For Agenda, PROPOSTA.md reads like this:

Proposal — Agenda and appointments (agenda)

Schema rainty_agenda

Table appuntamenti (appointments)

Column Type Notes
id uuid key, default gen_random_uuid()
organization_id text required, FK backbone_auth.organization(id)
user_id text who created it, FK backbone_auth.“user”(id)
cliente_id uuid FK rainty.clienti(id)
inizio, fine timestamptz start and end; fine > inizio
tipo text key in tipi
stato text fissato · confermato · svolto · annullato · assente (booked · confirmed · done · cancelled · no-show)
luogo text address or “online”
note text
campi jsonb custom fields of the vertical
created_at, updated_at timestamptz

Indexes: (organization_id, inizio), (organization_id, cliente_id).

Table tipi (appointment types)

Column Type Notes
organization_id text FK
key text key together with organization_id
durata_minuti int duration in minutes

Routes /rainty/agenda/… in data-service

Method Path Input Output
GET /rainty/agenda/appuntamenti da, a, cliente_id, stato list
POST /rainty/agenda/appuntamenti body appointment; event agenda.appuntamento.creato
PATCH /rainty/agenda/appuntamenti/:id fields appointment; event .spostato if start or end change
POST /rainty/agenda/appuntamenti/:id/stato stato appointment; event .svolto · .annullato · .assente
GET /rainty/agenda/tipi list

Timeline events

agenda.appuntamento.creato · spostato · annullato · svolto · assente

Own service

Not in the first version (reminders will come with scheduling and alerting).

What I use from the core

GET /rainty/clienti (customer search in the form), GET /rainty/clienti/:id/timeline (tab).

The core team reviews the proposal against the contract: organization_id everywhere, foreign keys only towards the core, names carrying the module key.

2. The manifest

The only file the shell reads. Types come from @vinovalab/app-shell (ModuloManifest, v0.11.0) and @rainty/nucleo (PropsPaginaModulo).

import { lazy } from "react";
import type { ModuloManifest } from "@vinovalab/app-shell";
import type { PropsPaginaModulo } from "@rainty/nucleo";

export const manifest: ModuloManifest<PropsPaginaModulo> = {
  key: "agenda",
  versioneContratto: 1,
  tipo: "menu",
  dipendenze: ["nucleo"],
  rotte: [{ id: "agenda", pagina: lazy(() => import("./pages/AgendaPage")) }],
  menu: [{ id: "agenda", etichetta: "agenda.menu", icona: "mdi:calendar-outline", ordine: 30 }],
  schedaCliente: [{ id: "agenda", titolo: "agenda.tab", componente: lazy(() => import("./components/TabCliente")) }],
  eventi: [
    "agenda.appuntamento.creato",
    "agenda.appuntamento.spostato",
    "agenda.appuntamento.annullato",
    "agenda.appuntamento.svolto",
    "agenda.appuntamento.assente",
  ],
  i18n: { it: () => import("./i18n/it.json"), en: () => import("./i18n/en.json") },
};
  • key is the catalogue key. menu[].section defaults to "main"; use "avanzate" for advanced features at the bottom of the menu.
  • etichetta (label) and titolo (title) are i18n keys, never text.
  • Everything visual is lazy: a module that is switched off is never downloaded.
  • strumentiAgente (agent tools) and impostazioni (settings) are added when needed; not in the first version.

3. The page

Thin, as rainty/AGENTS.md says: it loads the data, holds the state, composes the components. It receives Layout from the shell and uses it the way the other pages do.

import { useTranslation } from "react-i18next";
import type { PropsPaginaModulo } from "@rainty/nucleo";
import { useAppuntamenti } from "../hooks/useAppuntamenti";
import { Calendario } from "../components/Calendario";
import { FormAppuntamento } from "../components/FormAppuntamento";

export default function AgendaPage({ Layout, navItems }: PropsPaginaModulo) {
  const { t } = useTranslation();
  const agenda = useAppuntamenti();
  return (
    <Layout navItems={navItems} titolo={t("agenda.menu")}>
      <Calendario appuntamenti={agenda.elenco} stato={agenda.stato} onSeleziona={agenda.apri} />
      {agenda.aperto && <FormAppuntamento valore={agenda.aperto} onSalva={agenda.salva} onChiudi={agenda.chiudi} />}
    </Layout>
  );
}

One component per file, with typed props; components do not fetch. Before writing one, look at the design system (Card, Badge, Button, DataTable, EmptyState, ModalShell…) and use what is there.

4. The API client

One module per data-service route, inside the module folder, built on @rainty/api. Never fetch in components, never datahub.

import { api } from "@rainty/api";

export type Appuntamento = { id: string; clienteId: string; inizio: string; fine: string; tipo: string; stato: string; luogo?: string; note?: string };

export const elencaAppuntamenti = (q: { da: string; a: string; clienteId?: string }) =>
  api.get<Appuntamento[]>("/rainty/agenda/appuntamenti", { params: q });
export const creaAppuntamento = (corpo: Omit<Appuntamento, "id" | "stato">) =>
  api.post<Appuntamento>("/rainty/agenda/appuntamenti", corpo);

Today Manual Review imports its client through a relative path into UserInterface/src/api/: that is the old form, not to be copied. The right form is this one, and the import-boundary checks in CI will enforce it.

5. The customer-record tab

Registered in schedaCliente. It receives clienteId and the active organisation and loads its own data: it is the only exception to the rule “components do not fetch”, because the customer record is composed by the shell, not by a page of the module.

export default function TabCliente({ clienteId }: { clienteId: string }) {
  const { prossimi, passati, stato } = useAppuntamentiCliente(clienteId);
  …
}

6. The texts

i18n/it.json and i18n/en.json with the same tree, and a namespace equal to the module key. The English file:

{ "agenda": { "menu": "Agenda", "tab": "Appointments", "nuovo": "New appointment", "stato": { "fissato": "Booked", "svolto": "Done" } } }

Every text the user reads goes through t(): labels, buttons, placeholders, error messages. Dates and numbers through localeOf(i18n.language).

7. The registry

One line in rainty/frontend/modules/index.ts, in alphabetical order. It is one of the three places shared between modules; a conflict, if it happens, is trivial.

import { manifest as agenda } from "./agenda/manifest";
import { manifest as manualReview } from "./manual-review/manifest";
import { manifest as ricerca } from "./ricerca/manifest";

export const manifestModuli = [agenda, manualReview, ricerca];

8. The tests

  • Conformance (test/manifest.test.ts): the manifest has the right shape, the i18n keys exist in both it and en, nothing is imported from frontend/modules/<other>/. The model is frontend/modules/index.test.ts.
  • Components: with @testing-library/react, asserting on the text translated through the tests’ t(), not on hard-coded Italian strings.
  • Hooks: with a fake API client.

9. The migrations

Written by the core team from the proposal, in backbone-core/db/postgres/migrations. They touch only the module’s schema and its row in the catalogue; numbers may repeat, because the runner applies migrations by full name.

-- NNN_rainty_agenda_catalogo.sql
INSERT INTO rainty_licenze.moduli (key, tipo, dipendenze, attivo)
VALUES ('agenda', 'menu', '{nucleo}', true)
ON CONFLICT (key) DO NOTHING;
-- NNN_rainty_agenda_tabelle.sql
CREATE SCHEMA IF NOT EXISTS rainty_agenda;

CREATE TABLE IF NOT EXISTS rainty_agenda.appuntamenti (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  organization_id text NOT NULL REFERENCES backbone_auth.organization(id),
  user_id text NOT NULL REFERENCES backbone_auth."user"(id),
  cliente_id uuid NOT NULL REFERENCES rainty.clienti(id),
  inizio timestamptz NOT NULL,
  fine timestamptz NOT NULL CHECK (fine > inizio),
  tipo text NOT NULL,
  stato text NOT NULL DEFAULT 'fissato',
  luogo text,
  note text,
  campi jsonb NOT NULL DEFAULT '{}',
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS appuntamenti_org_inizio ON rainty_agenda.appuntamenti (organization_id, inizio);

An applied migration is never edited: corrections are a new migration.

10. The routes

Written by the core team in routes/raintyModuli/agenda.js, mounted by raintyModuli/index.js under /rainty/agenda before the existing /rainty router. Thin: user and organisation come from the login (creaContestoRainty, the same as /rainty/clienti), then requireModulo, reads and writes through datahub, and the timeline event in the same operation (creaTimeline(...).scriviEvento, modules/timelineRainty.js). The response is { ok: true, data }, which @rainty/api unwraps.

"use strict";
const { Router } = require("express");

// datahub: datahubHttp from server.js (get/post/patch towards datahub).
// contesto: creaContestoRainty({ table }). timeline: creaTimeline({ datahub }).
module.exports = function agendaRouter({ logger, datahub, contesto, timeline }) {
  const router = Router();

  router.get("/appuntamenti", async (req, res, next) => {
    try {
      const ctx = await contesto(req);
      const { data } = await datahub.get("/api/table/rainty_agenda.appuntamenti", {
        params: { organization_id: ctx.organization.id, inizio_gte: req.query.da, inizio_lte: req.query.a, limit: 500 },
      });
      res.json({ ok: true, data: data.data ?? data });
    } catch (e) { next(e); }
  });

  router.post("/appuntamenti", async (req, res, next) => {
    try {
      const ctx = await contesto(req);
      const corpo = { ...req.body, organization_id: ctx.organization.id, user_id: ctx.userId };
      const { data } = await datahub.post("/api/table/rainty_agenda.appuntamenti", corpo);
      const creato = data.data ?? data;
      await timeline.scriviEvento({
        tipo: "agenda.appuntamento.creato", clienteId: creato.cliente_id,
        attore: { tipo: "utente", id: ctx.userId },
        riferimento: { tipo: "appuntamento", id: creato.id },
        sintesi: "Appointment booked", dati: { inizio: creato.inizio },
      }, { organizationId: ctx.organization.id });
      res.status(201).json({ ok: true, data: creato });
    } catch (e) { next(e); }
  });

  return router;
};
// routes/raintyModuli/index.js — one line per module, in alphabetical order
const MODULI = {
  agenda: require("./agenda"),
};

index.js (backbone-core, data-service) mounts every entry of MODULI on /rainty/<key> with withUser and requireModulo(key), before the core’s /rainty router, and passes the router its dependencies { logger, datahub, contesto, timeline }. At startup it rejects a key that does not have the catalogue’s shape (^[a-z][a-z0-9-]*$) or that matches a core prefix (clienti, posta, documenti, tasks, …: the PREFISSI_DEL_NUCLEO list is kept in line with the sources by a test). A module that is not registered does not exist: /rainty/<key>/… answers 404.

Today the requireModulo check is requireModuloDaVista(http, key) from @vinovalab/backbone-shared/entitlements: it reads the v_moduli_effettivi view through datahub. A route without the check does not pass review.

11. The module’s own service

Only if the module has asynchronous work, queues, workers or external integrations. It lives in rainty/services/<key>-service/, with /status/health, a healthcheck and release.json like the other services, and it reads and writes only through data-service. Before doing work for a user it checks that the module is active for that user. Agenda has none in the first version.

What is already in place

  • 2026-11-04: @rainty/api (rainty PR #7); rainty.clienti, the timeline and the /rainty/clienti routes (backbone-core PR #10); the customer record that mounts the schedaCliente tabs of the active modules and TimelineCliente (rainty PR #8). The minimal core is in the development environment.
  • 2026-11-05: the routes/raintyModuli skeleton in data-service (backbone-core PR #12) and the module checks in CI (rainty PR #9).