# dunkrick/nook architecture

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

- Interactive diagram: https://gitdiagram.com/dunkrick/nook
- Repository: https://github.com/dunkrick/nook

## Overview

Nook is a spatial thinking workspace: users authenticate, choose a workspace, create and arrange text, link, and Polaroid artifacts, and can bring GitHub issues into that space. The browser’s React workspace communicates with an Express API; backend services persist workspace and artifact data and provide private image uploads and signed reads. GitHub webhooks are verified, queued, and processed asynchronously into artifacts. The graph follows documented architecture and shown wiring; some service internals and frontend page-level calls were not sampled, so uncertain links are omitted.

Main entry points: [`backend/src/app.ts`](https://github.com/dunkrick/nook/blob/main/backend/src/app.ts) (Express application), [`frontend/src/main.tsx`](https://github.com/dunkrick/nook/blob/main/frontend/src/main.tsx) (Nook browser app), [`backend/src/routes/uploads.ts`](https://github.com/dunkrick/nook/blob/main/backend/src/routes/uploads.ts) (Upload routes), [`backend/src/routes/github-webhooks.ts`](https://github.com/dunkrick/nook/blob/main/backend/src/routes/github-webhooks.ts) (Webhook endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser workspace"]
  node_browser["Nook browser app<br/>[main.tsx]"]
  node_authui["Authentication UI<br/>[AuthForm.tsx]"]
  node_workspaceui["Workspace page<br/>[Home.tsx]"]
  node_canvas["Spatial canvas"]
  node_drag["Artifact dragging<br/>[useArtifactDrag.ts]"]
  node_artifactview["Artifact views<br/>[ArtifactView.tsx]"]
  node_frontendtypes["Artifact model<br/>[artifacts.ts]"]
  node_frontendapi["API client<br/>[api.ts]"]
  node_localstate["Local session state<br/>[storage.ts]"]
end

subgraph group_api["API and domain"]
  node_app["Express application<br/>[app.ts]"]
  node_authroutes["Auth routes<br/>[auth.ts]"]
  node_authservice["Authentication service<br/>[auth.ts]"]
  node_authmiddleware["JWT protection<br/>[auth.ts]"]
  node_workspaceroutes["Workspace routes<br/>[workspaces.ts]"]
  node_artifactservice["Artifact services<br/>[artifacts.ts]"]
  node_artifactdomain["Artifact domain<br/>[artifacts.ts]"]
end

subgraph group_media["Private media"]
  node_uploadroutes["Upload routes<br/>[uploads.ts]"]
  node_uploadservice["Upload service<br/>[uploads.ts]"]
  node_imagehandling["Signed image reads<br/>[artifact-images.ts]"]
  node_objectstorage["Storage interface<br/>[object-storage.ts]"]
  node_gcs["Google Cloud Storage"]
end

subgraph group_github["GitHub sync"]
  node_webhookroute["Webhook endpoint<br/>[github-webhooks.ts]"]
  node_webhookverify["Signature verification<br/>[github-webhooks.ts]"]
  node_producer["Event producer<br/>[github-producer.ts]"]
  node_worker["Webhook worker<br/>[github-worker.ts]"]
  node_githubsync["Issue synchronization<br/>[github-sync.ts]"]
end

subgraph group_persistence["Persistence and messaging"]
  node_rabbitmq["RabbitMQ queues<br/>[rabbitmq.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
end

node_user(("Workspace user"))
node_github(("GitHub"))

node_user -->|"uses"| node_browser
node_browser -->|"renders"| node_authui
node_browser -->|"routes to"| node_workspaceui
node_workspaceui -->|"positions"| node_canvas
node_canvas -.->|"uses"| node_drag
node_workspaceui -.->|"renders"| node_artifactview
node_drag -->|"uses types"| node_frontendtypes
node_browser -->|"sends requests"| node_frontendapi
node_frontendapi -->|"reads token"| node_localstate
node_frontendapi -->|"HTTP requests"| node_app
node_app -->|"mounts"| node_authroutes
node_app -->|"mounts"| node_workspaceroutes
node_app -->|"mounts"| node_uploadroutes
node_authroutes -->|"calls"| node_authservice
node_workspaceroutes -->|"protects"| node_authmiddleware
node_workspaceroutes -->|"delegates"| node_artifactservice
node_artifactservice -.->|"uses model"| node_artifactdomain
node_uploadroutes -->|"protects"| node_authmiddleware
node_uploadroutes -->|"calls"| node_uploadservice
node_uploadservice -->|"stores through"| node_objectstorage
node_gcs -->|"implements"| node_objectstorage
node_uploadroutes -->|"configures storage"| node_gcs
node_imagehandling -.->|"signs reads"| node_gcs
node_github -->|"sends webhook"| node_webhookroute
node_app -->|"mounts"| node_webhookroute
node_webhookroute -->|"verifies with"| node_webhookverify
node_webhookroute -->|"publishes event"| node_producer
node_producer -->|"publishes to"| node_rabbitmq
node_worker -->|"consumes from"| node_rabbitmq
node_worker -->|"calls"| node_githubsync
node_worker -->|"uses transaction"| node_prisma
node_githubsync -->|"upserts artifact"| node_database
node_prisma -->|"connects"| node_database

click node_browser "https://github.com/dunkrick/nook/blob/main/frontend/src/main.tsx"
click node_authui "https://github.com/dunkrick/nook/blob/main/frontend/src/components/AuthForm.tsx"
click node_workspaceui "https://github.com/dunkrick/nook/blob/main/frontend/src/pages/Home.tsx"
click node_canvas "https://github.com/dunkrick/nook/blob/main/frontend/src/components/CanvasController.tsx"
click node_drag "https://github.com/dunkrick/nook/blob/main/frontend/src/hooks/useArtifactDrag.ts"
click node_artifactview "https://github.com/dunkrick/nook/blob/main/frontend/src/components/Artifact/ArtifactView.tsx"
click node_frontendtypes "https://github.com/dunkrick/nook/blob/main/frontend/src/types/artifacts.ts"
click node_frontendapi "https://github.com/dunkrick/nook/blob/main/frontend/src/services/api.ts"
click node_localstate "https://github.com/dunkrick/nook/blob/main/frontend/src/lib/storage.ts"
click node_app "https://github.com/dunkrick/nook/blob/main/backend/src/app.ts"
click node_authroutes "https://github.com/dunkrick/nook/blob/main/backend/src/routes/auth.ts"
click node_authservice "https://github.com/dunkrick/nook/blob/main/backend/src/services/auth.ts"
click node_authmiddleware "https://github.com/dunkrick/nook/blob/main/backend/src/middleware/auth.ts"
click node_workspaceroutes "https://github.com/dunkrick/nook/blob/main/backend/src/routes/workspaces.ts"
click node_artifactservice "https://github.com/dunkrick/nook/blob/main/backend/src/services/artifacts.ts"
click node_artifactdomain "https://github.com/dunkrick/nook/blob/main/backend/src/domain/artifacts.ts"
click node_uploadroutes "https://github.com/dunkrick/nook/blob/main/backend/src/routes/uploads.ts"
click node_uploadservice "https://github.com/dunkrick/nook/blob/main/backend/src/services/uploads.ts"
click node_imagehandling "https://github.com/dunkrick/nook/blob/main/backend/src/services/artifact-images.ts"
click node_objectstorage "https://github.com/dunkrick/nook/blob/main/backend/src/storage/object-storage.ts"
click node_gcs "https://github.com/dunkrick/nook/blob/main/backend/src/storage/google-cloud-storage.ts"
click node_webhookroute "https://github.com/dunkrick/nook/blob/main/backend/src/routes/github-webhooks.ts"
click node_webhookverify "https://github.com/dunkrick/nook/blob/main/backend/src/middleware/github-webhooks.ts"
click node_producer "https://github.com/dunkrick/nook/blob/main/backend/src/queue/github-producer.ts"
click node_worker "https://github.com/dunkrick/nook/blob/main/backend/src/queue/github-worker.ts"
click node_githubsync "https://github.com/dunkrick/nook/blob/main/backend/src/services/github-sync.ts"
click node_rabbitmq "https://github.com/dunkrick/nook/blob/main/backend/src/queue/rabbitmq.ts"
click node_prisma "https://github.com/dunkrick/nook/blob/main/backend/src/prisma.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_browser,node_authui,node_workspaceui,node_canvas,node_drag,node_artifactview,node_frontendtypes,node_frontendapi,node_localstate,node_user toneBlue
class node_app,node_authroutes,node_authservice,node_authmiddleware,node_workspaceroutes,node_artifactservice,node_artifactdomain toneAmber
class node_uploadroutes,node_uploadservice,node_imagehandling,node_objectstorage,node_gcs toneMint
class node_webhookroute,node_webhookverify,node_producer,node_worker,node_githubsync toneRose
class node_rabbitmq,node_prisma,node_database,node_github toneIndigo
```

## Components

### Browser workspace

- [Nook browser app](https://github.com/dunkrick/nook/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Authentication UI](https://github.com/dunkrick/nook/blob/main/frontend/src/components/AuthForm.tsx): `frontend/src/components/AuthForm.tsx`
- [Workspace page](https://github.com/dunkrick/nook/blob/main/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [Spatial canvas](https://github.com/dunkrick/nook/blob/main/frontend/src/components/CanvasController.tsx): `frontend/src/components/CanvasController.tsx`
- [Artifact dragging](https://github.com/dunkrick/nook/blob/main/frontend/src/hooks/useArtifactDrag.ts): `frontend/src/hooks/useArtifactDrag.ts`
- [Artifact views](https://github.com/dunkrick/nook/blob/main/frontend/src/components/Artifact/ArtifactView.tsx): `frontend/src/components/Artifact/ArtifactView.tsx`
- [Artifact model](https://github.com/dunkrick/nook/blob/main/frontend/src/types/artifacts.ts): `frontend/src/types/artifacts.ts`
- [API client](https://github.com/dunkrick/nook/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Local session state](https://github.com/dunkrick/nook/blob/main/frontend/src/lib/storage.ts): `frontend/src/lib/storage.ts`

### API and domain

- [Express application](https://github.com/dunkrick/nook/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Auth routes](https://github.com/dunkrick/nook/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Authentication service](https://github.com/dunkrick/nook/blob/main/backend/src/services/auth.ts): `backend/src/services/auth.ts`
- [JWT protection](https://github.com/dunkrick/nook/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [Workspace routes](https://github.com/dunkrick/nook/blob/main/backend/src/routes/workspaces.ts): `backend/src/routes/workspaces.ts`
- [Artifact services](https://github.com/dunkrick/nook/blob/main/backend/src/services/artifacts.ts): `backend/src/services/artifacts.ts`
- [Artifact domain](https://github.com/dunkrick/nook/blob/main/backend/src/domain/artifacts.ts): `backend/src/domain/artifacts.ts`

### Private media

- [Upload routes](https://github.com/dunkrick/nook/blob/main/backend/src/routes/uploads.ts): `backend/src/routes/uploads.ts`
- [Upload service](https://github.com/dunkrick/nook/blob/main/backend/src/services/uploads.ts): `backend/src/services/uploads.ts`
- [Signed image reads](https://github.com/dunkrick/nook/blob/main/backend/src/services/artifact-images.ts): `backend/src/services/artifact-images.ts`
- [Storage interface](https://github.com/dunkrick/nook/blob/main/backend/src/storage/object-storage.ts): `backend/src/storage/object-storage.ts`
- [Google Cloud Storage](https://github.com/dunkrick/nook/blob/main/backend/src/storage/google-cloud-storage.ts): `backend/src/storage/google-cloud-storage.ts`

### GitHub sync

- [Webhook endpoint](https://github.com/dunkrick/nook/blob/main/backend/src/routes/github-webhooks.ts): `backend/src/routes/github-webhooks.ts`
- [Signature verification](https://github.com/dunkrick/nook/blob/main/backend/src/middleware/github-webhooks.ts): `backend/src/middleware/github-webhooks.ts`
- [Event producer](https://github.com/dunkrick/nook/blob/main/backend/src/queue/github-producer.ts): `backend/src/queue/github-producer.ts`
- [Webhook worker](https://github.com/dunkrick/nook/blob/main/backend/src/queue/github-worker.ts): `backend/src/queue/github-worker.ts`
- [Issue synchronization](https://github.com/dunkrick/nook/blob/main/backend/src/services/github-sync.ts): `backend/src/services/github-sync.ts`

### Persistence and messaging

- [RabbitMQ queues](https://github.com/dunkrick/nook/blob/main/backend/src/queue/rabbitmq.ts): `backend/src/queue/rabbitmq.ts`
- [Prisma client](https://github.com/dunkrick/nook/blob/main/backend/src/prisma.ts): `backend/src/prisma.ts`
- **PostgreSQL**

### Other components

- **Workspace user**
- **GitHub**

## Connections

- Workspace user → Nook browser app: uses (evidence: `README.md`)
- Nook browser app → Authentication UI: renders
- Nook browser app → Workspace page: routes to
- Workspace page → Spatial canvas: positions (evidence: `frontend/src/components/CanvasController.tsx`)
- Spatial canvas → Artifact dragging: uses
- Workspace page → Artifact views: renders
- Artifact dragging → Artifact model: uses types (evidence: `frontend/src/hooks/useArtifactDrag.ts`)
- Nook browser app → API client: sends requests (evidence: `README.md`)
- API client → Local session state: reads token (evidence: `frontend/src/services/api.ts`)
- API client → Express application: HTTP requests (evidence: `README.md`)
- Express application → Auth routes: mounts (evidence: `backend/src/app.ts`)
- Express application → Workspace routes: mounts (evidence: `backend/src/app.ts`)
- Express application → Upload routes: mounts (evidence: `backend/src/app.ts`)
- Auth routes → Authentication service: calls (evidence: `backend/src/routes/auth.ts`)
- Workspace routes → JWT protection: protects (evidence: `README.md`)
- Workspace routes → Artifact services: delegates (evidence: `README.md`)
- Artifact services → Artifact domain: uses model
- Upload routes → JWT protection: protects (evidence: `backend/src/routes/uploads.ts`)
- Upload routes → Upload service: calls (evidence: `backend/src/routes/uploads.ts`)
- Upload service → Storage interface: stores through (evidence: `README.md`)
- Google Cloud Storage → Storage interface: implements (evidence: `backend/src/storage/google-cloud-storage.ts`)
- Upload routes → Google Cloud Storage: configures storage (evidence: `backend/src/routes/uploads.ts`)
- Signed image reads → Google Cloud Storage: signs reads
- GitHub → Webhook endpoint: sends webhook (evidence: `README.md`)
- Express application → Webhook endpoint: mounts (evidence: `backend/src/app.ts`)
- Webhook endpoint → Signature verification: verifies with (evidence: `backend/src/routes/github-webhooks.ts`)
- Webhook endpoint → Event producer: publishes event (evidence: `backend/src/routes/github-webhooks.ts`)
- Event producer → RabbitMQ queues: publishes to (evidence: `backend/src/queue/github-producer.ts`)
- Webhook worker → RabbitMQ queues: consumes from (evidence: `backend/src/queue/github-worker.ts`)
- Webhook worker → Issue synchronization: calls (evidence: `backend/src/queue/github-worker.ts`)
- Webhook worker → Prisma client: uses transaction (evidence: `backend/src/queue/github-worker.ts`)
- Issue synchronization → PostgreSQL: upserts artifact (evidence: `README.md`)
- Prisma client → PostgreSQL: connects (evidence: `backend/src/prisma.ts`)
