- You have learned the basics of Node.js and Express.js, now let's test your knowledge of how to integrate AI into your application by prompting OpenAI api endpoint.
- Fork and Clone this project repository in your terminal 2. CD into the project base directory
cd Week21_Task_Management_AI - Install dependencies:
npm install
- Create a
.envfile in the root directory with your database URL and JWT secret - Complete the authentication middleware and routes (see tasks below)
- Generate Prisma client and push schema to database:
npm run db:generate npm run db:push
- Start the server:
npm run dev
- The server will run on
http://localhost:3000
Location: .env
Create a .env file with:
DATABASE_URL="your-supabase-database-connection-url"
JWT_SECRET="your-super-secret-jwt-key"
OPENAI_API_KEY="your-openai-api-key"
PORT=3000Location: services/aiService.js
Objective: Complete the AI task generation functionality by implementing the generateTaskWithAI function.
What you need to do:
- Open the file
services/aiService.js - Find the function
generateTaskWithAI(prompt) - Follow the detailed instructions in the TODO comments
- Implement the AI integration step by step
Objective: Implement password reset with email verification.
Requirements:
- Create password reset endpoint that generates a reset token
- Send reset email with reset link (simulate with console.log)
- Create reset password endpoint that validates reset token
- Update user password in database
Objective: Implement email verification for new registrations.
Requirements:
- Add email verification field to User model
- Generate verification token during registration
- Send verification email (simulate with console.log)
- Create verification endpoint to confirm email
- Update user verification status
Objective: Implement AI-powered task generation using OpenAI.
Requirements:
- Install OpenAI dependency and configure API key
- Complete the AI task generation function in
services/aiService.js - Add AI generation endpoint at POST /api/tasks/generate
- Save generated tasks to database with subtasks
- Handle AI response parsing and validation
IMPORTANT: You need to complete the generateTaskWithAI function in services/aiService.js.
The function has been prepared with detailed instructions and TODO comments to guide you through the implementation.
Good luck with your implementation! 🚀