AI-powered learning platform backend with Express.js, MySQL, and OpenAI integration.
- 🔐 JWT Authentication (Register/Login)
- 📚 Course Management (Create, Enroll, Progress Tracking)
- 🤖 AI Study Assistant (24/7 chat support)
- 🎯 AI-Powered Course Generation
- 📝 Flashcards with Spaced Repetition
- 📊 Quiz/Exam Practice Mode
- 🏆 Gamification (Points, Levels, Leaderboards)
- 📈 Progress Tracking & Analytics
-
Install dependencies:
npm install
-
Configure environment:
cp .env.example .env
Edit
.envwith your configuration:- MySQL database credentials
- JWT secret key
- OpenAI API key (get from https://platform.openai.com/api-keys)
-
Set up database:
npm run setup
Or manually:
mysql -u root -p < database/schema.sql -
Start server:
npm start
Or for development with auto-reload:
npm run dev
DB_HOST- MySQL host (default: localhost)DB_USER- MySQL username (default: root)DB_PASSWORD- MySQL passwordDB_NAME- Database name (default: eduai_platform)DB_PORT- MySQL port (default: 3306)JWT_SECRET- Secret key for JWT tokensPORT- Server port (default: 5000)OPENAI_API_KEY- Your OpenAI API key (required for AI features)FRONTEND_URL- Frontend URL for CORS (default: http://localhost:5173)
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user (requires token)
GET /api/courses- Get all published coursesGET /api/courses/:id- Get single course with modulesPOST /api/courses- Create course (instructor)POST /api/courses/generate-outline- Generate course outline with AIPOST /api/courses/:id/modules- Add module to coursePOST /api/courses/:id/modules/generate- Generate module content with AIPOST /api/courses/:id/enroll- Enroll in coursePUT /api/courses/:id/progress- Update course progressGET /api/courses/user/my-courses- Get user's enrolled courses
GET /api/ai/conversations- Get user's conversationsPOST /api/ai/conversations- Create new conversationGET /api/ai/conversations/:id/messages- Get conversation messagesPOST /api/ai/conversations/:id/messages- Send message to AI assistant
GET /api/flashcards- Get user's flashcardsPOST /api/flashcards- Create flashcardPOST /api/flashcards/generate- Generate flashcards from content (AI)POST /api/flashcards/:id/review- Review flashcard (spaced repetition)DELETE /api/flashcards/:id- Delete flashcard
GET /api/quizzes- Get quizzesGET /api/quizzes/:id- Get quiz with questionsPOST /api/quizzes- Create quizPOST /api/quizzes/generate- Generate quiz with AIPOST /api/quizzes/:id/submit- Submit quiz attemptGET /api/quizzes/user/attempts- Get user's quiz attempts
GET /api/stats/user- Get user statisticsGET /api/stats/leaderboard- Get leaderboard
- Passwords hashed with bcryptjs
- JWT tokens for authentication
- SQL injection protection via parameterized queries
- CORS enabled for frontend
- Rate limiting on API routes
The platform uses OpenAI's GPT models for:
- Study assistant chat
- Course outline generation
- Course content generation
- Quiz question generation
- Flashcard generation
Make sure to set your OPENAI_API_KEY in the .env file.