Inspiration

The theme was Digital Sidekick, and we kept thinking about what makes a good sidekick: they help when you need it and stay out of the way when you don't. Most AI tools just bolt a chat box onto the side of your work. We wanted something that lives inside the document and stays quiet until you ask.

What it does

Lemma is a real-time collaborative LaTeX editor, a bit like Notion, where a few people can edit the same page at once and see each other's cursors.

The sidekick sits next to the collaborator avatars and is collapsed by default. It never interrupts your typing, and nothing goes into the document unless you accept it. Right now it can:

  • turn plain English into LaTeX, so "integral of x squared from 0 to 1" becomes \( \int_0^1 x^2\,dx \)
  • explain an equation in plain language, one step at a time
  • explain why a block won't render and suggest a fix
  • check your work, for example catching that \( (a+b)^2 = a^2 + b^2 \) is missing the \( 2ab \) term
  • suggest what the next step of a derivation could be

$$\int_0^1 x^2\,dx = \frac{1}{3}$$

How we built it

  • Frontend in Next.js and TypeScript, with KaTeX for rendering and shadcn/ui for the components
  • Backend in FastAPI, using Yjs and pycrdt so everyone's edits merge without conflicts
  • The sidekick runs on the Gemini API from Google AI Studio, and it's only called from our backend, so the API key never reaches the browser
  • The backend runs on a laptop and we expose it to the team with a Cloudflare Tunnel
  • Tests with pytest and Playwright, including one that opens two users on the same document

Challenges we ran into

  • The Gemini free tier has small daily limits, so the sidekick only runs when you ask it to, with per-user limits, caching and a mock mode we could build against.
  • Making the sidekick useful without it getting in the way took more tries than the AI part did.
  • Getting the sidekick to show up as a collaborator in the live document without breaking sync for everyone else.

What we learned

  • How CRDTs let lots of people edit at once without overwriting each other
  • That with AI features, quotas and user control matter as much as what the model can do
  • How to put a local server on the internet with a tunnel without leaking secrets

What's next

We'd like the sidekick to pick up on how each person writes their notation, and to host the whole thing so it doesn't depend on a laptop.

Built With

Share this project:

Updates

Submission history