Skip to content

alfredang/texpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TeXPad

Node.js Fastify Tectonic Claude License

A minimal, browser-based LaTeX authoring tool with real PDF compilation and a Claude AI co-author.

Report Bug · Request Feature

Screenshot

Screenshot

About

TeXPad is a self-hosted, AI-first slice of Overleaf. Write LaTeX in the browser, watch a real PDF render in the preview pane, and ask Claude to draft or revise sections via the chat sidebar — Claude can also search the web to ground its writing in real facts before editing your document.

Key features

Feature Description
Real LaTeX compilation Server-side Tectonic compiles .tex → PDF on every edit (debounced). No WASM, no quirky JS subsets — real publisher-quality output.
AI chat sidebar Type "Write an introduction on quantum tunneling" and Claude edits your document in place via three in-process tools (get_document, replace_range, replace_document).
Web research Claude's built-in WebSearch tool grounds claims in real sources before writing.
Templates One-click NeurIPS, IEEE, Physical Review Letters / D, arXiv, and blank starters.
Claude subscription auth Uses the local claude CLI — no API key, just your Claude.ai Pro / Max session.
Open any local file Uploaded files become reusable user templates.
Save / Export Cmd/Ctrl+S writes .tex to disk; one click downloads the compiled PDF.
Undo AI edits Every assistant edit is reversible from the chat panel.
Dark / light theme Minimalist UI, dark by default.

Tech stack

Category Tools
Frontend Vanilla JS (ES modules), HTML5, CSS custom properties, browser-native <iframe> PDF viewer
Backend Node.js 18+, Fastify, @fastify/static
LaTeX engine Tectonic (Rust, auto-fetches packages on demand)
AI @anthropic-ai/claude-agent-sdk with custom MCP tools, Claude WebSearch
Auth Claude Code CLI (subscription OAuth) — no API key required

Architecture

┌──────────────────────── Browser ────────────────────────┐
│                                                         │
│   Editor  ──┐         ┌─── PDF iframe ───┐  Chat panel  │
│   <textarea>│         │  (browser PDF)   │  (SSE)       │
│             │         └──────────────────┘              │
└─────────────┼─────────────────────────────┬─────────────┘
              │ POST /api/compile           │ POST /api/chat (SSE)
              ▼                             ▼
┌──────────── Node.js · Fastify ─────────────────────────┐
│                                                        │
│   compile.mjs ──spawn──▶ tectonic ──main.pdf──┐        │
│                                               │        │
│   chat.mjs ───query()──▶ Claude Agent SDK     │        │
│       │                       │               │        │
│       │       MCP tools:      │   WebSearch   │        │
│       │       get_document    │   (Anthropic) │        │
│       │       replace_range   │               │        │
│       │       replace_document│               │        │
└───────┼───────────────────────┼───────────────┼────────┘
        │                       │               │
        ▼                       ▼               ▼
   In-process doc state    claude CLI       PDF bytes
   (per chat session)      (subscription)

Project structure

texpad/
├── server/
│   ├── index.mjs        # Fastify app + routes
│   ├── compile.mjs      # Spawns Tectonic, returns PDF
│   └── chat.mjs         # Claude Agent SDK + 3 doc tools
├── public/
│   ├── index.html       # Single-page UI
│   ├── app.js           # Editor, PDF preview, chat client
│   ├── styles.css       # Minimalist theme tokens
│   └── templates.js     # Built-in LaTeX templates
├── package.json
├── .env.example
└── README.md

Getting started

Prerequisites

  • Node.js 18+
  • Tectonicbrew install tectonic (macOS) · other platforms
  • Claude Code CLInpm install -g @anthropic-ai/claude-code then run claude /login to authenticate with your Claude.ai subscription

Install & run

git clone https://github.com/alfredang/texpad.git
cd texpad
npm install
npm run dev

Open http://localhost:3030.

  1. Click cfg (top right) → Test connection to verify Claude auth.
  2. Pick a template from the dropdown.
  3. In the AI panel: "Add a Methods section with the equation for self-attention from the Transformer paper."

Endpoints

Method Path Description
GET /healthz Sanity check + Tectonic version
POST /api/compile Body {source} → PDF bytes or {ok:false, log}
POST /api/test-claude Verify Claude Code subscription auth
POST /api/chat SSE stream of text/tool/edit events

Why it can't run on Vercel

TeXPad needs a real Linux host (Fly.io, Railway, a VPS, your laptop) because:

  • Tectonic is a system binary, not a JS package — not available in Vercel functions.
  • Claude Agent SDK spawns the claude CLI subprocess, which can't run in serverless.
  • Subscription OAuth tokens (sk-ant-oat01-…) only work via the local claude CLI.

If you want a hosted demo, the right move is a Dockerfile on Fly.io / Railway with a regular sk-ant-api03-… API key in env. Run locally otherwise.

Contributing

  1. Fork the repo
  2. Create a feature branch: git checkout -b feature/amazing-thing
  3. Commit: git commit -m "feat: add amazing thing"
  4. Push: git push origin feature/amazing-thing
  5. Open a Pull Request

Developed by

Tertiary Infotech Academy Pte. Ltd.

Acknowledgements

  • Tectonic — modernised, self-contained LaTeX engine
  • Anthropic — Claude Agent SDK and WebSearch tool
  • Fastify — fast Node.js web framework

If you find TeXPad useful, please ⭐ star the repository.

About

Browser LaTeX authoring tool with real Tectonic compilation and a Claude AI co-author. Minimalist Overleaf alternative with web-grounded research.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors