Litewrite: AI-Powered Collaborative LaTeX Writing Platform
News β’ Features β’ Screenshots β’ Architecture β’ AI Features β’ nanobot β’ Quick Start β’ Contributing
- 2026-02-10 π€ **nanobot Γ Litewrite β nanobot empowers your vibe writing (setup guide)
- 2026-02-03 π Litewrite v1.0.7 β Real-time collaboration, LaTeX compilation & AI chat.
π TAP Smart Completion β Type a few words, AI continues writing for you. Just hit Tab and you're all set!
π¬ ASK Mode β Summon your AI assistant anytime. Grammar issues? Format problems? Just ask!
π€ Agent Mode β The ultimate hands-off writing experience! AI automatically edits, polishes, formats!
π Deep Research β AI conducts in-depth research and auto-generates reports. Research while you write!
π± nanobot β Chat with your projects from IM apps. Compile, edit, and manage β all from your phone!
π¬ Chat with your projects from IM apps
Click to expand screenshots
AI-integrated vibe writing β lite, fast, effortless
10+ pre-built templates: NeurIPS, ACM, Beamer, CV, Thesis, and more
Quick insert Greek letters, math operators, and LaTeX constructs
Search and insert BibTeX citations with fuzzy matching
Create snapshots, compare diffs, and restore any previous version
Share via link or invite collaborators by email
π‘ Try it yourself: Visit litewrite.ai for the live demo!
Litewrite is a microservices architecture with 6 core services communicating over a Docker network.
| Service | Port | Technology | Role |
|---|---|---|---|
| π Next.js | 3000 | TypeScript, React | Web app, API routes, auth, project management |
| π WebSocket | 1234 | Node.js, Yjs | Real-time collaboration, document sync, chat rooms |
| π§ AI Server | 6612 | Python, FastAPI | TAP completion, Chat Agent, Deep Research |
| π Compile | 3002 | Node.js, TeXLive | LaTeX compilation (pdfLaTeX/XeLaTeX/LuaLaTeX) |
| π€ nanobot | β | Python, LiteLLM | Telegram/Feishu bot, Litewrite project operations |
| β‘ Redis | 6379 | Redis | Yjs persistence, rate limiting, caching |
π All internal service-to-service communication is authenticated via
X-Internal-Secretheader.
Litewrite's AI capabilities are powered by a modular Agent system built on Python FastAPI. The architecture follows a MainAgent + SubAgent orchestration pattern with a unified Tool layer.
Ghost-text AI completion as you type, similar to GitHub Copilot.
| Stage | Description |
|---|---|
| Input | prefix (text before cursor) + suffix (text after cursor) |
| Processing | Boundary extraction β Scenario detection β LLM inference |
| Output | Action type (insert / complete_word / fix / skip) + suggested text |
| Post-processing | Boundary fixups β Diff computation β Frontend rendering |
The Agent system uses a ReAct-style loop with tool calling for complex writing tasks.
Mode-based Tool Availability:
| Tool | Ask Mode | Agent Mode | Description |
|---|---|---|---|
read_file |
β | β | Read file content with line ranges |
list_files |
β | β | List project files and structure |
web_search |
β | β | Search the web for information |
arxiv_search |
β | β | Search arXiv papers with RAG |
plan |
β | β | Generate step-by-step plan |
done |
β | β | Signal task completion |
edit_file |
β | β | Edit file with diff preview |
task |
β | β | Delegate to SubAgent |
Context Management:
- π¦ Session history limit: 64K tokens (configurable)
- π¦ Execution context limit: 64K tokens (configurable)
- π Automatic LLM-based compression when threshold (95%) is exceeded
- π‘οΈ Shadow documents for safe edit preview (or direct-apply for trusted callers)
Multi-source research with automatic report generation.
All tools inherit from a base Tool class with standardized interfaces:
class Tool(ABC):
name: str # Tool identifier
description: str # LLM-readable description
parameters: dict # JSON Schema for parameters
mode: ToolMode # ask / agent / all
async def execute(params, context) -> ToolResultThe ToolContext provides:
- π Project and user information
- π‘ SSE event emitter for real-time frontend updates
- π
direct_applyflag for trusted callers (bypasses shadow documents) - π Shared usage accumulator for token tracking
π± nanobot β Chat Platform Integration
nanobot is an AI assistant that connects messaging platforms (Telegram, Feishu/Lark) to Litewrite, enabling users to manage LaTeX projects through natural language conversations.
π For detailed setup instructions, see the nanobot Deployment Guide.
nanobot provides 20 Litewrite tools for comprehensive project management:
| Category | Tools |
|---|---|
| π― Core | List projects, invoke Litewrite AI agent, compile to PDF |
| π File Operations | List, read, edit, create, rename, delete, upload files |
| π¦ Project Management | Create, delete, rename projects |
| π Version Control | List, save, restore versions |
| π₯ Import | Import from arXiv, GitHub/GitLab, or file upload |
- π¬ User sends a message in Telegram or Feishu
- π§ nanobot's agent processes the message with LLM reasoning
- π§ Agent decides which Litewrite tools to call
- π Tools communicate with Litewrite via Internal API (
X-Internal-Secret) - π€ Results (text, PDF, etc.) are sent back to the chat platform
- π Per-project session cache: consecutive calls reuse the same conversation
- ποΈ Sessions appear in the Litewrite web UI as "nanobot" conversations
- π€ The
litewrite_agenttool delegates complex tasks to Litewrite's built-in AI agent, combining nanobot's chat interface with Litewrite's full editing capabilities
- Docker Desktop (includes Docker Compose)
- 8GB+ RAM recommended (TeXLive image is ~5GB)
# Clone the repository
git clone https://github.com/hkuds/litewrite.git
cd litewrite
# Start with one command
./scripts/up-dev.shThis will:
- Create
.envfromenv.example.ossif missing - Pull/build all Docker images
- Start the full stack (web, ws, ai-server, compile, minio, redis)
| Service | URL | Description |
|---|---|---|
| π App | http://localhost:3000 | Main application |
| π¦ MinIO | http://localhost:9001 | Object storage console (minioadmin/minioadmin) |
| π§ AI Server | http://localhost:6612/health | AI services health check |
| π Compile | http://localhost:3002/health | LaTeX compile service |
# With custom env files
./scripts/up-prod.sh --env-file .env.production --env-file .env.secretsπ Required Environment Variables
| Variable | Description |
|---|---|
NEXTAUTH_SECRET |
Random string for session encryption |
INTERNAL_API_SECRET |
Internal service authentication |
DATABASE_URL |
PostgreSQL connection string |
S3_BUCKET |
S3 bucket name |
S3_REGION |
S3 region |
S3_ACCESS_KEY_ID |
S3 access key |
S3_SECRET_ACCESS_KEY |
S3 secret key |
OPENROUTER_API_KEY |
AI service API key |
See env.example.oss for the complete configuration reference.
|
|
|
|
| Feature | Description |
|---|---|
| π LaTeX Editor | Built on CodeMirror 6 with syntax highlighting, smart completion, bracket matching, and folding |
| π Markdown Editor | Full GFM support with code highlighting, math rendering (KaTeX), and live preview |
| ποΈ Visual Editing | Typora-like WYSIWYG: renders content while editing, shows source at cursor position |
| π Multi-file Projects | Organize large documents with \input{}, \include{}, and proper file tree management |
| Feature | Description |
|---|---|
| β‘ TAP Completion | Ghost-text AI completion as you type (Cursor/Copilot-like experience) |
| π¬ Ask AI | Select text and ask AI to explain, improve, translate, or rewrite |
| π€ Agent Mode | Full autonomous editing β AI reads, plans, and applies multi-file edits |
| π Deep Research | Multi-iteration research: web + arXiv search, structured report generation with BibTeX |
| π AI Table | Generate LaTeX tables from natural language descriptions |
| π± nanobot | Manage projects from Telegram/Feishu: edit files, compile PDFs, import papers |
| Feature | Description |
|---|---|
| π Real-time Collaboration | Multiple users editing simultaneously with cursor presence indicators |
| π Version History | Create snapshots, compare diffs, and restore any previous version |
| π Sharing | Share projects via link with granular view/edit permissions |
| Feature | Description |
|---|---|
| π§ Multiple Engines | pdfLaTeX, XeLaTeX, LuaLaTeX with full TeXLive distribution |
| ποΈ Live Preview | Auto-compile on save with instant PDF preview |
| π SyncTeX | Bi-directional navigation: click PDF to jump to source, click source to highlight PDF |
| π¦ Export Options | Download PDF, source ZIP, or individual files |
litewrite/
βββ app/ # Next.js App Router pages & API routes
β βββ api/ # REST API + Internal API endpoints
β βββ editor/ # Editor page
β βββ (home)/ # Dashboard pages
βββ components/ # React components
β βββ editor/ # Editor-specific components
β βββ pdf-viewer/ # PDF preview components
β βββ ui/ # Shadcn UI components
βββ lib/ # Shared utilities
βββ prisma/ # Database schema & migrations
β
βββ server/ # WebSocket collaboration server
β βββ ws-server.ts # Yjs WebSocket + HTTP endpoints
β βββ yjs-persistence.ts # Redis-based Yjs persistence
β
βββ ai-server/ # AI service (Python FastAPI)
β βββ api/ # Chat, TAP, Deep Research endpoints
β βββ services/ # Service implementations
β β βββ chat_1_5/ # Agent system (MainAgent + SubAgents)
β β βββ tap/ # TAP completion service
β β βββ deep_research/ # Multi-iteration research
β βββ tools/ # Agent tools (read, edit, search, etc.)
β βββ core/ # Config, LLM client, caching
β
βββ compile-server/ # LaTeX compilation service
β
βββ nanobot/ # Chat platform AI assistant
β βββ nanobot/
β βββ agent/ # LLM agent loop + 20 Litewrite tools
β βββ channels/ # Telegram, Feishu, WhatsApp adapters
β βββ bus/ # Async message bus
β βββ config/ # Environment-based configuration
β βββ skills/ # Extensible skill system
β
βββ docker-compose.yml # Development configuration
βββ docker-compose.prod.yml # Production configuration
βββ scripts/ # Setup & deployment helpers
# Start development environment
docker compose up
# Start in background
docker compose up -d
# View logs
docker compose logs -f web
docker compose logs -f ai-server
docker compose logs -f nanobot
# Rebuild specific service
docker compose up --build web
# Reset database
docker compose exec web npx prisma migrate reset
# Run TypeScript check
npm run typecheck| Directory | Service | Auto-reload |
|---|---|---|
app/, components/, lib/ |
Next.js | β |
server/ |
WebSocket | β |
ai-server/ |
AI Server | β |
nanobot/ |
nanobot | β |
compile-server/ |
Compile | β (rebuild needed) |
π Click to expand full list
| Variable | Description | Default |
|---|---|---|
NEXTAUTH_SECRET |
NextAuth encryption secret | (required) |
INTERNAL_API_SECRET |
Internal service auth | (required) |
DATABASE_URL |
Database connection | file:./dev.db |
| Variable | Description | Default |
|---|---|---|
OPENROUTER_API_KEY |
LLM API key (required for AI features) | β |
OPENROUTER_API_KEYS |
Multiple keys for rotation | β |
OPENROUTER_KEY_STRATEGY |
Key rotation: round_robin, random, least_used |
round_robin |
LLM_MODEL |
Default LLM model | google/gemini-3-flash-preview |
EMBEDDING_API_BASE |
Embedding API URL | https://openrouter.ai/api/v1 |
EMBEDDING_API_KEY |
Embedding API key | β |
EMBEDDING_MODEL |
Embedding model | text-embedding-3-small |
SERPER_API_KEY |
Web search (for Deep Research) | β |
| Variable | Description | Default |
|---|---|---|
TELEGRAM_ENABLED |
Enable Telegram bot | false |
TELEGRAM_BOT_TOKEN |
Telegram bot token from @BotFather | β |
FEISHU_ENABLED |
Enable Feishu bot | false |
FEISHU_APP_ID |
Feishu app ID | β |
FEISHU_APP_SECRET |
Feishu app secret | β |
NANOBOT_DEFAULT_LITEWRITE_USER_ID |
Litewrite user UUID for project ownership | β |
| Variable | Description | Default |
|---|---|---|
STORAGE_PROVIDER |
s3 or local |
s3 |
S3_ENDPOINT |
S3 endpoint URL | http://localhost:9000 |
S3_BUCKET |
S3 bucket name | litewrite |
S3_REGION |
S3 region | us-east-1 |
S3_ACCESS_KEY_ID |
S3 access key | β |
S3_SECRET_ACCESS_KEY |
S3 secret key | β |
| Variable | Description | Default |
|---|---|---|
REDIS_URL |
Redis URL (enables Yjs persistence + rate limiting) | β |
NEXT_PUBLIC_WS_URL |
Public WebSocket URL for clients | ws://localhost:1234 |
TAP_MODEL |
Override model for TAP completion | (uses LLM_MODEL) |
π See
env.example.ossfor the complete template.
We welcome contributions! Please see our Contributing Guide for details.
# Quick contribution workflow
git clone https://github.com/hkuds/litewrite.git
cd litewrite
git checkout -b feature/your-feature
# Make your changes
git commit -m "feat: add amazing feature"
git push origin feature/your-feature
# Open a Pull RequestLitewrite is built on the shoulders of giants:
- Next.js β React framework
- CodeMirror β Code editor
- Yjs β CRDT for collaboration
- Prisma β Database ORM
- TeXLive β TeX distribution
- Shadcn UI β UI components
- OpenRouter β LLM routing
- LiteLLM β LLM provider abstraction
- nanobot β Ultra-lightweight AI assistant











