# rlynx0/creatures-den architecture

> Architecture diagram of the GitHub repository rlynx0/creatures-den, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rlynx0/creatures-den
- Repository: https://github.com/rlynx0/creatures-den

## Overview

Creature’s Den is a web application for creating and viewing items with collaborative Markdown and drawing features, alongside accounts and administration. The main user journey is to enter the app, open or create an item, edit its content, and view it; item history provides a separate drawing-history view. The graph also captures Markdown rendering and collaboration, account workflows, and administrative tools. Relationships are limited to routes and calls supported by the excerpts; several page and persistence implementations are unsampled.

Main entry points: [`src/app.rs`](https://github.com/rlynx0/creatures-den/blob/main/src/app.rs) (App router and shell), [`src/main.rs`](https://github.com/rlynx0/creatures-den/blob/main/src/main.rs) (HTTP server), [`src/app/components/markdown/mod.rs`](https://github.com/rlynx0/creatures-den/blob/main/src/app/components/markdown/mod.rs) (Markdown editor and collaboration), [`src/app/pages/item/history.rs`](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/history.rs) (Drawing history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and routing"]
  node_server["HTTP server<br/>[main.rs]"]
  node_app["App router and shell<br/>[app.rs]"]
  node_home["Home page<br/>[home.rs]"]
end

subgraph group_items["Items and drawing"]
  node_create["Create item<br/>[create.rs]"]
  node_edit["Edit item<br/>[edit.rs]"]
  node_view["View item<br/>[view.rs]"]
  node_history["Drawing history<br/>[history.rs]"]
  node_drawing["Drawing canvas<br/>[mod.rs]"]
  node_draw_types["Drawing data types<br/>[draw_types.rs]"]
end

subgraph group_markdown["Markdown collaboration"]
  node_markdown["Markdown editor and collaboration<br/>[mod.rs]"]
  node_md_parse["Markdown decorations<br/>[parse.rs]"]
  node_cm_editor["CodeMirror bridge<br/>[cm-editor.js]"]
  node_ws_session["WebSocket reconnect<br/>[ws_session.rs]"]
  node_ws["WebSocket handlers<br/>[ws.rs]"]
end

subgraph group_identity["Accounts and access"]
  node_login["Login and joining<br/>[login.rs]"]
  node_join["Invite joining<br/>[join.rs]"]
  node_profile["Profile settings<br/>[profile.rs]"]
  node_auth["Authentication<br/>[auth.rs]"]
end

subgraph group_admin["Administration and storage"]
  node_admin["Admin pages<br/>[mod.rs]"]
  node_invites["Trusted invites<br/>[trusted_invites.rs]"]
  node_users["User administration<br/>[users.rs]"]
  node_sql_console["SQL console<br/>[sql_console.rs]"]
  node_db["Database backend<br/>[db_backend.rs]"]
  node_postgres[("PostgreSQL")]
  node_blob["Blob serving<br/>[blob.rs]"]
end

node_user(("User"))

node_user -->|"sends requests"| node_server
node_server -->|"dispatches page routes"| node_app
node_server -->|"dispatches WebSockets"| node_ws
node_server -->|"applies auth layer"| node_auth
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_edit
node_app -->|"routes to"| node_view
node_app -->|"routes to"| node_history
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_join
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_admin
node_edit -->|"shows editor"| node_drawing
node_view -->|"shows drawing"| node_drawing
node_history -->|"uses drawing data"| node_draw_types
node_markdown -->|"computes decorations"| node_md_parse
node_markdown -->|"creates editor"| node_cm_editor
node_cm_editor -->|"requests decorations"| node_markdown
node_markdown -->|"manages connection"| node_ws_session
node_markdown -->|"connects to Markdown socket"| node_ws
node_ws -->|"persists data"| node_postgres
node_profile -->|"reads and writes profile"| node_postgres
node_history -->|"reads history"| node_postgres
node_invites -->|"manages invite records"| node_postgres
node_users -->|"manages users"| node_postgres
node_sql_console -->|"runs SQL"| node_postgres
node_db -->|"connects to"| node_postgres
node_server -->|"serves blob route"| node_blob

click node_server "https://github.com/rlynx0/creatures-den/blob/main/src/main.rs"
click node_app "https://github.com/rlynx0/creatures-den/blob/main/src/app.rs"
click node_home "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/home.rs"
click node_create "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/create.rs"
click node_edit "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/edit.rs"
click node_view "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/view.rs"
click node_history "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/history.rs"
click node_drawing "https://github.com/rlynx0/creatures-den/blob/main/src/app/components/drawing/mod.rs"
click node_draw_types "https://github.com/rlynx0/creatures-den/blob/main/src/draw_types.rs"
click node_markdown "https://github.com/rlynx0/creatures-den/blob/main/src/app/components/markdown/mod.rs"
click node_md_parse "https://github.com/rlynx0/creatures-den/blob/main/src/app/components/markdown/decorations/parse.rs"
click node_cm_editor "https://github.com/rlynx0/creatures-den/blob/main/src-js/cm-editor.js"
click node_ws_session "https://github.com/rlynx0/creatures-den/blob/main/src/app/components/ws_session.rs"
click node_ws "https://github.com/rlynx0/creatures-den/blob/main/src/ws.rs"
click node_login "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/login.rs"
click node_join "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/join.rs"
click node_profile "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/profile.rs"
click node_auth "https://github.com/rlynx0/creatures-den/blob/main/src/auth.rs"
click node_admin "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/mod.rs"
click node_invites "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/trusted_invites.rs"
click node_users "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/users.rs"
click node_sql_console "https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/sql_console.rs"
click node_db "https://github.com/rlynx0/creatures-den/blob/main/src/db_backend.rs"
click node_blob "https://github.com/rlynx0/creatures-den/blob/main/src/blob.rs"

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_server,node_app,node_home,node_user toneBlue
class node_create,node_edit,node_view,node_history,node_drawing,node_draw_types toneAmber
class node_markdown,node_md_parse,node_cm_editor,node_ws_session,node_ws toneMint
class node_login,node_join,node_profile,node_auth toneRose
class node_admin,node_invites,node_users,node_sql_console,node_db,node_postgres,node_blob toneIndigo
```

## Components

### Application and routing

- [HTTP server](https://github.com/rlynx0/creatures-den/blob/main/src/main.rs): `src/main.rs`
- [App router and shell](https://github.com/rlynx0/creatures-den/blob/main/src/app.rs): `src/app.rs`
- [Home page](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/home.rs): `src/app/pages/home.rs`

### Items and drawing

- [Create item](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/create.rs): `src/app/pages/item/create.rs`
- [Edit item](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/edit.rs): `src/app/pages/item/edit.rs`
- [View item](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/view.rs): `src/app/pages/item/view.rs`
- [Drawing history](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/item/history.rs): `src/app/pages/item/history.rs`
- [Drawing canvas](https://github.com/rlynx0/creatures-den/blob/main/src/app/components/drawing/mod.rs): `src/app/components/drawing/mod.rs`
- [Drawing data types](https://github.com/rlynx0/creatures-den/blob/main/src/draw_types.rs): `src/draw_types.rs`

### Markdown collaboration

- [Markdown editor and collaboration](https://github.com/rlynx0/creatures-den/blob/main/src/app/components/markdown/mod.rs): `src/app/components/markdown/mod.rs`
- [Markdown decorations](https://github.com/rlynx0/creatures-den/blob/main/src/app/components/markdown/decorations/parse.rs): `src/app/components/markdown/decorations/parse.rs`
- [CodeMirror bridge](https://github.com/rlynx0/creatures-den/blob/main/src-js/cm-editor.js): `src-js/cm-editor.js`
- [WebSocket reconnect](https://github.com/rlynx0/creatures-den/blob/main/src/app/components/ws_session.rs): `src/app/components/ws_session.rs`
- [WebSocket handlers](https://github.com/rlynx0/creatures-den/blob/main/src/ws.rs): `src/ws.rs`

### Accounts and access

- [Login and joining](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/login.rs): `src/app/pages/login.rs`
- [Invite joining](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/join.rs): `src/app/pages/join.rs`
- [Profile settings](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/profile.rs): `src/app/pages/profile.rs`
- [Authentication](https://github.com/rlynx0/creatures-den/blob/main/src/auth.rs): `src/auth.rs`

### Administration and storage

- [Admin pages](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/mod.rs): `src/app/pages/admin/mod.rs`
- [Trusted invites](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/trusted_invites.rs): `src/app/pages/admin/trusted_invites.rs`
- [User administration](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/users.rs): `src/app/pages/admin/users.rs`
- [SQL console](https://github.com/rlynx0/creatures-den/blob/main/src/app/pages/admin/sql_console.rs): `src/app/pages/admin/sql_console.rs`
- [Database backend](https://github.com/rlynx0/creatures-den/blob/main/src/db_backend.rs): `src/db_backend.rs`
- **PostgreSQL**
- [Blob serving](https://github.com/rlynx0/creatures-den/blob/main/src/blob.rs): `src/blob.rs`

### Other components

- **User**

## Connections

- User → HTTP server: sends requests
- HTTP server → App router and shell: dispatches page routes
- HTTP server → WebSocket handlers: dispatches WebSockets
- HTTP server → Authentication: applies auth layer
- App router and shell → Home page: routes to
- App router and shell → Create item: routes to
- App router and shell → Edit item: routes to
- App router and shell → View item: routes to
- App router and shell → Drawing history: routes to
- App router and shell → Login and joining: routes to
- App router and shell → Invite joining: routes to
- App router and shell → Profile settings: routes to
- App router and shell → Admin pages: routes to
- Edit item → Drawing canvas: shows editor
- View item → Drawing canvas: shows drawing
- Drawing history → Drawing data types: uses drawing data
- Markdown editor and collaboration → Markdown decorations: computes decorations
- Markdown editor and collaboration → CodeMirror bridge: creates editor
- CodeMirror bridge → Markdown editor and collaboration: requests decorations
- Markdown editor and collaboration → WebSocket reconnect: manages connection
- Markdown editor and collaboration → WebSocket handlers: connects to Markdown socket
- WebSocket handlers → PostgreSQL: persists data
- Profile settings → PostgreSQL: reads and writes profile
- Drawing history → PostgreSQL: reads history
- Trusted invites → PostgreSQL: manages invite records
- User administration → PostgreSQL: manages users
- SQL console → PostgreSQL: runs SQL
- Database backend → PostgreSQL: connects to
- HTTP server → Blob serving: serves blob route
