How floguo/mind-map works
Project type and purpose
• This is a full-stack web application (“PDF Mind Map Maker”) built on Next.js 14 with the App Router.
• It enables users to upload a PDF, sends it through a Google Gemini Pro AI pipeline (via Vercel’s AI SDK) to extract key points, and visualizes the result as an interactive mind map using React Flow.
File structure
• Top-level files: configuration (.eslintrc.json, tsconfig.json, next.config.mjs, tailwind.config.ts, postcss.config.js), package.json, README.
• app/(preview): all UI pages & layouts under Next.js App Router; includes globals.css, layout.tsx, page.tsx, actions.ts, theme CSS.
• app/api: Next.js API routes for chat and generate-quiz (server-side endpoints).
• app/types/types.ts: shared TypeScript types for data transfer.
• components/: reusable React components (MindMap, PDFExtractor, UI primitives in components/ui).
• lib/: shared utilities and schema definitions (schemas.ts, utils.ts).
• terminal: (likely local scripts or snapshots, can be omitted if unused).
• components.json: metadata for UI components (for design system?).
README for additional insights
• Confirms Next.js + React Flow on the front end.
• AI integration via Google Generative AI and Vercel’s AI SDK.
• Tailwind CSS for styling.
• Key features: drag & drop PDF upload, AI-powered analysis, interactive draggable/collapsible mind maps.
Main components and their interactions
a. Frontend (Browser)
• Next.js App Router pages in app/(preview)
• PDFExtractor component: drag & drop or file picker UI
• MindMap component: renders nodes/edges via React Flow
• Other UI primitives: buttons, inputs, badges, cards (components/ui)
b. Backend (Next.js Serverless)
• API route “/api/generate-quiz” (app/api/generate-quiz/route.ts):
• Receives PDF binary or text
• Calls Vercel AI SDK PDF support
• Sends request to Google Gemini Pro
• Receives structured key-point output
• Returns JSON to frontend
• API route “/api/chat”: optional chat interface
c. Data definitions
• app/types/types.ts: request/response schemas
• lib/schemas.ts: Zod or JSON schema validation
d. External services
• Google Generative AI API (Gemini Pro)
• Vercel AI SDK (manages file upload, rate-limiting, streaming)
e. Styling & build
• Tailwind CSS configuration (tailwind.config.ts)
• PostCSS (postcss.config.js)
Architectural patterns & design principles
• Separation of concerns: UI components vs API routes vs shared utils/schemas
• Serverless functions: each API endpoint is isolated
• Client-driven interactivity: heavy use of client-side React Flow for rendering
• Schema validation: ensure data contracts between front end, back end, and AI service