Strawie
A Python classroom in the browser where a tutor and students write code together, with nothing to install.
How it came together
1. Editing together without a central referee
Problem: I first taught kids with Replit, and they found it intimidating. I wanted one shared page where a class could write code together with no setup.
Choice: I used a CRDT (Yjs) rather than operational transformation. OT needs a central server that transforms every edit, and Python has no mature OT server library. A CRDT lets edits merge on their own, and the same approach also covers the shared whiteboard.
Result: The first version was a relay: the server passed edits between browsers and kept nothing itself.
2. Making the server own the document
Problem: Students reported that their code disappeared. Once everyone left a room, the relay had nothing to give back, and browsers that joined an empty room raced each other to fill it.
Choice: The server now keeps one document per room, fills each room only once, and saves it 2 seconds after the last edit, when the last person leaves, and at shutdown.
Result: Code stopped disappearing. This also made private rooms possible: each student gets a personal copy, built on the server with the solutions and tests removed.
3. Never running student code on the server
Problem: Code originally ran on the server inside a blocklist sandbox, which any signed-in user could reach and which can be bypassed. Proper container isolation wasn’t available on the hosting plan.
Choice: All Python now runs in the student’s browser, in a Web Worker. Homework is graded there too, against the teacher’s tests, and the server only stores the result. I deleted about 1,100 lines of server execution code.
Result: The server never runs untrusted code. The tradeoff I accepted is that a determined student could fake their own grade, which matters little in a tutoring class.
4. Fewer layers before the first line of code
Problem: The old model of classrooms and assignments shared one room per assignment, so students could see each other’s homework, and a tutor needed several steps before anyone could code.
Choice: Lessons are tied to the class schedule, and each lesson is a notebook page of text and code blocks. I decided against a reusable topic library, because it would make setup harder.
Result: A tutor opens the scheduled lesson and starts. Word problems are now text blocks instead of code wrapped in quotes.
What broke
After a deploy, the app sent users in an endless loop between the landing page and the app. A database query compared a JSON column inside a UNION, which Postgres can’t do, so the request failed, and the app treated every error as “not signed in”. I rewrote the query, redirected only on a real 401, and added a regression test.
Next
Live code previews in the tutor’s view of student copies.