# sm-joe/papershift-doc-converter architecture

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

- Interactive diagram: https://gitdiagram.com/sm-joe/papershift-doc-converter
- Repository: https://github.com/sm-joe/papershift-doc-converter

## Overview

PaperShift is a self-hosted document conversion service: a browser uses the Next.js interface to submit files to a Go API, which detects formats and runs conversions in ephemeral workspaces. The graph also preserves the documented capability-discovery and specialized PDF, image, and DOCX operations. Relationships are limited to the README and shown source references; some API-to-service links are supported by indexed API files whose excerpts were not provided.

Main entry points: [`internal/jobs/service.go`](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/service.go) (Job orchestration), [`internal/api/handler.go`](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/handler.go) (HTTP routes), [`internal/api/application.go`](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/application.go) (Application setup), [`internal/converter/registry.go`](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/converter/registry.go) (Converter registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Web application<br/>[page.tsx]"]
end

subgraph group_api["API surface"]
  node_server["API server<br/>[main.go]"]
  node_http["HTTP routes<br/>[handler.go]"]
  node_app["Application setup<br/>[application.go]"]
  node_capabilities["Capabilities<br/>[capabilities.go]"]
end

subgraph group_processing["Conversion processing"]
  node_formats["Format registry<br/>[registry.go]"]
  node_detection["Format detection<br/>[detector.go]"]
  node_jobs["Job orchestration<br/>[service.go]"]
  node_workspace["Job workspaces<br/>[workspace.go]"]
  node_results["Result store<br/>[store.go]"]
  node_registry["Converter registry<br/>[registry.go]"]
end

subgraph group_engines["Conversion engines"]
  node_libreoffice["LibreOffice engine<br/>[libreoffice.go]"]
  node_imagemagick["Image conversion<br/>[imagemagick.go]"]
  node_pdfengine["PDF conversion<br/>[pdf.go]"]
end

subgraph group_special["File operations"]
  node_pdftools["PDF operations<br/>[merge.go]"]
  node_imagecompress["Image compression<br/>[compress.go]"]
  node_docxcompress["DOCX compression<br/>[compress.go]"]
end

node_browser(("Browser"))

node_browser -->|"uses"| node_web
node_web -->|"submits files"| node_server
node_server -->|"configures"| node_app
node_server -->|"serves"| node_http
node_app -->|"registers engines"| node_registry
node_app -->|"creates service"| node_jobs
node_app -->|"creates detector"| node_detection
node_app -->|"loads formats"| node_formats
node_app -->|"creates store"| node_results
node_http -->|"reports capabilities"| node_capabilities
node_jobs -->|"detects input"| node_detection
node_jobs -->|"resolves output"| node_formats
node_jobs -->|"selects converter"| node_registry
node_jobs -->|"creates workspace"| node_workspace
node_registry -->|"dispatches"| node_libreoffice
node_registry -->|"dispatches"| node_imagemagick
node_registry -->|"dispatches"| node_pdfengine
node_http -->|"handles conversions"| node_jobs
node_http -->|"serves downloads"| node_results
node_http -->|"handles PDF tasks"| node_pdftools
node_http -->|"handles compression"| node_imagecompress
node_http -->|"handles compression"| node_docxcompress
node_jobs -->|"runs PDF tasks"| node_pdftools
node_jobs -->|"compresses images"| node_imagecompress
node_jobs -->|"compresses DOCX"| node_docxcompress
node_docxcompress -->|"compresses embedded images"| node_imagecompress

click node_web "https://github.com/sm-joe/papershift-doc-converter/blob/main/apps/web/src/app/page.tsx"
click node_server "https://github.com/sm-joe/papershift-doc-converter/blob/main/apps/api/main.go"
click node_http "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/handler.go"
click node_app "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/application.go"
click node_capabilities "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/converter/capabilities.go"
click node_formats "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/formats/registry.go"
click node_detection "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/detection/detector.go"
click node_jobs "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/service.go"
click node_workspace "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/workspace.go"
click node_results "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/store.go"
click node_registry "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/converter/registry.go"
click node_libreoffice "https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/libreoffice/libreoffice.go"
click node_imagemagick "https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/imagemagick/imagemagick.go"
click node_pdfengine "https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/pdf/pdf.go"
click node_pdftools "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/pdf/merge.go"
click node_imagecompress "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/image/compress.go"
click node_docxcompress "https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/docx/compress.go"

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_web,node_browser toneBlue
class node_server,node_http,node_app,node_capabilities toneAmber
class node_formats,node_detection,node_jobs,node_workspace,node_results,node_registry toneMint
class node_libreoffice,node_imagemagick,node_pdfengine toneRose
class node_pdftools,node_imagecompress,node_docxcompress toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/sm-joe/papershift-doc-converter/blob/main/apps/web/src/app/page.tsx): `apps/web/src/app/page.tsx`

