How mrmps/pdf2md works
Project type and overall purpose
• This is a browser-based, single-page application built with Next.js (App Router), React, TypeScript, and Tailwind CSS.
• There is no back-end or server-side data storage; all PDF processing happens locally in the user’s browser via the @opendocsg/pdf2md library.
• The app is statically hosted (e.g., on Vercel, Netlify, or any static‐file server).
Main architectural components
a. Static Host / CDN
• Serves built assets: HTML, JS bundles, CSS, images (in public/)
• Examples: Vercel, Netlify, AWS S3 + CloudFront
b. Next.js Build Process (Node.js)
• Transpiles TypeScript (tsconfig.json)
• Bundles React components (app/, components/, hooks/)
• Processes Tailwind CSS (tailwind.config.ts, postcss.config.mjs)
c. Browser Client (Runtime)
1. UI Layer
– Layout & routing (app/layout.tsx, app/page.tsx)
– Theme & style providers (components/theme-provider.tsx, app/globals.css)
– Core React components (components/…, components/ui/…)
2. PDF Upload & Conversion
– File Uploader (components/file-uploader.tsx)
– Conversion Engine: @opendocsg/pdf2md (invoked from pdf2md-loader.tsx)
3. Markdown Preview & Output
– Markdown Previewer (components/markdown-preview.tsx)
– Download / Copy UI (components/pdf2md-loader.tsx & download button)
4. Utility Hooks & Helpers
– hooks/use-toast.ts (notifications)
– hooks/use-mobile.tsx (responsive behavior)
– lib/utils.ts (shared utilities)
Relationships and data flow
• User → Browser UI → File Uploader
• Uploaded PDF → pdf2md library (in-browser) → Markdown string
• Markdown string → Markdown Preview component → Rendered HTML
• User actions → Download / Copy operations
• Toasts & alerts reflect success/failure at each step
Architectural patterns & principles
• Component-based UI (React + shadcn/ui)
• Separation of concerns:
• Layout & routing ↔ UI components ↔ business logic (conversion) ↔ utilities
• Zero trust / privacy-first: all data stays on client
• Offline-capable static PWA