Skip to content

crafter-station/latex0

Repository files navigation

LATEX0

LATEX0

The Future of Typesetting

Website · Issues

Next.js Supabase TypeScript Monaco Editor

Built by Crafter Station

About

LATEX0 is an AI-powered LaTeX editor for the modern era. Write, compile, and collaborate in real-time.

Researchers deserve open source tools.

Features

  • AI Assistant — Chat with AI to generate and edit LaTeX code
  • Real-time Collaboration — See other users' cursors live with unique colors
  • Document Persistence — Save and manage multiple documents with auto-save
  • Monaco Editor — VS Code-quality editing with LaTeX syntax highlighting
  • Live Preview — Instant PDF rendering as you type
  • Hybrid Authentication — Sign in with Google/GitHub via Clerk, or work as a guest

Quick Start

# Clone
git clone https://github.com/crafter-station/latex0.git
cd latex0

# Install
bun install

# Configure
cp .env.example .env.local
# Add your environment variables (see below)

# Set up database
bun db:push

# Run
bun dev

Open http://localhost:3000

Environment Variables

Required

# Supabase (for real-time collaboration)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_supabase_key

# Database (for document persistence)
DATABASE_URL=your_postgresql_connection_string

# AI Gateway (for chat functionality)
AI_GATEWAY_API_KEY=your_ai_gateway_key

# Latex Renderer
NEXT_PUBLIC_LATEX_API_KEY=
NEXT_PUBLIC_LATEX_API_URL=

Optional

# Authentication (Clerk - enables Google/GitHub OAuth)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
CLERK_SECRET_KEY=your_clerk_secret

# Rate Limiting (Upstash Redis)
UPSTASH_REDIS_REST_URL=your_upstash_url
UPSTASH_REDIS_REST_TOKEN=your_upstash_token

Note: Guest users can use the editor without authentication. Only authenticated users (via Clerk) can save and persist documents.

Database Setup

The project uses Drizzle ORM with PostgreSQL (via Supabase).

Initial Setup

# Generate migration files
bun db:generate

# Push schema to database
bun db:push

# Open Drizzle Studio (database GUI)
bun db:studio

Schema

The documents table stores saved LaTeX documents:

  • id — Unique document ID (nanoid)
  • title — Document title
  • content — LaTeX source code
  • folder — Organization folder (default: "root")
  • user_id — Owner's Clerk user ID
  • created_at, updated_at — Timestamps

Migrations

Migration files are stored in drizzle/ and version-controlled. The schema is defined in lib/db/schema.ts.

Architecture

  • Repository Pattern — Data access abstraction in lib/db/repositories/
  • API Routes — Next.js API routes handle CRUD operations with Clerk authentication
  • No RLS — Authorization is handled in API routes (not Supabase RLS) since Drizzle uses direct database connection
  • Auto-save — Documents auto-save every 2 seconds while editing
  • URL Routing — Each document has a unique URL (/playground/{id})

License

MIT


Built with care by Crafter Station

About

Resources

Stars

11 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors