ProofMesh is a collaborative workspace for mathematical writing, exploration, and formalization.
It combines a LaTeX lab, a visual proof canvas, a knowledge library, and AI-assisted workflows, with Lean 4 and TeX compilation isolated in dedicated services.
frontend/: Next.js 16 application (TypeScript, Tailwind CSS 4).backend/: FastAPI API server (SQLAlchemy async, PostgreSQL, Redis, MinIO).mesh/: internal AI orchestration/agent package imported by backend.lean-runner/: isolated Lean 4 execution service.latex-compiler/: isolated TeXLive compilation + SyncTeX lookup service.docker-compose.yml: local development stack.docker-compose.prod.yml: production stack with Traefik + HTTPS.Makefile: common development commands.
Runtime services in local development:
frontend(http://localhost:3000)backend(http://localhost:8080, docs at/docs)postgres(localhost:5432)redis(localhost:6379)minio(http://localhost:9000, consolehttp://localhost:9001)lean-runner(localhost:9008)texlive-compiler(internal service, used by backend)canvas-ai-worker(background jobs)
Core flow:
- User actions go through
frontendintobackend. - Backend persists metadata in PostgreSQL and files/artifacts in MinIO.
- Long-running AI canvas jobs are processed by
canvas-ai-workervia Redis. - Lean verification is delegated to
lean-runner. - LaTeX compile and SyncTeX mapping are delegated to
texlive-compiler.
This project is explicitly wired to Gemini 3 for assistant workflows in LaTeX and canvas exploration.
- LaTeX AI chat/edit/autocomplete (frontend server routes):
frontend/src/app/api/latex-ai/chat/route.tsfrontend/src/app/api/latex-ai/edit/route.tsfrontend/src/app/api/latex-ai/autocomplete/route.ts
- Canvas AI routes:
frontend/src/app/api/canvas-ai/explore/route.tsfrontend/src/app/api/canvas-ai/formalize/route.tsfrontend/src/app/api/canvas-ai/critique/route.ts
- Backend orchestration + worker path:
backend/app/api/orchestration.pybackend/app/workers/canvas_ai_worker.pymesh/backend/agents/
gemini-3-flash-previewgemini-3-flash-preview-thinkinggemini-3-pro-preview
Current usage defaults in UI:
- LaTeX Lab mode selector maps to:
flash->gemini-3-flash-previewthinking->gemini-3-flash-preview-thinking
Reference:
frontend/src/app/problems/[id]/lab/page.tsx
Set at least one of:
GEMINI_API_KEYGOOGLE_GENERATIVE_AI_API_KEY
In Docker flow, define them in .env before make dev.
- Start stack with
make dev. - Open
http://localhost:3000/problems/<problem_id>/lab. - In LaTeX Lab AI panel, run one prompt in
Flashmode and one inThinkingmode. - Open
/problems/<problem_id>/canvasand trigger explore/formalize/critique. - Verify responses stream and state transitions complete without API errors.
- API key is present in container env.
backendlogs do not showGEMINI_API_KEY not found.- LaTeX AI routes return content, not fallback errors.
- Canvas AI endpoints produce generated output.
- No 401/403 from frontend server routes using Gemini.
- Docker Engine with Compose plugin
- GNU Make
cp .env.example .env
make devThen open:
- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8080 - API docs:
http://localhost:8080/docs - MinIO Console:
http://localhost:9001
This repository now includes a production stack with Traefik and automatic Let's Encrypt certificates (ACME).
You do not need a separate Certbot container.
- Create your production env file:
cp .env.prod.example .env.prod- Update
.env.prod:
APP_DOMAIN,API_DOMAINTRAEFIK_ACME_EMAIL- strong secrets/passwords (
POSTGRES_PASSWORD,MINIO_ROOT_PASSWORD,JWT_SECRET_KEY, API keys) CORS_ORIGINSwith your frontend domain
-
Point DNS A/AAAA records of those domains to your VPS/public IP.
-
Deploy:
make prod-up- Check certificate provisioning/logs:
make prod-logs-traefikUseful production commands:
make prod-ps
make prod-logs
make prod-down# lifecycle
make dev
make down
make logs
make logs-backend
make logs-frontend
# production
make prod-up
make prod-ps
make prod-logs
make prod-down
# database
make migrate
make migrate-status
make migration
# shells
make shell-backend
make shell-frontend
make shell-db
# data seeding
make seed
make seed-clean
make seed-custom
# cleanup / rebuild
make clean
make rebuild- Backend and frontend run with source mounts for hot reload.
- Backend startup runs migrations via container entrypoint.
mesh/is a Python package mounted into backend; it is not a separate HTTP service.- LaTeX artifacts are stored under MinIO object prefixes (e.g.
latex/<problem_id>/.output/*).
cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
alembic upgrade head
uvicorn app.main:app --reload --host 0.0.0.0 --port 8080cd frontend
npm install
npm run devManual mode still requires PostgreSQL, Redis, MinIO, Lean runner, and LaTeX compiler reachable through the URLs configured in .env.
Use .env.example as the baseline. Important groups:
- Database/queue/storage:
DATABASE_URLREDIS_URLS3_ENDPOINT,S3_ACCESS_KEY,S3_SECRET_KEY,S3_BUCKET,S3_REGION,S3_SECURE
- External/aux services:
LATEX_COMPILER_URLLATEX_COMPILE_TIMEOUTLEAN_RUNNER_URLLEAN_TIMEOUT
- AI keys:
GEMINI_API_KEYGOOGLE_GENERATIVE_AI_API_KEY
- Frontend:
NEXT_PUBLIC_API_URLNEXT_PUBLIC_WS_URLNEXT_PUBLIC_DEMO_CODE_REQUIREDNEXT_PUBLIC_ENABLE_ACCOUNT_AUTH
- Auth policy:
DEMO_ACCESS_CODEDEMO_CODE_REQUIRED_IN_PRODUCTIONALLOW_REGISTRATION_IN_PRODUCTIONALLOW_PASSWORD_LOGIN_IN_PRODUCTION
backend/
app/
api/
models/
schemas/
services/
workers/
alembic/
scripts/
frontend/
src/
mesh/
lean-runner/
latex-compiler/
- Test coverage is currently limited; changes are validated mostly through local runtime checks.
- This repository is optimized for local development and iteration speed over production-hardening defaults.
- Service not updating after code changes (especially
texlive-compiler,lean-runner):
make rebuild-
Backend cannot access private problem or returns auth errors:
- verify
access_tokenin frontend session - verify
NEXT_PUBLIC_API_URLpoints to the current backend
- verify
-
Missing PDFs / compile artifacts:
- check
make logs-backend - check
docker logs proofmesh-texlive-compiler - verify MinIO credentials and bucket from
.env
- check
- Create a branch for the change.
- Keep changes scoped and include reproduction/validation steps in PR descriptions.
- Prefer non-breaking API updates and document any required migrations.