How mangesh2004/notetakingapp works
Project type and purpose
• This is a full-stack Next.js application (“app” directory, next.config.ts, etc.)
• Purpose: A note-taking and PDF annotation workspace that supports user authentication, PDF uploads, viewing/editing PDFs, and AI-powered text assistance (Models/AiModel.tsx).
• Backend: Uses Convex as a serverless data store and function host (convex/ folder).
File structure
• Top-level:
• app/ – the Next.js “App Router” pages and layouts
• convex/ – serverless data schema, actions, file storage, and custom logic
• Models/ – front-end AI model component
• components/ – shared UI primitives (buttons, dialogs, inputs)
• hooks/, lib/ – utilities and custom React hooks
• public/, styles, configs (tailwind, postcss, eslint, tsconfig)
• app/ details:
• (auth)/sign-in & sign-up – authentication UI routes
• api/pdfloader/route.ts – an API endpoint to ingest PDFs
• dashboard/ – main workspace after login, with Header, Sidebar, and UploadPDF components
• workspace/[fileId]/ – dynamic workspace page showing PdfViewer, TextEditor, EditorExtinction, WorkspaceHeader
• providers/ConvexClientProvider.tsx – wrapper to supply Convex client context
• convex/ details:
• schema.ts – data model definitions (users, notes)
• users.ts, notes.ts – Convex query/mutation functions
• fileStorage.ts – PDF file handling
• myActions.ts & langchain/db.ts – custom actions, possibly for AI/text extraction
a. Main components:
• Frontend UI (Next.js React components)
• API layer (Next.js serverless routes under app/api)
• Convex backend (queries, mutations, fileStorage, custom actions)
• Database/storage (Convex’s underlying storage + PDF blobs)
• AI Model integration (Models/AiModel and/or Langchain actions)
• External services: Vercel hosting, possibly OpenAI or other LLM endpoints
b. Relationships & data flow:
1. User browser <–> Next.js frontend (pages + React components)
2. Frontend calls Next.js API routes (/api/pdfloader) or uses Convex client for live queries/mutations
3. Next.js API / Convex actions manage PDF storage, user data, notes in Convex DB
4. AI Model component invokes custom Convex actions or third-party LLM APIs to process/extract text from PDFs
5. Results are stored in Convex and pushed to the UI via real-time subscriptions
c. Architectural patterns & design principles:
• Separation of concerns: UI layer vs. API layer vs. data layer
• App Router and component reusability (atomic UI components in components/ui)
• Serverless functions for business logic (Convex)
• Real-time data sync (Convex live queries)
• Dynamic routing for resource-oriented pages (workspace/[fileId])
d. Key technologies & libraries:
• Next.js App Router (React + Server Components + Client Components)
• Convex (serverless DB + functions + file storage)
• Tailwind CSS for styling
• TypeScript throughout
• Langchain or custom AI integration (convex/langchain)
• Sonner for toasts, other UI utilities