A contextual AI powered markdown reader with threads for deep document exploration and AI-assisted learning.
- What is Threaded?
- Quick Start
- Supported AI Providers
- How to Use
- CLI
- Development
- Deployment
- Architecture
- License
Standard chat interfaces force you into a single, linear timeline. But real thinking isn't linear—it requires exploring tangents, comparing options, and questioning specific details without losing the bigger picture.
Often, samples from an LLM open up more questions which fit in awkwardly with a linear timeline. I find being forced to follow a linear thought path very frustrating so I built Threaded.
Threaded transforms documents into explorable workspaces where you can:
- Think in branches: Highlight any text to spin off a focused discussion about that specific idea.
- Multitask your curiosity: Keep multiple lines of inquiry open simultaneously, side-by-side with your reading.
- Bring your own AI: Use Gemini, OpenAI, Claude, or local Ollama models.
- Stay private: AI processing happens in your browser with your keys. Sessions are stored on the server to enable instant sharing, but are accessible only via their unguessable 21-character IDs. You can also self-host the entire platform on Cloudflare for complete control.
Prerequisites: Node.js 18+, pnpm
pnpm install
pnpm devOpen http://localhost:3000 in your browser.
Configure your provider in the Settings modal:
| Provider | Default Model | Notes |
|---|---|---|
| Google Gemini | gemini-3-flash-preview | Default; best cost/perf |
| OpenAI | gpt-5.2-chat-latest | Full support for custom bases |
| Anthropic | claude-opus-4-5-20251101 | High quality, browser-direct |
| Ollama | qwen3:8b | Cloud in prod, local in dev |
API keys are stored only in your browser's
localStorage.
Development: Start Ollama with CORS enabled:
OLLAMA_ORIGINS=* ollama serveProduction: Local Ollama requires a reverse proxy due to browser CORS restrictions. Using ngrok:
- Start Ollama with CORS:
OLLAMA_ORIGINS=* ollama serve - Expose via ngrok:
ngrok http 11434 - Copy the ngrok URL (e.g.,
https://abc123.ngrok-free.app) - Paste into the Base URL field in Threaded settings
Ollama Cloud: Alternatively, get an API key at ollama.com/settings/keys and leave the Base URL as default.
- Paste markdown content on the start screen (or use the default example).
- Highlight any text to see the action tooltip:
- Discuss — Start an open-ended conversation about the selection.
- Explain — Get a simplified explanation immediately.
- Use the floating input at the bottom to ask questions about the entire document.
- Export the document with all conversations as markdown.
Open local files directly from your terminal:
pnpm install -g @andypai/threaded
threaded ./document.pdfUseful for AI agent workflows—pipe plans or code context into Threaded for deeper analysis.
See cli/README.md for installation options and full documentation.
pnpm dev # Start Vite dev server at http://localhost:3000pnpm dev:full # Starts both Worker and Vite dev serverOr run them separately:
# Terminal 1: Worker
pnpm dev:cf
# Terminal 2: Vite (proxies /api to Worker)
pnpm devOpen local files directly from your terminal:
pnpm cli -- ./your-document.pdf-
Cloudflare Authentication — Run
pnpm wrangler login. -
Local Secrets — Create
.dev.varsfrom the example. -
D1 Database Setup — Create the D1 database and apply the schema:
pnpm wrangler d1 create threaded-db pnpm wrangler d1 execute threaded-db --local --file=migrations/schema.sql
Update the
database_idin bothwrangler.tomlandwrangler.dev.tomlwith the ID returned from the create command.
pnpm deploy:cfWhat happens:
pnpm buildcreates the static bundle indist/.wrangleruploadsdist/via theASSETSbinding and deploys the worker.
Threaded is built as a Cloudflare Worker that serves both a React SPA and a JSON API.
├── App.tsx # State hub & view router
├── cli/ # CLI tool for opening local files
├── components/ # UI components (ThreadPanel, Tooltip, etc.)
├── docs/ # Architecture documentation
├── examples/ # Example markdown files
├── hooks/ # React hooks (useSession, useAiRequest)
├── lib/ # Utilities (API client, formatters)
├── migrations/ # D1 database schema
├── services/ # AI service & content parser
└── worker/ # Cloudflare Worker backend
├── routes/ # API endpoints
└── utils/ # Parsing & validation
POST /api/parse: Convert files/URLs to markdown.POST /api/sessions: Create new shared sessions.GET/DELETE /api/sessions/:id: Manage session data.POST /api/sessions/:id/threads: Anchor new conversations.POST /api/sessions/:id/fork: Clone a session.
MIT



