# Intent.Modelers.UI

This Intent Architect module provides the **User Interface** designer, for describing a frontend's intention and structure: its screens and where content is placed in them, how users navigate, which client modules and APIs each screen depends on, the data shapes it uses, and where each element is implemented.

The designer models **what** a UI is for, not **how** it is built. There are no view trees, controls, bindings or mappings. Code is written from the model, from each element's comment and from the skills of a framework module (Vue, Angular, React, Blazor and so on). The designer is framework- and language-agnostic: it models general UI concepts that apply in any stack. Only what is truly unique to one framework or language is added, by the framework modules that extend this designer.

## Element types

| Element | What it is | Children |
| --- | --- | --- |
| **Layout** | An app shell or window | Region, Component Operation |
| **Page** | A screen. Carries the Page stereotype (Route, Title); the Route is optional | Region, Property (route and query parameters), Component Operation, Contract |
| **Dialog** | A modal or overlay screen | Region, Property (inputs), Event Emitter (results), Component Operation, Contract |
| **Component** | A reusable piece of UI rendered inside others | Region, Property (inputs), Event Emitter (outputs), Component Operation, Contract |
| **Region** | A named placement point in a Layout, Page, Dialog or Component, such as "Main", "Side Panel" or "Toolbar" | none |
| **Store** | Shared client state (a Pinia or Redux store, a stateful service) | Property (state fields) |
| **View Model** | A stateful class one element creates for its own use rather than sharing it: a view model, a presenter, a tree node, the state behind a control | Property (state other elements read) |
| **UI Service** | Reusable client logic with no UI (a composable, hook or injectable service). Not an API client: that is a Proxy | none |
| **Utility** | A module of pure functions or a static helper | none |
| **Background Process** | Code that runs in its own execution context and exchanges messages with the UI: a Web or Service Worker, an Electron main process, a Tauri backend, a VS Code extension host, a separate agent process | none |
| **Behaviour** | Reusable behaviour attached to an existing element that renders no UI of its own: a Vue or Angular directive, a Svelte action, a React hook bound to a ref, a WPF attached behaviour | none |
| **App Event** | An app-wide message that any element can publish or subscribe to (an event bus event, an RxJS Subject, a Redux action, an IPC channel) | Property (optional payload) |
| **Proxy** | An API client, with an optional Base URL | Proxy Operation |
| **Proxy Operation** | One client method, with parameters and an optional return type | Parameter |
| **Contract** | A client-side data shape | Property |
| **Enum** | A set of named values (from Common Types) | Enum Literal |

A Store's Properties describe the state it holds, typed as a basic type, Enum, Contract or DTO. Its actions and getters are not modelled; describe them in its comment. Apply **Persisted** to a Store whose state is saved and restored across restarts, such as user preferences in local storage or a settings file, and say in its comment where it is saved and at what scope.

A View Model is state that belongs to the element that creates it, usually with `new`, and lives as long as that element needs it. The elements that create or use it have a Uses to it. State shared across the UI is a Store, and reusable logic with no state of its own is a UI Service. Add Properties only for the state other elements read, and describe its methods, who creates it and how long it lives in its comment.

A **Component Operation** is a named action, such as "Save" or "Refresh". It can take Parameters, return a type, and hold Invocations of other operations. Write a behavioural comment on every Layout, Page, Dialog and Component: it is the main context code is written from.

Convert to type changes an element between Component, Page and Dialog.

Every element type can be created directly under the package or in a folder. As a convention, keep only the app shell and app-wide client modules, such as a theme or session store, at the root, and put everything else in folders named for the feature area.

## Associations

