Freezmo: self-hosted notes-to-activities study app

Next.js 15 app that turns photos, PDFs, DOCX/PPTX and text into a swipeable
feed of AI-generated activities (flashcards, multiple choice, true/false,
fill-in-the-blank, matching, ordering, short answer) using the user's own
Ollama models.

Highlights:
- All AI calls run in server route handlers; the browser never talks to Ollama.
- Bring-your-own-key mode (default): the key lives only in the browser and is
  sent per-request; server, local-daemon and shared-key modes also supported.
- Client-side document extraction (pdf.js, mammoth, jszip) with scanned-PDF
  page rendering for the vision model; notes stay in their original language.
- ChatGPT-style shell: collapsible sidebar / mobile drawer, neutral token-based
  light + dark themes, folder organisation, PWA (manifest, SW, offline page).
- Strict JSON validation with zod + auto-repair, rate limiting, and request
  guards (cross-origin, body-size, API-key sanitising).
- setup.sh bootstraps deps, .env.local and a production build.

Gitignore excludes .env*, the generated pdf.js worker and local scratch files.
This commit is contained in:
Martin Dvořák 2026-10-06 20:56:55 +00:00
commit 3ea2cea100
83 changed files with 10909 additions and 165 deletions

View file

@ -0,0 +1,92 @@
"use client";
import { motion } from "framer-motion";
import { useState } from "react";
import type { Activity } from "@/lib/schemas";
import { Button } from "@/components/ui";
import {
ActivityHeader,
FeedbackPanel,
Hint,
PromptCard,
QuestionText,
type ActivityComponentProps,
} from "./shared";
type FlashcardActivity = Extract<Activity, { type: "flashcard" }>;
export function Flashcard({ activity, onAnswered, onNext, isLast }: ActivityComponentProps<FlashcardActivity>) {
const [flipped, setFlipped] = useState(false);
const [result, setResult] = useState<boolean | null>(null);
const settle = (correct: boolean) => {
if (result !== null) return;
setResult(correct);
onAnswered(correct);
};
return (
<>
<ActivityHeader type="flashcard" topic={activity.topic} />
<Hint>{flipped ? "Did you know it before flipping?" : "Tap the card to flip it."}</Hint>
<button
type="button"
onClick={() => setFlipped((value) => !value)}
className="group relative block w-full text-left [perspective:1400px]"
aria-label={flipped ? "Flip back to the question" : "Reveal the answer"}
>
<motion.div
animate={{ rotateX: flipped ? 180 : 0 }}
transition={{ type: "spring", stiffness: 220, damping: 24 }}
className="relative min-h-56 w-full [transform-style:preserve-3d]"
>
<PromptCard className="absolute inset-0 flex flex-col justify-center gap-3 group-hover:border-frost-300 [backface-visibility:hidden]">
<span className="text-xs font-bold uppercase tracking-widest text-frost-600 dark:text-frost-200">
Question
</span>
<QuestionText>{activity.front}</QuestionText>
<span className="mt-2 text-xs font-semibold text-slate-400 dark:text-slate-400">
tap to flip ↻
</span>
</PromptCard>
<div className="[transform:rotateX(180deg)] [backface-visibility:hidden]">
<div className="card flex min-h-56 flex-col justify-center gap-3 px-5 py-6 sm:px-6">
<span className="text-xs font-bold uppercase tracking-widest text-frost-600 dark:text-frost-200">
Answer
</span>
<p className="text-lg font-semibold leading-relaxed text-frost-950 dark:text-frost-50">
{activity.back}
</p>
</div>
</div>
</motion.div>
</button>
{flipped && result === null ? (
<div className="grid grid-cols-2 gap-3">
<Button variant="secondary" size="lg" onClick={() => settle(false)}>
😅 Not yet
</Button>
<Button variant="success" size="lg" onClick={() => settle(true)}>
🧊 I knew it
</Button>
</div>
) : null}
{result !== null ? (
<FeedbackPanel
correct={result}
explanation={activity.explanation}
xp={activity.xp}
isLast={isLast}
headline={result ? "Frozen solid!" : "Keep it on the pile"}
onNext={onNext}
/>
) : null}
</>
);
}