How adawang1210/mind_map works
Project Type and Purpose
• This is a full-stack single-page application combining a Vue.js (Vue 3) frontend and a Python Flask backend.
• Purpose: allow users to upload PDF documents, analyze them via AI (Google Gemini + Sentence Transformers), automatically generate an interactive mind map, and serve a quiz based on the content.
Key Architectural Components
a. Client / Browser
• Renders the Vue.js SPA
• Three main views/components: HomePage, MindMap (MindElixir visualization), QuizPage (interactive quiz)
b. Frontend (Vue 3 SPA)
• Components: AppHeader, AppFooter, HomePage.vue, MindMap.vue, QuizPage.vue
• Plugins: Vuetify (UI), Vue Router (routing), Axios (HTTP requests)
• MindElixir library for rendering mind maps
c. Backend (Flask API)
• app.py: Flask application, CORS enabled, serves API endpoints and optionally serves built frontend from backend/dist
• pdf_processor.py: handles file uploads, invokes Google Gemini API and Sentence Transformers to parse and structure content
• quiz_generator.py: generates quiz questions and answers using AI prompts (prompt.txt)
• uploads/: stores user-uploaded PDF files
• requirements.txt: dependencies (Flask, Flask-CORS, transformers, etc.)
d. External Services
• Google Generative AI (Gemini-1.5-pro)
• Sentence Transformers models (local inference for semantic analysis)
e. Data Storage
• File system upload directory (no persistent DB; ephemeral storage of PDFs and generated artifacts)
Interactions and Data Flow
1. User in Browser → interacts with Vue UI (HomePage.vue) → triggers “Upload PDF”
2. Vue + Axios → HTTP POST /upload (Flask app.py) → file lands in /uploads
3. Flask pdf_processor.py
• Reads PDF, calls Sentence Transformers for semantic segmentation
• Sends text snippets to Gemini API for deeper analysis
• Produces a JSON structure representing the mind map
4. Flask returns JSON to Vue → MindMap.vue uses MindElixir to render the map
5. User navigates to QuizPage → Vue triggers GET /quiz → Flask quiz_generator.py reads mind-map JSON or text, uses Gemini prompts to generate questions/answers → returns quiz JSON → Vue renders interactive quiz and scoring
Architectural Patterns & Design Principles
• SPA (Single-Page Application) on frontend, RESTful JSON API on backend
• Separation of concerns: UI layer vs. business logic vs. AI/ML processing
• Modular Python backend: distinct modules for PDF processing and quiz generation
• File-based storage for uploads (could evolve to object storage or database)
• CORS to allow cross-origin calls from port 8080 → 5001