| Association | From | To |
| --- | --- | --- |
| **Navigation** | Layout, Page, Dialog, Component, Component Operation | Page |
| **Composition** | Layout, Page, Dialog, Component, Region | Component; Page or Dialog only from a Region |
| **Show Dialog** | Layout, Page, Dialog, Component, Component Operation | Dialog |
| **Call Service Operation** | Layout, Page, Dialog, Component, Component Operation, Store, View Model, UI Service, Utility, Behaviour, Background Process, Proxy Operation | A backend operation in the Services designer, or a Proxy Operation |
| **Uses** | Layout, Page, Dialog, Component, Store, View Model, UI Service, Utility, Behaviour, Background Process | Store, View Model, UI Service, Utility, Behaviour, Proxy |
| **Publishes** | Layout, Page, Dialog, Component, Store, View Model, UI Service, Utility, Behaviour, Background Process | App Event |
| **Subscribes** | Layout, Page, Dialog, Component, Store, View Model, UI Service, Utility, Behaviour, Background Process | App Event |

A Behaviour is applied to the element it attaches to with a Uses from that element (the Layout, Page, Dialog or Component), the same association as for any other client module.

An App Event is not an Event Emitter. An Event Emitter is an output of a Dialog or Component that only its parent binds to; an App Event is broadcast app-wide, and any element can publish or subscribe to it without knowing the others. Its payload, when it has one, is its Properties. Comment each App Event with when it is raised. On a diagram it is drawn as a card listing its payload. Publishes and Subscribes are both dotted rose lines: Publishes has its arrowhead at the event, and Subscribes has its arrowhead at the subscriber.

A Background Process talks to the UI through App Events, never through Uses: nothing imports it. Add one only when the app has one, and describe in its comment what it does, what starts it and how long it lives. Asynchronous work that shares the UI's state, such as a timer, a promise or a task on the UI's own thread pool, is not a Background Process.

Apply **Entry** to a Composition when the placed element is presented as a tab, activity bar item, side-panel switcher or menu entry. Set only the fields that apply: the **Label** the user sees (leave it empty when it is the element's name), the **Icon** identifier the code uses, the keyboard **Shortcut** that opens it, and the **Key** the code opens or selects it by. It sits on the Composition, not the element, because the same element can be placed in several places under different labels.

On a diagram, every element is drawn as a card outlined in its type's accent colour, with its members listed below the header. The header shows the icon, then the name on the first line and the «type» on the second. A Page's Route or a Proxy's Base URL follows the «type» on that line, and the card widens to fit the full name and detail. Each member row shows its name (an operation's with its parameters) on the left and its type on the right. Each Component, Page or Dialog it composes appears as a tile inside it, or inside the Region that composes it, so a screen's structure can be read without following lines.

A Dialog's tile has an inner frame, so it can be told apart from a Page's. Regions are drawn as lightly shaded boxes with an uppercase label, side by side in their order within the host element, sharing its width (a Region with more tiles gets more of it) and resizing with it. When the host is too narrow for every Region to fit a tile, they stack vertically at its full width instead. Drag them in the model tree to reorder them. The Compositions inside a Region can be reordered the same way, and its tiles follow.

A Contract is drawn as a card listing its properties, so the shapes a Proxy sends and receives can sit beside it.

## Routes

A Page's Route is what the page is mounted at, using `{param}` placeholders (`/products/{id}`). It is optional, for pages that are application states with no URL. When present it must start with `/`. The designer never sets or rewrites it; a framework module may give a new Page a default Route, require one, or translate it to its own syntax.

## Reaching an API

| | Model | Data shapes |
| --- | --- | --- |
| **Intent backend, no client modelled** | Call Service Operation straight to the backend operation | The backend's DTOs |
| **Intent backend, client modelled** | A Proxy whose Proxy Operations each call one backend operation; screens call the Proxy Operations | DTOs, or Contracts where the client defines its own |
| **API not modelled in Intent** | A Proxy whose Proxy Operations carry the HTTP Request stereotype (Verb, Route) | Contracts |

A Proxy Operation may call at most one backend operation, and needs a Verb and Route only when it calls none. When it does call one, its signature is compatible rather than identical: parameters match by position; a Contract matches a DTO when every Contract field exists on the DTO (by name, ignoring case); one Contract parameter may stand for the backend's scalar query parameters when its fields match them by name; and the return type is the same DTO or a Contract whose fields all exist on it. Framework modules check this against the code.

