The Nightmare Scenario
You've spent 90 minutes configuring an assignment. You uploaded source notes, selected question types, set the marks distribution, crafted the perfect mix of MCQs and written questions, and added detailed instructions for the AI generator. You're about to click 'Generate paper' when your browser crashes. Or your laptop battery dies. Or you accidentally close the wrong tab.
When you reload the page, everything is gone. Every decision, every configuration, every carefully crafted setting—vanished. You have to start from scratch, wasting another hour of preparation time that you don't have. This isn't just frustrating—it's a barrier to using digital tools for assignment creation.
The problem isn't unique to our platform. Teachers face this risk every time they use web-based tools for lesson planning. The cost isn't just the time lost—it's the hesitation to use powerful tools because the fear of data loss outweighs the potential benefits.
Why Traditional Auto-Save Isn't Enough
Many applications have auto-save, but they often implement it poorly. Some save only when you click a specific button, which you forget to click. Others save too frequently, creating performance issues. Some overwrite previous drafts without a way to recover earlier versions. The worst ones save silently without any indication that your work is safe.
For assignment creation, the stakes are higher than a simple document. You're not just typing text—you're making complex configuration decisions across multiple sections. Source material, question types, marks distribution, bloom levels, additional instructions—a lot can go wrong, and losing any part of it breaks the whole assignment.
We needed a system that saves automatically, provides clear feedback, allows recovery, and manages drafts intelligently so they don't collide across different assignments.
Our Solution: Intelligent Draft Management
We built a draft management system that combines automatic saving, manual recovery, and smart cleanup. The system saves to localStorage every 30 seconds or when you make significant changes. It shows a 'Last saved' indicator with a human-readable timestamp ('Just now', '5m ago', '2h ago') so you always know your work is safe.
When you return to the assignment creation page, the system checks for existing drafts. If it finds one with content, it shows a restoration prompt: 'Draft available. Resume your work from a previous session?' You can choose to restore the draft and continue where you left off, or discard it and start fresh.
Drafts are managed per assignment context, so creating a new assignment doesn't overwrite the draft of another one. Each draft gets a unique ID based on timestamp and a random token, preventing collisions. Drafts older than 7 days are automatically cleaned up to prevent localStorage bloat.
How It Works Under the Hood
The draft manager is implemented as a TypeScript module (`frontend/lib/draftManager.ts`) with a clean API. `saveDraft()` serializes the current assignment state and stores it in localStorage with a prefixed key (`vedai_draft_[id]`). The draft includes all configurable fields: subject, title, due date, additional info, file content, file name, question rows, and paper versions.
When you click 'Generate paper' and the assignment is successfully created, the system automatically clears the draft. This prevents the old draft from persisting after you've completed the work. The cleanup is silent—you don't need to remember to delete drafts manually.
The restoration prompt is dismissible. If you choose not to restore a draft, you can still retrieve it later because the draft persists until you either use it or explicitly discard it. This gives you control over your data while still providing the convenience of automatic saving.
The UX Details That Matter
Good auto-save isn't just about the technical implementation—it's about making the user feel safe. We added several UX touches that make the system trustworthy. The 'Last saved' indicator uses a green dot and relative time, making it easy to glance and know your work is current. The restoration prompt uses a success-colored card with clear action buttons, making it obvious but not intrusive.
The draft restoration shows all the saved data: your subject, title, source material, question configuration, everything. This helps you verify it's the right draft before committing to it. If you accidentally restore the wrong draft, you can clear it and the system will let you know your work is safe.
We also added a 'Reset to standard' button that restores the default question template. This is separate from draft management—it's about quickly returning to a known good state when you've made too many experimental changes. Both features work together to give teachers confidence to experiment without fear of getting stuck in a broken state.
Privacy and Performance
Using localStorage means draft data never leaves your browser until you explicitly submit the assignment. This is a privacy advantage—your source notes and assignment configurations aren't transmitted or stored on our servers until you're ready. Auto-save happens entirely client-side with no network calls.
The performance impact is negligible. Saving to localStorage is fast (<10ms for typical assignments), and the 30-second interval ensures we're not constantly writing. The system uses a debounced save on field changes, so rapid typing doesn't trigger excessive writes. Even with complex source files, the auto-save doesn't impact the creation experience.
For schools concerned about localStorage limits (typically 5-10MB), we store only the essential configuration data, not the full processed output. Source text is compressed or truncated if necessary, though in practice most assignment configurations fit easily within limits.
From Risk to Confidence
Before this system, creating a complex assignment in a web browser felt risky. Teachers hesitated to invest time in digital tools because one crash could waste an hour of work. Now, the risk is eliminated. You can close your browser mid-creation, come back hours later, and resume exactly where you left off.
This changes how teachers work. You can start an assignment in the morning, realize you need to reference a textbook, close the browser, and finish in the evening without losing any work. You can experiment with different question configurations, knowing you can always revert to a saved state. The tool becomes a reliable part of your workflow rather than a risky addition.
The psychological benefit is significant. When you know your work is automatically saved, you focus on the content—crafting better questions, refining the difficulty, ensuring alignment with your lesson—rather than worrying about data loss. That's exactly what a productivity tool should do: remove friction so you can focus on what matters.
Future Enhancements
We're planning cloud-based draft persistence as an optional enhancement. This would allow you to start an assignment on one device and continue on another. The localStorage version would remain as the default for privacy-conscious users, with cloud sync as an opt-in feature.
We're also exploring versioned drafts, which would save snapshots at key points (before major configuration changes) so you can revert to earlier versions if you go down a wrong path. This would be particularly useful for teachers who like to experiment with different approaches.
Finally, we're considering collaborative drafts for teachers working in teams. Multiple teachers could work on the same assignment draft simultaneously, with conflict resolution similar to Google Docs. This would extend the benefits of draft management to team-based curriculum development.
The Bottom Line
Auto-save with draft management isn't a flashy feature. It doesn't have the visible impact of AI question generation or the complexity of anti-cheating systems. But it's the foundation that makes everything else possible. When teachers trust that their work won't be lost, they're willing to invest time in using digital tools. When data loss isn't a risk, experimentation becomes viable. When you can close and reopen without fear, the tool becomes a reliable partner rather than a risky proposition.
This is how we solve the problem of data loss: not by asking teachers to be more careful, but by making the system safe by default. It's a simple principle with profound impact on teacher confidence and productivity.

