From e246fc5b804454e7bd902bab7b359546b87201c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:48:08 +0000 Subject: [PATCH 1/4] Initial plan From a6a6792275edcf48c0483bfa4ca523982fd2358c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:53:12 +0000 Subject: [PATCH 2/4] Create English README with Chinese version appended Co-authored-by: LQ458 <143152892+LQ458@users.noreply.github.com> --- README.md | 404 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 400 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1bc1dac8..bd3382d8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,399 @@ +# ๐Ÿ“š TeachAI - AI-Powered Lesson Plan Generator + +A full-stack AI lesson plan generation application built with Next.js and Node.js, integrated with RAG (Retrieval-Augmented Generation) system for more accurate educational content generation. + +## ๐Ÿš€ Quick Start + +### System Requirements + +- Node.js >= 18.17.0 +- pnpm >= 8.0.0 +- Python >= 3.8 (for ChromaDB) + +### ๐Ÿ“ฆ Package Manager Installation + +This project uses **pnpm** as the package manager. If you haven't installed pnpm yet, please install it first: + +```bash +# Install pnpm globally +npm install -g pnpm + +# Or use Corepack (Node.js 16.10+) +corepack enable +corepack prepare pnpm@latest --activate +``` + +### ๐Ÿ”ง Project Installation and Setup + +1. **Clone the Repository** + + ```bash + git clone https://github.com/LQ458/lesson-plan-generator.git + cd lesson-plan-generator + ``` + +2. **Install All Dependencies** + + ```bash + # Install dependencies for root, web, and server + pnpm run install:all + + # Or install separately + pnpm install # Root dependencies + cd web && pnpm install # Frontend dependencies + cd ../server && pnpm install # Backend dependencies + ``` + +3. **Install ChromaDB (RAG System)** + + ```bash + # Install ChromaDB + pip install chromadb + + # Or use conda + conda install -c conda-forge chromadb + ``` + +4. **Configure Environment Variables** + + ```bash + # Copy environment variable template + cp server/.env.example server/.env + + # Edit environment variables, set AI API key + # DASHSCOPE_API_KEY=your_api_key_here + ``` + +## ๐Ÿง  RAG System Setup + +This project integrates a RAG (Retrieval-Augmented Generation) system that uses ChromaDB as a vector database to provide intelligent content generation based on educational materials. + +### Starting the RAG System + +1. **Start ChromaDB Service** + + ```bash + # Start ChromaDB vector database + pnpm run chroma:start + ``` + +2. **Load Educational Materials** + + ```bash + # Load educational materials from optimized folder to vector database + pnpm run rag:load + ``` + +3. **Check RAG System Status** + + ```bash + # Check database status and data statistics + pnpm run rag:status + ``` + +### One-Click RAG System Setup + +```bash +# Automatically start ChromaDB and load data +pnpm run setup:rag +``` + +### RAG System Management + +```bash +# Start ChromaDB service +pnpm run chroma:start + +# Stop ChromaDB service +pnpm run chroma:stop + +# Check system status +pnpm run rag:status + +# Reload data +pnpm run rag:load +``` + +## ๐Ÿƒโ€โ™‚๏ธ Running the Project + +### Development Mode + +1. **Standard Development Mode (without RAG)** + + ```bash + # Start both frontend and backend development servers + pnpm dev + ``` + +2. **Full Development Mode (with RAG)** + + ```bash + # Start ChromaDB, frontend, and backend servers simultaneously + pnpm run dev:full + ``` + +### Starting Services Separately + +```bash +# Start ChromaDB service +pnpm run chroma:start + +# Start backend server +pnpm run dev:server + +# Start frontend server +pnpm run dev:web +``` + +Access URLs: + +- Frontend Application: http://localhost:3000 +- Backend API: http://localhost:3001 +- ChromaDB: http://localhost:8000 + +## ๐Ÿ“š Educational Materials Data + +### Data Structure + +The `server/optimized/` folder contains preprocessed educational materials in JSON format: + +``` +server/optimized/ +โ”œโ”€โ”€ 1751827962807_ๆน˜ๆ•™็‰ˆๆ•ฐๅญฆไนๅนด็บงไธ‹ๅ†Œๆ•™ๅธˆ็”จไนฆ.pdf.json +โ”œโ”€โ”€ 1751827960661_ๅŽๅธˆๅคง็‰ˆๆ•ฐๅญฆไนๅนด็บงไธ‹ๅ†Œ็”ตๅญ่ฏพๆœฌ.pdf.json +โ”œโ”€โ”€ 1751827949169_ไบบๆ•™็‰ˆ็‰ฉ็†ไนๅนด็บงๅ…จไธ€ๅ†Œ็”ตๅญ่ฏพๆœฌ.pdf.json +โ””โ”€โ”€ ... (more educational materials) +``` + +### Data Format + +Each JSON file contains the following structure: + +```json +{ + "chunks": [ + { + "content": "Educational content text", + "page_number": 1, + "metadata": { + "source": "Filename", + "chunk_index": 0 + } + } + ] +} +``` + +### Supported Textbook Versions + +- **Mathematics**: People's Education Press, Beijing Normal University Press, Xiang Education Press, East China Normal University Press +- **Chinese Language**: People's Education Press, Jiangsu Education Press, Beijing Normal University Press +- **English**: People's Education Press, Foreign Language Teaching and Research Press, Yilin Press +- **Physics**: People's Education Press, Beijing Normal University Press, Shanghai Science Press +- **Chemistry**: People's Education Press, Shandong Science and Technology Press +- **Biology**: People's Education Press, Jiangsu Education Press +- **Others**: Music, Art, Science, etc. + +### Building the Project + +```bash +# Build the entire project +pnpm build + +# Build separately +pnpm run build:web # Build frontend +pnpm run build:server # Build backend +``` + +## ๐ŸŽฏ Technical Features + +### RAG (Retrieval-Augmented Generation) System + +This project integrates an advanced RAG system that retrieves relevant educational materials through vector database, significantly improving the quality and accuracy of AI-generated content. + +#### Core Features + +- **Intelligent Retrieval**: Retrieve relevant educational content based on semantic similarity +- **Multi-Version Textbook Support**: Covers mainstream textbooks like People's Education Press, Beijing Normal University Press, Jiangsu Education Press, etc. +- **Grade Adaptation**: Automatically matches grade-relevant educational materials +- **Subject Specialization**: Provides specialized educational content for different subjects +- **Real-time Enhancement**: Real-time retrieval and integration of relevant educational resources during generation + +#### Data Statistics + +- **Educational Materials**: 6,805+ educational content chunks +- **Grade Coverage**: Elementary Grade 1 to High School Grade 12 +- **Supported Subjects**: Mathematics, Chinese, English, Physics, Chemistry, Biology, History, Geography, Politics, Music, Art, Science +- **Textbook Versions**: 20+ mainstream textbook versions + +#### Technical Architecture + +``` +User Request โ†’ AI Service โ†’ Vector Retrieval โ†’ Content Fusion โ†’ Enhanced Generation โ†’ Return Result + โ†“ + ChromaDB Vector Database + (6,805+ Educational Materials) +``` + +### AI Generation Capabilities + +- **Lesson Plan Generation**: Supports complete instructional design including teaching objectives, key points and difficulties, teaching process +- **Exercise Generation**: Intelligent question generation with support for multiple question types and difficulty levels +- **Content Analysis**: Intelligently analyzes educational content and extracts core concepts +- **Multi-format Output**: Supports various display formats including text, mind maps, flowcharts, timelines + +### User Experience + +- **Streaming Output**: Real-time display of generation process for enhanced user experience +- **Personalized Settings**: Customize generated content based on user preferences +- **Content Management**: Complete content bookmarking, export, and deletion functionality +- **Multi-format Export**: Supports export to PDF, Word, images, and other formats + +## ๐Ÿ“– Usage Guide + +### Basic Usage Flow + +1. **Start Services** + + ```bash + # Start complete service (recommended) + pnpm run dev:full + ``` + +2. **Generate Lesson Plans** + - Visit http://localhost:3000 + - Select subject, grade, and topic + - Click generate, AI will provide professional lesson plans combined with RAG system + +3. **Manage Content** + - View generation history + - Bookmark quality content + - Export to PDF/Word + +### Advanced Features + +- **RAG System Management**: Use `pnpm run rag:status` to view database status +- **Data Update**: Use `pnpm run rag:load` to reload educational materials +- **System Monitoring**: View generation logs and performance metrics + +4. **Production Environment Startup** + +```bash +# Start production environment +pnpm start + +# Start separately +pnpm run start:web # Start frontend production server +pnpm run start:server # Start backend production server +``` + +## ๐Ÿ“ Project Structure + +``` +lesson-plan-generator/ +โ”œโ”€โ”€ web/ # Next.js frontend application +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ app/ # App Router pages +โ”‚ โ”‚ โ””โ”€โ”€ components/ # React components +โ”‚ โ”œโ”€โ”€ package.json +โ”‚ โ””โ”€โ”€ pnpm-lock.yaml +โ”œโ”€โ”€ server/ # Node.js backend service +โ”‚ โ”œโ”€โ”€ models/ # Data models +โ”‚ โ”œโ”€โ”€ services/ # Business services +โ”‚ โ”œโ”€โ”€ middleware/ # Middleware +โ”‚ โ”œโ”€โ”€ config/ # Configuration files +โ”‚ โ”œโ”€โ”€ utils/ # Utility functions +โ”‚ โ”œโ”€โ”€ package.json +โ”‚ โ””โ”€โ”€ pnpm-lock.yaml +โ”œโ”€โ”€ package.json # Root configuration (workspace) +โ”œโ”€โ”€ pnpm-lock.yaml # Lock file +โ””โ”€โ”€ .gitignore # Git ignore file +``` + +## ๐Ÿ› ๏ธ Development Tools + +### Available Scripts + +```bash +pnpm dev # Start frontend and backend in development mode +pnpm build # Build production version +pnpm start # Start production server +pnpm lint # Code style check +pnpm test # Run tests +pnpm clean # Clean node_modules and build files +pnpm format # Code formatting +``` + +### Git Ignore Rules + +The project has a complete `.gitignore` file configured to automatically ignore: + +- `**/node_modules/` - All levels of dependency directories +- `**/.next/` - Next.js build output +- `**/*.log` - Log files +- `.env*` - Environment variable files +- `.DS_Store` - macOS system files +- IDE configuration files, etc. + +## ๐Ÿ”‘ Environment Configuration + +Please create a `.env` file in the `server/` directory: + +```bash +# MongoDB connection +MONGODB_URI=your_mongodb_connection_string + +# JWT secret +JWT_SECRET=your_jwt_secret + +# OpenAI API Key (if using) +OPENAI_API_KEY=your_openai_api_key + +# Server port +PORT=8080 +``` + +## ๐Ÿ“– Technology Stack + +### Frontend (web/) + +- **Next.js 15** - React full-stack framework +- **React 19** - UI library +- **TypeScript** - Type safety +- **Tailwind CSS** - Styling framework +- **Framer Motion** - Animation library +- **Lucide React** - Icon library + +### Backend (server/) + +- **Node.js** - Runtime environment +- **Express.js** - Web framework +- **MongoDB** - Database +- **Mongoose** - ODM +- **JWT** - Authentication +- **Winston** - Logging + +## ๐Ÿค Contributing + +Pull Requests and Issues are welcome! + +## ๐Ÿ“„ License + +MIT License + +## ๐Ÿ“ž Contact Us + +- Project Link: [GitHub Repository](https://github.com/LQ458/lesson-plan-generator) +- Issue Feedback: [Issues](https://github.com/LQ458/lesson-plan-generator/issues) + +--- + +**TeachAI** - Let AI Be Your Teaching Assistant ๐Ÿš€ + +--- + +# ไธญๆ–‡็‰ˆๆœฌ / Chinese Version + # ๐Ÿ“š TeachAI - ๆ™บ่ƒฝๆ•™ๆกˆ็”Ÿๆˆๅ™จ ๅŸบไบŽ Next.js ๅ’Œ Node.js ็š„ๅ…จๆ ˆ AI ๆ•™ๆกˆ็”Ÿๆˆๅบ”็”จ๏ผŒ้›†ๆˆ RAG (ๆฃ€็ดขๅขžๅผบ็”Ÿๆˆ) ็ณป็ปŸ๏ผŒๆไพ›ๆ›ดๅ‡†็กฎ็š„ๆ•™ๅญฆๅ†…ๅฎน็”Ÿๆˆใ€‚ @@ -28,8 +424,8 @@ corepack prepare pnpm@latest --activate 1. **ๅ…‹้š†้กน็›ฎ** ```bash - git clone https://github.com/your-username/teachai.git - cd teachai + git clone https://github.com/LQ458/lesson-plan-generator.git + cd lesson-plan-generator ``` 2. **ๅฎ‰่ฃ…ๆ‰€ๆœ‰ไพ่ต–** @@ -383,8 +779,8 @@ MIT License ## ๐Ÿ“ž ่”็ณปๆˆ‘ไปฌ -- ้กน็›ฎ้“พๆŽฅ: [GitHub Repository](https://github.com/your-username/teachai) -- ้—ฎ้ข˜ๅ้ฆˆ: [Issues](https://github.com/your-username/teachai/issues) +- ้กน็›ฎ้“พๆŽฅ: [GitHub Repository](https://github.com/LQ458/lesson-plan-generator) +- ้—ฎ้ข˜ๅ้ฆˆ: [Issues](https://github.com/LQ458/lesson-plan-generator/issues) --- From 96a6e10c5bc809588efeebfde83fd6b981e58f88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:55:29 +0000 Subject: [PATCH 3/4] Fix documentation inconsistencies in environment configuration Co-authored-by: LQ458 <143152892+LQ458@users.noreply.github.com> --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bd3382d8..c47770a2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A full-stack AI lesson plan generation application built with Next.js and Node.j - Node.js >= 18.17.0 - pnpm >= 8.0.0 - Python >= 3.8 (for ChromaDB) +- MongoDB (local or cloud instance) ### ๐Ÿ“ฆ Package Manager Installation @@ -340,17 +341,17 @@ The project has a complete `.gitignore` file configured to automatically ignore: Please create a `.env` file in the `server/` directory: ```bash +# AI Service API Key (Qwen/DashScope) +DASHSCOPE_API_KEY=your_dashscope_api_key + # MongoDB connection MONGODB_URI=your_mongodb_connection_string # JWT secret JWT_SECRET=your_jwt_secret -# OpenAI API Key (if using) -OPENAI_API_KEY=your_openai_api_key - # Server port -PORT=8080 +PORT=3001 ``` ## ๐Ÿ“– Technology Stack @@ -405,6 +406,7 @@ MIT License - Node.js >= 18.17.0 - pnpm >= 8.0.0 - Python >= 3.8 (็”จไบŽ ChromaDB) +- MongoDB (ๆœฌๅœฐๆˆ–ไบ‘ๅฎžไพ‹) ### ๐Ÿ“ฆ ๅŒ…็ฎก็†ๅ™จๅฎ‰่ฃ… @@ -736,17 +738,17 @@ pnpm format # ไปฃ็ ๆ ผๅผๅŒ– ่ฏทๅœจ `server/` ็›ฎๅฝ•ไธ‹ๅˆ›ๅปบ `.env` ๆ–‡ไปถ๏ผš ```bash +# AI ๆœๅŠก API ๅฏ†้’ฅ (Qwen/DashScope) +DASHSCOPE_API_KEY=your_dashscope_api_key + # MongoDB ่ฟžๆŽฅ MONGODB_URI=your_mongodb_connection_string # JWT ๅฏ†้’ฅ JWT_SECRET=your_jwt_secret -# OpenAI API Key (ๅฆ‚ๆžœไฝฟ็”จ) -OPENAI_API_KEY=your_openai_api_key - # ๆœๅŠกๅ™จ็ซฏๅฃ -PORT=8080 +PORT=3001 ``` ## ๐Ÿ“– ๆŠ€ๆœฏๆ ˆ From 353682ed085adec79b47bc83b049619243b3008d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:56:55 +0000 Subject: [PATCH 4/4] Add MongoDB version and DashScope API key documentation link Co-authored-by: LQ458 <143152892+LQ458@users.noreply.github.com> --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c47770a2..72efda49 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A full-stack AI lesson plan generation application built with Next.js and Node.j - Node.js >= 18.17.0 - pnpm >= 8.0.0 - Python >= 3.8 (for ChromaDB) -- MongoDB (local or cloud instance) +- MongoDB >= 4.4 (local or cloud instance) ### ๐Ÿ“ฆ Package Manager Installation @@ -342,6 +342,7 @@ Please create a `.env` file in the `server/` directory: ```bash # AI Service API Key (Qwen/DashScope) +# Get your API key from: https://dashscope.aliyun.com/ DASHSCOPE_API_KEY=your_dashscope_api_key # MongoDB connection @@ -406,7 +407,7 @@ MIT License - Node.js >= 18.17.0 - pnpm >= 8.0.0 - Python >= 3.8 (็”จไบŽ ChromaDB) -- MongoDB (ๆœฌๅœฐๆˆ–ไบ‘ๅฎžไพ‹) +- MongoDB >= 4.4 (ๆœฌๅœฐๆˆ–ไบ‘ๅฎžไพ‹) ### ๐Ÿ“ฆ ๅŒ…็ฎก็†ๅ™จๅฎ‰่ฃ… @@ -739,6 +740,7 @@ pnpm format # ไปฃ็ ๆ ผๅผๅŒ– ```bash # AI ๆœๅŠก API ๅฏ†้’ฅ (Qwen/DashScope) +# ่Žทๅ– API ๅฏ†้’ฅ: https://dashscope.aliyun.com/ DASHSCOPE_API_KEY=your_dashscope_api_key # MongoDB ่ฟžๆŽฅ