Lamina is an AI-powered note-taking app focused on fast capture, structured notes, and a fluid writing experience. Below are the product-grade features and where they live in the codebase.
-
Live AI streaming
- Frontend stream reader:
streamAiResponse(lib/prompt.js) - Backend streaming endpoint: app/api/ai-stream/route.js (
streamTextintegration) - Typing UX: incremental chunks are rendered to the editor as they arrive.
- Frontend stream reader:
-
Multi-source parsing (convert sources to text before summarizing)
- PDF parsing:
parsePdf→ app/api/parse-pdf/route.js - YouTube transcripts:
getYoutubeTranscript(lib/prompt.js) - DOC/DOCX parsing:
parseDoc(lib/prompt.js) - Webpage extraction:
fetchWebpageText(lib/prompt.js) - Paste/long text:
getLongText(lib/prompt.js)
- PDF parsing:
-
Rich WYSIWYG Markdown editor
- Editor component: components/MarkdownEditor.jsx
- Live-rendering: streamed AI output is processed via
markedand injected so markdown formatting appears as the AI types. - Tiptap extensions included (lists, links, images, highlights, tasks).
-
Productivity UX
- Tabbed editor system: components/TabSystem.jsx
- Sidebar file explorer with folders and breadcrumbs: components/Sidebar.jsx
- Auto-save and Supabase sync (client created in components using env vars)
-
Clear separation:
- Prompt and streaming logic centralized in lib/prompt.js (
makeNotesPrompt,streamAiResponse). - API routes in app/api.
- Editor UI in components/MarkdownEditor.jsx.
- Prompt and streaming logic centralized in lib/prompt.js (
-
Streaming-first design:
- Backend returns a streaming response to the client so the frontend can render tokens in real time.
- The editor receives tokens via
streamAiResponseand appends them using Tiptap commands.
-
Safe defaults and debugging:
- Token truncation to prevent model context errors.
- Console logging hooks in API routes (add logs in app/api/parse-pdf/route.js and app/api/ai-stream/route.js while debugging).
- Install:
npm install- Add environment variables in
.env.local:
- NEXT_PUBLIC_SUPABASE_URL
- NEXT_PUBLIC_SUPABASE_ANON_KEY
- OPENROUTER_API_KEY
- Run:
npm run dev-
Generate notes from a PDF:
- Upload via the custom dialog in components/MarkdownEditor.jsx.
- Frontend calls
parsePdf→ POST/api/parse-pdf(app/api/parse-pdf/route.js). - Build prompt via
makeNotesPromptand callstreamAiResponse. - AI streams notes into the editor live.
-
Convert a webpage or YouTube transcript:
- Use
fetchWebpageTextorgetYoutubeTranscript, then stream notes as above.
- Use
- Prompt & streaming: lib/prompt.js — see
makeNotesPromptandstreamAiResponse. - Editor: components/MarkdownEditor.jsx.
- Streaming API: app/api/ai-stream/route.js.
- PDF parser: app/api/parse-pdf/route.js.
- Tabs and layout: components/TabSystem.jsx and app/Application.jsx.