← Back to blog

Spaced Repetition Learning Web Application

3 min read

Spaced Repetition Learning Web Application

Memoria is an AI-powered flashcard and spaced repetition system. The goal is simple: take raw learning material (notes, a chapter, an article), turn it into high-quality flashcards, and then schedule your reviews so you spend time on what you’re about to forget.

Status: In Progress
GitHub: AysajanE/memoria-ai-flashcard-spaced-repetition-web-app
Demo: Not available (no public deployment at the moment)

Project Overview

Memoria combines two workflows:

  1. Create: generate flashcards from text using an AI service (with configurable model, card type, and card count).
  2. Study: review due cards with an Anki-style rating flow (Again / Hard / Good / Easy) and automatic rescheduling.

Key Features

AI-powered flashcard generation

  • Paste in learning material and request card generation (supports multiple AI providers/models via a backend service).
  • Track generation as an asynchronous job (so long requests don’t block the UI).

Spaced repetition (SRS) scheduling

Scheduling is implemented as an Anki-style SM-2 variant with explicit ratings and bounded ease factors. The canonical implementation lives in the Next.js app at nextjs-app/lib/srs.ts in the Memoria repo.

At a high level:

  • Learning phase (new cards): fixed early intervals (e.g., Good → 1 day, Easy → 3 days).
  • Review phase: interval growth depends on rating and ease factor.
  • Ease factor bounds: clamped to [1.3, 2.5] to prevent runaway behavior.

The scheduling function is typed against the database schema (Drizzle) and returns the updated interval/ease/due-date/level:

export type StudyRating = "Again" | "Hard" | "Good" | "Easy";

export function calculateSrsData(
  currentCard: typeof flashcards.$inferSelect,
  rating: StudyRating
): {
  newInterval: number;
  newEaseFactor: number;
  newDueDate: Date;
  newSrsLevel: number;
};

Decks, study sessions, and progress

  • Deck organization and flashcard management.
  • Study experience centered around due cards and honest self-grading.
  • Progress metrics (including streak logic) are part of the app’s data model and utilities.

Educational content

The app includes short articles (Markdown content) explaining spaced repetition and effective study habits.

Technical Implementation

Repository structure

The GitHub repo is a monorepo with two services:

  • nextjs-app/: Next.js web app (frontend + server routes/actions)
  • ai-service/: Python FastAPI service for AI flashcard generation

Tech stack (current)

  • Web app: Next.js (App Router) + TypeScript
  • Auth: Clerk
  • Database: PostgreSQL + Drizzle ORM
  • AI service: FastAPI (Python) with optional Redis-backed queuing
  • Integrations (optional / environment-driven): Redis/Upstash (rate limiting), Supabase (uploads), Stripe scaffolding

AI request flow (high-level)

  1. The user submits text and generation options in the Next.js app.
  2. The app submits an asynchronous request to the AI service (shared secret via INTERNAL_API_KEY).
  3. The AI service processes the job (optionally via Redis/RQ workers) and sends results back via webhook.
  4. The app stores generated cards and they become available for study with SRS scheduling.

Running Locally (developer setup)

The Memoria repo documents local setup in detail, but the working shape is:

  • Configure the Next.js app in nextjs-app/.env.local from nextjs-app/.env.example (Clerk + Postgres + AI service URL/keys).
  • Start the Next.js app: cd nextjs-app && npm install && npm run dev
  • Start the AI service: cd ai-service && pip install -r requirements.txt && uvicorn app.main:app --reload --port 8000
  • For queued processing in development/production, run Redis and the worker process (see ai-service/README.md).

This post is intentionally kept close to the actual implementation details in the Memoria repository. If something here ever drifts, the repo is the source of truth.