To call a backend operation, reference the backend Services package with **Connect to Service(s)** on the User Interface package.

## Stereotypes

| Stereotype | Applies to | Properties |
| --- | --- | --- |
| **Page** | Page (applied automatically) | Route, Title |
| **Persisted** | Store | none |
| **Entry** | Composition (its target end) | Label, Icon, Shortcut, Key |
| **Implementation** | Any element whose type implements `[Implementable]` | Path (only when the file breaks the framework's convention), Owned Files |
| **Secured** | Any element whose type implements `[UI Element]` | Roles, Policy |
| **HTTP Request** | Proxy Operation | Verb, Route |
| **Base URL** | Proxy | Url |

## Building a framework module on this designer

Every association end above targets a **trait**, so a framework module's own element types join them by implementing the trait:

| Trait | Grants |
| --- | --- |
| `[UI Element]` | Source of Navigation, Composition and Show Dialog; can be Secured |
| `[Region Host]` | Can contain Regions |
| `[Placeable]` | Target of Composition |
| `[Service Caller]` | Source of Call Service Operation |
| `[Dependent]` | Source of Uses |
| `[Usable]` | Target of Uses |
| `[Event Participant]` | Source of Publishes and Subscribes |
| `[Implementable]` | Can carry the Implementation stereotype |

A framework module can:

- add element types to the User Interface designer from a Designers Folder whose Designer Settings extend "User Interface", implementing the core traits they need;
- extend core types with stereotypes, AI rules, validation and child types;
- add its own traits to core types through element extensions, so core types can take part in the framework module's own associations.

Each trait generates an interface (`IServiceCallerModel`, `IUsableModel` and so on) in `Intent.Modules.Modelers.UI.Api`. Module Builder writes these by short name without a `using`, so a module implementing a core trait needs `global using Intent.Modules.Modelers.UI.Api;`. Read Implementation and Secured with the extension methods on `IHasStereotypes` (`GetImplementation()`, `HasImplementation()`, `TryGetImplementation()`, and the same for Secured), which work for core and framework elements alike.

## Upgrading from 1.x

Version 2 removes the view, view-mapping and layout-library concepts of 1.x. Operation signatures and their mappings are kept. Screens and the fixed Layout regions are converted when the module updates; the rest is not:

- Framework modules built on this designer must be on a version that supports 2.0, such as Intent.Blazor 3.0 or later. Follow their own upgrade notes.
- Existing pages and dialogs are converted when the module updates. A Component carrying the Page stereotype becomes a Page, keeping its Route and Title; one carrying the Dialog stereotype becomes a Dialog, and the stereotype is removed. Both keep their ids, so Navigations, Show Dialogs and diagrams that point at them still resolve. The Composable stereotype is removed from every element.
- Convert to type (between Component, Page and Dialog) refuses an element that still holds a child of a removed type, such as a Component View. Delete those children first.
- The fixed Layout regions (Layout Header, Sider, Body, Footer and Profile Menu) are converted to Regions when the module updates, keeping their name and id. A Region is a user-named placement point, so the name is what now says which region it is: a `Layout Header` named "Header" becomes a Region named "Header".
- Component Operation parameters, Invocations, Returns and the Invocation, Call Service and Call Service Response mappings all carry over: they keep the definitions and ids they had in 1.x, so they load and validate as they did before.
- Component Views and their controls, and the view mappings that bound them (View Binding and the layout bindings), stay in the package files with no definition. The Software Factory runs over them, but editing an element that still carries an orphaned mapping can raise errors in the designer, so remove them before you carry on modelling.
- Model Definitions load as Contracts and keep any operations they had; remove them.
- Properties typed as a Command or Query are no longer valid. Retype them, or use Call Service Operation.
- Show Dialog is now defined in this module with new ids. Show Dialog associations created with Intent.Modelers.UI.Core resolve only while that module is installed.
