LetMeCook web app
Local-first active recall app with dual-persistence (LocalStorage + Postgres) and deterministic mastery logic.

Engineering a Local-First, Hybrid Active Recall System with Next.js & Drizzle
The Elevator Pitch
I engineered LetMeCook Web, a high-performance, privacy-centric port of a deterministic active recall system. By architecting a sophisticated dual-persistence layer that bridges LocalStorage with PostgreSQL, the application delivers a zero-latency learning experience that enforces cognitive stimulation without the reliability issues of traditional cloud-only platforms.
The Problem
Standard flashcard applications often suffer from two major architectural and pedagogical flaws:
- Algorithmic Complacency: Many platforms automate "mastery" based on simple hit-rates, allowing users to "soft-pass" cards through luck rather than deep cognitive effort.
- The Persistence Paradox: Modern learners require the speed and privacy of local-first applications but also demand the synchronization and community-sharing features of cloud-hosted systems.
The Solution
I developed a robust, type-safe Next.js implementation that prioritizes user sovereignty and high-retention learning. The system utilizes a custom storage abstraction layer that seamlessly handles both ephemeral guest sessions via LocalStorage and permanent, shared data via Neon PostgreSQL and Drizzle ORM.
The core philosophy revolves around Deterministic Mastery—a manual, 5-level assessment system that forces rigorous self-judgement, ensuring that "Success = Effort * Consistency."
Key Features
- Deterministic Mastery Assessment: Implemented a manual rating system (New, Don't Know, Okay, I Know, Mastered) that forces active brain stimulation through self-judgement rather than passive, automated "pass/fail" logic.
- Fisher-Yates Shuffle Integration: Engineered a randomized study session engine using the Fisher-Yates algorithm to eliminate "positional memory" bias, ensuring users truly learn content rather than its sequence.
- Hybrid State Abstraction: Architected a unified
AppContextthat manages a dual-persistence pipeline, enabling sub-10ms state updates for both guest (offline) and authenticated (cloud) users. - Data Migration Engine: Designed a purpose-built promotion pipeline that validates and transforms LocalStorage schemas into relational database records upon user registration.
- Scientific UX Enhancements: Integrated LaTeX rendering for technical content and Text-to-Speech (TTS) support to provide a multi-sensory, high-impact learning environment.
Tech Stack
| Category | Technologies Used |
|---|---|
| Framework | Next.js 16 (App Router), React 19 |
| Persistence | Neon PostgreSQL, LocalStorage API |
| ORM & Database | Drizzle ORM, Server Actions |
| Styling & UI | Tailwind CSS 4, Framer Motion, Radix UI |
| Utilities | LaTeX (MathJax/KaTeX), Lucide React |
The "Why": Overcoming Technical Challenges
Challenge: Synchronizing Ephemeral and Persistent States Managing state consistency between a synchronous local storage and an asynchronous PostgreSQL backend introduced significant race conditions and schema drift risks, especially during the "guest-to-user" transition.
Solution: I architected a debounced persistence adapter that treats LocalStorage as a high-speed write-through cache. For the migration process, I built a custom Migration Engine that:
- Performs a runtime validation of the guest's JSON schema using TypeScript guards.
- Transforms flat LocalStorage Decks into relational
projectsandflashcardstables. - Executes a transactional batch insert to ensure data integrity, preventing partial migrations if a network error occurs.
Challenge: Server Action Resource Abuse Exposing card creation via Server Actions made the database vulnerable to automated brute-force attacks or "junk deck" generation.
Solution: I implemented an in-memory Rate Limiter on the server side. By tracking client signatures and request frequency, the system can transparently throttle abusive traffic without requiring an external Redis instance, maintaining the project's lean, high-performance architecture.
Results & Impact
- Performance: Achieved sub-1ms UI latency for core study loops by prioritizing local-first state updates over network confirmation.
- Availability: Delivered 100% offline capability, allowing users to maintain consistency regardless of internet connectivity.
- Scale: Successfully migrated hundreds of test cards from local environments to the cloud database with zero data loss.
- Learning Efficiency: Integrated scientific tools (LaTeX/TTS) that significantly broadened the app's utility for STEM students.