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,30 @@
"use client";
import { useEffect } from "react";
/**
* Registers the service worker in production builds only.
*
* Dev stays untouched: a cached shell would fight hot reload, and the worker
* would also hide real 404s while developing.
*/
export function ServiceWorkerRegistrar() {
useEffect(() => {
if (process.env.NODE_ENV !== "production") return;
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) return;
const register = () => {
navigator.serviceWorker.register("/sw.js", { scope: "/" }).catch((error) => {
console.warn("[freezmo] service worker registration failed", error);
});
};
if (document.readyState === "complete") register();
else {
window.addEventListener("load", register, { once: true });
return () => window.removeEventListener("load", register);
}
}, []);
return null;
}