# sandikodev/aurelia-ssr architecture

> Architecture diagram of the GitHub repository sandikodev/aurelia-ssr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sandikodev/aurelia-ssr
- Repository: https://github.com/sandikodev/aurelia-ssr

## Overview

This is an Aurelia 2 SSR and hydration runtime. Its main flow renders a component in an isolated server DOM, serializes state into an inert JSON script, builds a full or streaming HTML document, then reads that payload in the browser to hydrate or boot the selected component. README and excerpts document these connections; no unshown implementation details are assumed.

Main entry points: [`src/render.ts`](https://github.com/sandikodev/aurelia-ssr/blob/main/src/render.ts) (Aurelia Renderer), [`src/hydrate.ts`](https://github.com/sandikodev/aurelia-ssr/blob/main/src/hydrate.ts) (Client Bootstrap), [`src/html.ts`](https://github.com/sandikodev/aurelia-ssr/blob/main/src/html.ts) (HTML Builder), [`src/serialize.ts`](https://github.com/sandikodev/aurelia-ssr/blob/main/src/serialize.ts) (State Serializer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Server Rendering"]
  node_render["Aurelia Renderer<br/>[render.ts]"]
  node_dom["DOM Scope<br/>[render.ts]"]
end

subgraph group_payload["State and HTML"]
  node_serialize["State Serializer<br/>[serialize.ts]"]
  node_html["HTML Builder<br/>[html.ts]"]
end

subgraph group_client["Client Hydration"]
  node_client["Client Bootstrap<br/>[hydrate.ts]"]
end

subgraph group_shared["Shared Contracts"]
  node_tokens["Request Context DI<br/>[tokens.ts]"]
  node_types["Type Contracts<br/>[types.ts]"]
end

node_caller(("Application"))
node_aurelia["Aurelia Runtime"]
node_browser["Browser DOM"]

node_caller -->|"requests render"| node_render
node_render -->|"creates scope"| node_dom
node_render -->|"starts app"| node_aurelia
node_render -->|"registers context"| node_tokens
node_caller -->|"serializes state"| node_serialize
node_serialize -->|"encodes payload"| node_html
node_caller -->|"builds document"| node_html
node_html -->|"emits markup"| node_browser
node_browser -->|"loads bootstrap"| node_client
node_client -->|"reads payload"| node_browser
node_client -->|"hydrates app"| node_aurelia
node_client -->|"registers context"| node_tokens

click node_render "https://github.com/sandikodev/aurelia-ssr/blob/main/src/render.ts"
click node_dom "https://github.com/sandikodev/aurelia-ssr/blob/main/src/render.ts"
click node_serialize "https://github.com/sandikodev/aurelia-ssr/blob/main/src/serialize.ts"
click node_html "https://github.com/sandikodev/aurelia-ssr/blob/main/src/html.ts"
click node_client "https://github.com/sandikodev/aurelia-ssr/blob/main/src/hydrate.ts"
click node_tokens "https://github.com/sandikodev/aurelia-ssr/blob/main/src/tokens.ts"
click node_types "https://github.com/sandikodev/aurelia-ssr/blob/main/src/types.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_render,node_dom,node_browser toneBlue
class node_serialize,node_html toneAmber
class node_client toneMint
class node_tokens,node_types toneRose
class node_caller,node_aurelia toneIndigo
```

## Components

### Server Rendering

- [Aurelia Renderer](https://github.com/sandikodev/aurelia-ssr/blob/main/src/render.ts): `src/render.ts`
- [DOM Scope](https://github.com/sandikodev/aurelia-ssr/blob/main/src/render.ts): `src/render.ts`

### State and HTML

- [State Serializer](https://github.com/sandikodev/aurelia-ssr/blob/main/src/serialize.ts): `src/serialize.ts`
- [HTML Builder](https://github.com/sandikodev/aurelia-ssr/blob/main/src/html.ts): `src/html.ts`

### Client Hydration

- [Client Bootstrap](https://github.com/sandikodev/aurelia-ssr/blob/main/src/hydrate.ts): `src/hydrate.ts`

### Shared Contracts

- [Request Context DI](https://github.com/sandikodev/aurelia-ssr/blob/main/src/tokens.ts): `src/tokens.ts`
- [Type Contracts](https://github.com/sandikodev/aurelia-ssr/blob/main/src/types.ts): `src/types.ts`

### Other components

- **Application**
- **Aurelia Runtime**
- **Browser DOM**

## Connections

- Application → Aurelia Renderer: requests render (evidence: `README.md`)
- Aurelia Renderer → DOM Scope: creates scope (evidence: `src/render.ts`)
- Aurelia Renderer → Aurelia Runtime: starts app (evidence: `src/render.ts`)
- Aurelia Renderer → Request Context DI: registers context (evidence: `src/render.ts`)
- Application → State Serializer: serializes state (evidence: `README.md`)
- State Serializer → HTML Builder: encodes payload (evidence: `src/html.ts`)
- Application → HTML Builder: builds document (evidence: `README.md`)
- HTML Builder → Browser DOM: emits markup (evidence: `README.md`)
- Browser DOM → Client Bootstrap: loads bootstrap (evidence: `README.md`)
- Client Bootstrap → Browser DOM: reads payload (evidence: `src/hydrate.ts`)
- Client Bootstrap → Aurelia Runtime: hydrates app (evidence: `src/hydrate.ts`)
- Client Bootstrap → Request Context DI: registers context (evidence: `src/hydrate.ts`)
