# chuanqisun/spaceship architecture

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

- Interactive diagram: https://gitdiagram.com/chuanqisun/spaceship
- Repository: https://github.com/chuanqisun/spaceship

## Overview

Spaceship IDE is an interactive writing prototype for steering streamed story continuations with attention cues and future-vector controls. The principal workflow runs from the browser’s text interaction through generation buffering and live or simulated text sources to rendered continuation; users can also tune future dimensions, emphasize phrases, and explore alternatives by scrubbing. The graph preserves these documented capabilities and key text, layout, and audio layers. Some feature modules were not excerpted, so their internal links are omitted where the supplied evidence does not show the caller.

Main entry points: [`src/text/main.ts`](https://github.com/chuanqisun/spaceship/blob/master/src/text/main.ts) (Writing Orchestrator), [`src/text/story-layout.ts`](https://github.com/chuanqisun/spaceship/blob/master/src/text/story-layout.ts) (Story Layout), [`src/text/future-knobs.ts`](https://github.com/chuanqisun/spaceship/blob/master/src/text/future-knobs.ts) (Future Knobs), [`src/text/live-completion.ts`](https://github.com/chuanqisun/spaceship/blob/master/src/text/live-completion.ts) (Live Completion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Writing Interaction"]
  node_writer["Writing Orchestrator<br/>[main.ts]"]
  node_drag["Drag Interaction<br/>[drag.ts]"]
end

subgraph group_steering["Steering Features"]
  node_attention["Attention Buffers<br/>[attention.ts]"]
  node_attentionui["Attention Knobs<br/>[attention-knobs.ts]"]
  node_livedomain["Live Attention and Steering"]
  node_futureknobs["Future Knobs<br/>[future-knobs.ts]"]
  node_dimensions["Steering Dimensions<br/>[dimension.ts]"]
  node_relevance["Keyword Relevance"]
  node_influence["Phrase Connections<br/>[connections.ts]"]
end

subgraph group_generation["Text Generation"]
  node_textstream["Text Stream<br/>[text-stream.ts]"]
  node_completion["Completion Source<br/>[completion.ts]"]
  node_livecompletion["Live Completion<br/>[live-completion.ts]"]
  node_cerebras["Cerebras Client<br/>[cerebras.ts]"]
  node_decision["Decision Models<br/>[decisions.ts]"]
  node_openings["Story Openings<br/>[openings.ts]"]
  node_prompt["Story Prompt<br/>[prompt.ts]"]
end

subgraph group_foundation["Text and Feedback"]
  node_storylayout["Story Layout<br/>[story-layout.ts]"]
  node_segments["Text Segments<br/>[segments.ts]"]
  node_streamwords["Text and Word Utilities<br/>[text-stream.ts]"]
  node_geometry["Pointer Geometry<br/>[point.ts]"]
  node_sounddesign["Interaction Sounds<br/>[sounds.ts]"]
  node_audio["Audio Engine<br/>[engine.ts]"]
end

node_user(("Writer"))
node_cerebrasapi(("Cerebras API"))

node_user -->|"steers writing"| node_writer
node_writer -->|"creates stream"| node_textstream
node_writer -->|"configures controls"| node_attentionui
node_writer -->|"selects sources"| node_livedomain
node_writer -->|"creates connections"| node_influence
node_writer -->|"creates relevance"| node_relevance
node_writer -->|"binds dragging"| node_drag
node_writer -->|"plays feedback"| node_sounddesign
node_textstream -->|"requests continuation"| node_completion
node_completion -->|"lays out text"| node_storylayout
node_livecompletion -->|"streams completion"| node_cerebras
node_livecompletion -->|"uses openings"| node_openings
node_livecompletion -->|"uses prompt"| node_prompt
node_cerebras -->|"streams response"| node_cerebrasapi
node_livedomain -->|"requests model output"| node_cerebras
node_attentionui -->|"buffers attention"| node_attention
node_futureknobs -->|"tunes dimensions"| node_dimensions
node_futureknobs -->|"binds dragging"| node_drag
node_futureknobs -->|"tracks story"| node_storylayout
node_futureknobs -->|"plays feedback"| node_sounddesign
node_influence -->|"uses story layout"| node_storylayout
node_influence -->|"uses segments"| node_segments
node_relevance -->|"uses story layout"| node_storylayout
node_storylayout -->|"splits sentences"| node_segments
node_storylayout -->|"counts words"| node_streamwords
node_textstream -->|"counts words"| node_streamwords
node_drag -->|"uses points"| node_geometry
node_sounddesign -->|"synthesizes sounds"| node_audio

click node_writer "https://github.com/chuanqisun/spaceship/blob/master/src/text/main.ts"
click node_textstream "https://github.com/chuanqisun/spaceship/blob/master/src/text/text-stream.ts"
click node_completion "https://github.com/chuanqisun/spaceship/blob/master/src/text/completion.ts"
click node_livecompletion "https://github.com/chuanqisun/spaceship/blob/master/src/text/live-completion.ts"
click node_cerebras "https://github.com/chuanqisun/spaceship/blob/master/src/llm/cerebras.ts"
click node_decision "https://github.com/chuanqisun/spaceship/blob/master/src/llm/decisions.ts"
click node_openings "https://github.com/chuanqisun/spaceship/blob/master/src/story/openings.ts"
click node_prompt "https://github.com/chuanqisun/spaceship/blob/master/src/story/prompt.ts"
click node_attention "https://github.com/chuanqisun/spaceship/blob/master/src/text/attention.ts"
click node_attentionui "https://github.com/chuanqisun/spaceship/blob/master/src/text/attention-knobs.ts"
click node_livedomain "https://github.com/chuanqisun/spaceship/tree/master/src/text"
click node_futureknobs "https://github.com/chuanqisun/spaceship/blob/master/src/text/future-knobs.ts"
click node_dimensions "https://github.com/chuanqisun/spaceship/blob/master/src/text/dimension.ts"
click node_relevance "https://github.com/chuanqisun/spaceship/blob/master/src/text/keyword-relevance.ts"
click node_influence "https://github.com/chuanqisun/spaceship/blob/master/src/text/connections.ts"
click node_storylayout "https://github.com/chuanqisun/spaceship/blob/master/src/text/story-layout.ts"
click node_segments "https://github.com/chuanqisun/spaceship/blob/master/src/text/segments.ts"
click node_streamwords "https://github.com/chuanqisun/spaceship/blob/master/src/text/text-stream.ts"
click node_geometry "https://github.com/chuanqisun/spaceship/blob/master/src/point.ts"
click node_drag "https://github.com/chuanqisun/spaceship/blob/master/src/text/drag.ts"
click node_sounddesign "https://github.com/chuanqisun/spaceship/blob/master/src/text/sound/sounds.ts"
click node_audio "https://github.com/chuanqisun/spaceship/blob/master/src/text/sound/engine.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_writer,node_drag toneBlue
class node_attention,node_attentionui,node_livedomain,node_futureknobs,node_dimensions,node_relevance,node_influence toneAmber
class node_textstream,node_completion,node_livecompletion,node_cerebras,node_decision,node_openings,node_prompt,node_cerebrasapi toneMint
class node_storylayout,node_segments,node_streamwords,node_geometry,node_sounddesign,node_audio toneRose
class node_user toneIndigo
```

## Components

### Writing Interaction

- [Writing Orchestrator](https://github.com/chuanqisun/spaceship/blob/master/src/text/main.ts): `src/text/main.ts`
- [Drag Interaction](https://github.com/chuanqisun/spaceship/blob/master/src/text/drag.ts): `src/text/drag.ts`

### Steering Features

- [Attention Buffers](https://github.com/chuanqisun/spaceship/blob/master/src/text/attention.ts): `src/text/attention.ts`
- [Attention Knobs](https://github.com/chuanqisun/spaceship/blob/master/src/text/attention-knobs.ts): `src/text/attention-knobs.ts`
- [Live Attention and Steering](https://github.com/chuanqisun/spaceship/tree/master/src/text): `src/text`
- [Future Knobs](https://github.com/chuanqisun/spaceship/blob/master/src/text/future-knobs.ts): `src/text/future-knobs.ts`
- [Steering Dimensions](https://github.com/chuanqisun/spaceship/blob/master/src/text/dimension.ts): `src/text/dimension.ts`
- [Keyword Relevance](https://github.com/chuanqisun/spaceship/blob/master/src/text/keyword-relevance.ts): `src/text/keyword-relevance.ts`
- [Phrase Connections](https://github.com/chuanqisun/spaceship/blob/master/src/text/connections.ts): `src/text/connections.ts`

### Text Generation

- [Text Stream](https://github.com/chuanqisun/spaceship/blob/master/src/text/text-stream.ts): `src/text/text-stream.ts`
- [Completion Source](https://github.com/chuanqisun/spaceship/blob/master/src/text/completion.ts): `src/text/completion.ts`
- [Live Completion](https://github.com/chuanqisun/spaceship/blob/master/src/text/live-completion.ts): `src/text/live-completion.ts`
- [Cerebras Client](https://github.com/chuanqisun/spaceship/blob/master/src/llm/cerebras.ts): `src/llm/cerebras.ts`
- [Decision Models](https://github.com/chuanqisun/spaceship/blob/master/src/llm/decisions.ts): `src/llm/decisions.ts`
- [Story Openings](https://github.com/chuanqisun/spaceship/blob/master/src/story/openings.ts): `src/story/openings.ts`
- [Story Prompt](https://github.com/chuanqisun/spaceship/blob/master/src/story/prompt.ts): `src/story/prompt.ts`

### Text and Feedback

- [Story Layout](https://github.com/chuanqisun/spaceship/blob/master/src/text/story-layout.ts): `src/text/story-layout.ts`
- [Text Segments](https://github.com/chuanqisun/spaceship/blob/master/src/text/segments.ts): `src/text/segments.ts`
- [Text and Word Utilities](https://github.com/chuanqisun/spaceship/blob/master/src/text/text-stream.ts): `src/text/text-stream.ts`
- [Pointer Geometry](https://github.com/chuanqisun/spaceship/blob/master/src/point.ts): `src/point.ts`
- [Interaction Sounds](https://github.com/chuanqisun/spaceship/blob/master/src/text/sound/sounds.ts): `src/text/sound/sounds.ts`
- [Audio Engine](https://github.com/chuanqisun/spaceship/blob/master/src/text/sound/engine.ts): `src/text/sound/engine.ts`

### Other components

- **Writer**
- **Cerebras API**

## Connections

- Writer → Writing Orchestrator: steers writing
- Writing Orchestrator → Text Stream: creates stream (evidence: `src/text/main.ts`)
- Writing Orchestrator → Attention Knobs: configures controls (evidence: `src/text/main.ts`)
- Writing Orchestrator → Live Attention and Steering: selects sources (evidence: `src/text/main.ts`)
- Writing Orchestrator → Phrase Connections: creates connections (evidence: `src/text/main.ts`)
- Writing Orchestrator → Keyword Relevance: creates relevance (evidence: `src/text/main.ts`)
- Writing Orchestrator → Drag Interaction: binds dragging (evidence: `src/text/main.ts`)
- Writing Orchestrator → Interaction Sounds: plays feedback (evidence: `src/text/main.ts`)
- Text Stream → Completion Source: requests continuation (evidence: `src/text/completion.ts`)
- Completion Source → Story Layout: lays out text (evidence: `src/text/completion.ts`)
- Live Completion → Cerebras Client: streams completion (evidence: `src/text/live-completion.ts`)
- Live Completion → Story Openings: uses openings (evidence: `src/text/live-completion.ts`)
- Live Completion → Story Prompt: uses prompt (evidence: `src/text/live-completion.ts`)
- Cerebras Client → Cerebras API: streams response (evidence: `src/llm/cerebras.ts`)
- Live Attention and Steering → Cerebras Client: requests model output (evidence: `src/text/live-attention.ts`)
- Attention Knobs → Attention Buffers: buffers attention (evidence: `src/text/attention-knobs.ts`)
- Future Knobs → Steering Dimensions: tunes dimensions (evidence: `src/text/future-knobs.ts`)
- Future Knobs → Drag Interaction: binds dragging (evidence: `src/text/future-knobs.ts`)
- Future Knobs → Story Layout: tracks story (evidence: `src/text/future-knobs.ts`)
- Future Knobs → Interaction Sounds: plays feedback (evidence: `src/text/future-knobs.ts`)
- Phrase Connections → Story Layout: uses story layout (evidence: `src/text/connections.ts`)
- Phrase Connections → Text Segments: uses segments (evidence: `src/text/connections.ts`)
- Keyword Relevance → Story Layout: uses story layout (evidence: `src/text/keyword-relevance.ts`)
- Story Layout → Text Segments: splits sentences (evidence: `src/text/story-layout.ts`)
- Story Layout → Text and Word Utilities: counts words (evidence: `src/text/story-layout.ts`)
- Text Stream → Text and Word Utilities: counts words (evidence: `src/text/text-stream.ts`)
- Drag Interaction → Pointer Geometry: uses points (evidence: `src/text/drag.ts`)
- Interaction Sounds → Audio Engine: synthesizes sounds (evidence: `src/text/sound/sounds.ts`)