### API surface

- [API server](https://github.com/sm-joe/papershift-doc-converter/blob/main/apps/api/main.go): `apps/api/main.go`
- [HTTP routes](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/handler.go): `internal/api/handler.go`
- [Application setup](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/api/application.go): `internal/api/application.go`
- [Capabilities](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/converter/capabilities.go): `internal/converter/capabilities.go`

### Conversion processing

- [Format registry](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/formats/registry.go): `internal/formats/registry.go`
- [Format detection](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/detection/detector.go): `internal/detection/detector.go`
- [Job orchestration](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/service.go): `internal/jobs/service.go`
- [Job workspaces](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/workspace.go): `internal/jobs/workspace.go`
- [Result store](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/jobs/store.go): `internal/jobs/store.go`
- [Converter registry](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/converter/registry.go): `internal/converter/registry.go`

### Conversion engines

- [LibreOffice engine](https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/libreoffice/libreoffice.go): `engines/libreoffice/libreoffice.go`
- [Image conversion](https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/imagemagick/imagemagick.go): `engines/imagemagick/imagemagick.go`
- [PDF conversion](https://github.com/sm-joe/papershift-doc-converter/blob/main/engines/pdf/pdf.go): `engines/pdf/pdf.go`

### File operations

- [PDF operations](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/pdf/merge.go): `internal/pdf/merge.go`
- [Image compression](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/image/compress.go): `internal/image/compress.go`
- [DOCX compression](https://github.com/sm-joe/papershift-doc-converter/blob/main/internal/docx/compress.go): `internal/docx/compress.go`

### Other components

- **Browser**

## Connections

- Browser → Web application: uses (evidence: `README.md`)
- Web application → API server: submits files (evidence: `README.md`)
- API server → Application setup: configures (evidence: `apps/api/main.go`)
- API server → HTTP routes: serves (evidence: `apps/api/main.go`)
- Application setup → Converter registry: registers engines (evidence: `internal/api/application.go`)
- Application setup → Job orchestration: creates service (evidence: `internal/api/application.go`)
- Application setup → Format detection: creates detector (evidence: `internal/api/application.go`)
- Application setup → Format registry: loads formats (evidence: `internal/api/application.go`)
- Application setup → Result store: creates store (evidence: `internal/api/application.go`)
- HTTP routes → Capabilities: reports capabilities (evidence: `internal/api/handler.go`)
- Job orchestration → Format detection: detects input (evidence: `internal/jobs/service.go`)
- Job orchestration → Format registry: resolves output (evidence: `internal/jobs/service.go`)
- Job orchestration → Converter registry: selects converter (evidence: `internal/jobs/service.go`)
- Job orchestration → Job workspaces: creates workspace (evidence: `internal/jobs/service.go`)
- Converter registry → LibreOffice engine: dispatches
- Converter registry → Image conversion: dispatches
- Converter registry → PDF conversion: dispatches
- HTTP routes → Job orchestration: handles conversions
- HTTP routes → Result store: serves downloads
- HTTP routes → PDF operations: handles PDF tasks
- HTTP routes → Image compression: handles compression
- HTTP routes → DOCX compression: handles compression
- Job orchestration → PDF operations: runs PDF tasks (evidence: `internal/jobs/service.go`)
- Job orchestration → Image compression: compresses images (evidence: `internal/jobs/service.go`)
- Job orchestration → DOCX compression: compresses DOCX (evidence: `internal/jobs/service.go`)
- DOCX compression → Image compression: compresses embedded images (evidence: `internal/docx/compress.go`)
