Architecture

# Architecture

The product is a modular monolith. HTTP apps assemble modules; modules do
not import Slim, Plates, or PDO.

## Boundaries

| Area | Role |
| --- | --- |
| `apps/http` | Single HTTP composition root |
| `packages/modules` | Bounded business contexts |
| `packages/ui` | Shared Plates layouts and components |
| `platform` | Technical adapters |

## JSON shape of a public document

The API wraps payloads in a `data` object with exactly four fields.

```json
{
  "data": {
    "slug": "architecture",
    "title": "Architecture",
    "description": "How apps, modules, shared UI, and adapters are separated.",
    "content": "# Architecture\n"
  }
}
```

## Module structure

The composition root wires modules, contracts, shared UI, and platform
adapters. The fence below is an id-only contract. The documentation
Markdown island lazy-loads a first-party renderer for that id.

```g5nx-diagram
nx-platform-architecture
```

## Documentation request flow

HTML `/docs/{slug}` and JSON `/api/v1/docs/{slug}` share the Markdown
allowlist. Diagram JSON is a separate route,
`GET /api/v1/docs/diagrams/{id}`. A valid `g5nx-diagram` fence fetches
that JSON from the same origin and paints from `data.model`.

```g5nx-diagram
docs-request-flow
```