Product and UI boundaries
Status: working contract. These boundaries guide new work; existing Rails files have not yet been reorganized. The application remains one Rails monolith.
Responsibilities
Section titled “Responsibilities”| Area | Owns | Must not own |
|---|---|---|
| Core | Tenants, resources, recipients, selections, snapshots, dispatches, deliveries, ledger and their invariants. | Incident workflows, presentation, SMS-provider details. |
| Visitor Incident Management | Visits, presence, incidents, product authorization and workflows; invokes Core operations. | Core persistence internals or provider protocols. |
| SMS channel | Provider integration, normalization, transport attempts, callbacks and reconciliation. | Visitor or incident business rules. |
| Product presentation | Staff and kiosk pages, input presentation, product-specific UI and mapping application results to HTML. | Database queries, authorization decisions, provider calls or Core invariants. |
| Shared UI | Design tokens, generic controls, layouts and accessibility behavior. | Tenant, visit, incident or SMS business rules. |
The staff application uses product language. A location is presented by the product and represented as a Core resource. A kiosk uses a separate shell and access flow from staff, while sharing suitable generic UI primitives.
Dependency direction
Section titled “Dependency direction”Presentation invokes authenticated, authorized application operations or read queries. Product application operations invoke Core through explicit interfaces. Core never imports product presentation or incident code. Core interacts with channels through an explicit contract; a provider adapter remains behind that contract. Shared UI is used by presentation and has no dependency on Core or product-domain objects. Pass display values into components, not Active Record objects that they query or mutate.
Controllers orchestrate identity, authorization, tenant context and application calls. Templates, partials and UI components do not call Active Record, invoke external services or implement authorization. Database RLS is defense in depth; it does not establish a user’s membership or permission. A request parameter or job argument alone is not proof of authorization. Jobs establish their own verified tenant context and use application operations.
These boundaries apply to both writes and reads. A query object may retrieve only the data authorized for a use case and returns a presentation-ready result; it must not expose unrestricted database relations to views. Do not introduce a public API, package framework or cross-product abstraction before a real need.
Intended organization
Section titled “Intended organization”This is a target layout, not a claim that the current repository already has
these directories. Introduce paths when their first real code is added; migrate
the existing Tenant, Resource and TenantContext deliberately, with tests,
instead of duplicating them or breaking the running application.
apps/web/app/ core/ # domain and application interfaces products/visitor/ # visit and incident workflows and read queries channels/sms/ # channel contract implementation and adapter controllers/visitor/ # staff and kiosk request entry points views/visitor/ # product-specific pages and compositions components/ui/ # generic, reusable presentation primitives assets/ # shared tokens, styles and product assetsRails autoload paths, namespacing and persistence boundaries must be verified when implementing this structure. Kiosk and staff routes, layouts and sessions must be explicitly separated; do not assume a kiosk has staff privileges.
Verification
Section titled “Verification”Each feature PR documents the operation and boundary it touches. Add executable boundary checks as namespaces are introduced: Core must boot without product, channel adapter or presentation dependencies; generic UI must not query models; product workflows must use Core interfaces. Test authorization and tenant isolation at request, job and database levels, including missing context and cross-tenant attempts. Exercise actual browser behavior, not only markup.