# thevkp/x-post-formatter architecture

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

- Interactive diagram: https://gitdiagram.com/thevkp/x-post-formatter
- Repository: https://github.com/thevkp/x-post-formatter

## Overview

X Post Slicer is a browser-based tool for turning long text into X-sized posts. Users enter text, choose split or compression mode, adjust the count limit and labels, review and edit compressed text, then copy individual posts or the full thread. Its runtime flow runs through the state hook and pure processing pipeline: compression, sentence-aware splitting, and weighted counting. The UI also exposes warnings and copy progress. The graph follows shown calls and imports; unsampled component and compressor internals are represented only at their supported subsystem boundaries.

Main entry points: [`x-post-slicer/src/App.tsx`](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/App.tsx) (Slicer interface), [`x-post-slicer/src/core/splitter/split.ts`](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/split.ts) (Post splitting), [`x-post-slicer/src/core/pipeline.ts`](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/pipeline.ts) (Processing pipeline), [`x-post-slicer/src/core/counter/xWeightedCounter.ts`](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/counter/xWeightedCounter.ts) (X-weighted count)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Slicer interface<br/>[App.tsx]"]
  node_state["Slicer state<br/>[usePostSlicer.ts]"]
  node_postcard["Post cards<br/>[PostCard.tsx]"]
end

subgraph group_processing["Text processing"]
  node_compressor["Compression modes<br/>[index.ts]"]
  node_pipeline["Processing pipeline<br/>[pipeline.ts]"]
  node_splitter["Post splitting<br/>[split.ts]"]
  node_boundaries["Text boundaries<br/>[boundaries.ts]"]
  node_labels["Post labels<br/>[labels.ts]"]
end

subgraph group_counting["Character counting"]
  node_weighted["X-weighted count"]
  node_graphemes["Grapheme segments<br/>[graphemes.ts]"]
end

subgraph group_copying["Clipboard"]
  node_copybutton["Copy controls<br/>[CopyButton.tsx]"]
  node_clipboard["Browser clipboard<br/>[clipboard.ts]"]
end

node_user(("Text editor"))
node_browser["Browser APIs"]

node_user -->|"enters text"| node_app
node_app -->|"reads state"| node_state
node_state -->|"runs pipeline"| node_pipeline
node_pipeline -->|"compresses text"| node_compressor
node_pipeline -->|"splits text"| node_splitter
node_pipeline -->|"measures text"| node_weighted
node_splitter -->|"gets units"| node_boundaries
node_splitter -->|"adds labels"| node_labels
node_splitter -->|"checks budgets"| node_weighted
node_splitter -->|"cuts long words"| node_graphemes
node_weighted -->|"counts segments"| node_graphemes
node_app -->|"renders posts"| node_postcard
node_app -->|"renders copy control"| node_copybutton
node_app -->|"copies next post"| node_clipboard
node_copybutton -->|"copies text"| node_clipboard
node_clipboard -->|"writes clipboard"| node_browser

click node_app "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/App.tsx"
click node_state "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/hooks/usePostSlicer.ts"
click node_postcard "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/PostCard.tsx"
click node_compressor "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/compressor/index.ts"
click node_pipeline "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/pipeline.ts"
click node_splitter "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/split.ts"
click node_boundaries "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/boundaries.ts"
click node_labels "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/labels.ts"
click node_weighted "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/counter/xWeightedCounter.ts"
click node_graphemes "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/counter/graphemes.ts"
click node_copybutton "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/CopyButton.tsx"
click node_clipboard "https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/clipboard.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_app,node_state,node_postcard,node_browser toneBlue
class node_compressor,node_pipeline,node_splitter,node_boundaries,node_labels toneAmber
class node_weighted,node_graphemes toneMint
class node_copybutton,node_clipboard toneRose
class node_user toneIndigo
```

## Components

### User interface

- [Slicer interface](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/App.tsx): `x-post-slicer/src/App.tsx`
- [Slicer state](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/hooks/usePostSlicer.ts): `x-post-slicer/src/hooks/usePostSlicer.ts`
- [Post cards](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/PostCard.tsx): `x-post-slicer/src/components/PostCard.tsx`

### Text processing

- [Compression modes](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/compressor/index.ts): `x-post-slicer/src/core/compressor/index.ts`
- [Processing pipeline](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/pipeline.ts): `x-post-slicer/src/core/pipeline.ts`
- [Post splitting](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/split.ts): `x-post-slicer/src/core/splitter/split.ts`
- [Text boundaries](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/boundaries.ts): `x-post-slicer/src/core/splitter/boundaries.ts`
- [Post labels](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/splitter/labels.ts): `x-post-slicer/src/core/splitter/labels.ts`

### Character counting

- [X-weighted count](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/counter/xWeightedCounter.ts): `x-post-slicer/src/core/counter/xWeightedCounter.ts`
- [Grapheme segments](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/core/counter/graphemes.ts): `x-post-slicer/src/core/counter/graphemes.ts`

### Clipboard

- [Copy controls](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/CopyButton.tsx): `x-post-slicer/src/components/CopyButton.tsx`
- [Browser clipboard](https://github.com/thevkp/x-post-formatter/blob/main/x-post-slicer/src/components/clipboard.ts): `x-post-slicer/src/components/clipboard.ts`

### Other components

- **Text editor**
- **Browser APIs**

## Connections

- Text editor → Slicer interface: enters text (evidence: `x-post-slicer/src/App.tsx`)
- Slicer interface → Slicer state: reads state (evidence: `x-post-slicer/src/App.tsx`)
- Slicer state → Processing pipeline: runs pipeline (evidence: `x-post-slicer/src/hooks/usePostSlicer.ts`)
- Processing pipeline → Compression modes: compresses text (evidence: `x-post-slicer/src/core/pipeline.ts`)
- Processing pipeline → Post splitting: splits text (evidence: `x-post-slicer/src/core/pipeline.ts`)
- Processing pipeline → X-weighted count: measures text (evidence: `x-post-slicer/src/core/pipeline.ts`)
- Post splitting → Text boundaries: gets units (evidence: `x-post-slicer/src/core/splitter/split.ts`)
- Post splitting → Post labels: adds labels (evidence: `x-post-slicer/src/core/splitter/split.ts`)
- Post splitting → X-weighted count: checks budgets (evidence: `x-post-slicer/src/core/splitter/split.ts`)
- Post splitting → Grapheme segments: cuts long words (evidence: `x-post-slicer/src/core/splitter/split.ts`)
- X-weighted count → Grapheme segments: counts segments (evidence: `x-post-slicer/src/core/counter/xWeightedCounter.ts`)
- Slicer interface → Post cards: renders posts (evidence: `x-post-slicer/src/App.tsx`)
- Slicer interface → Copy controls: renders copy control (evidence: `x-post-slicer/src/App.tsx`)
- Slicer interface → Browser clipboard: copies next post (evidence: `x-post-slicer/src/App.tsx`)
- Copy controls → Browser clipboard: copies text (evidence: `x-post-slicer/src/components/CopyButton.tsx`)
- Browser clipboard → Browser APIs: writes clipboard (evidence: `x-post-slicer/src/components/clipboard.ts`)
