A Next.js application that generates AI-powered math word problems for Primary 5 students and provides personalized feedback.
URL: https://ai-math-tutor-three.vercel.app
- AI Problem Generation: Uses OpenAI GPT-4o-mini to generate Primary 5 level math word problems
- Interactive Learning: Students can submit answers and receive immediate feedback
- Personalized Feedback: AI generates customized feedback based on student responses
- Data Persistence: All problems and submissions are saved to Supabase database
- Mobile Responsive: Clean, modern interface built with Tailwind CSS
- Frontend: Next.js 13, React 18, TypeScript
- Styling: Tailwind CSS with shadcn/ui components
- Database: Supabase (PostgreSQL)
- AI: OpenAI GPT-4o-mini
- Deployment: Vercel
- Project URL:
https://eouhvfiknjcacmkaxbpx.supabase.co - Anon Key:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVvdWh2ZmlrbmpjYWNta2F4YnB4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTk1NDM0OTgsImV4cCI6MjA3NTExOTQ5OH0.B9PY2yuWhakH790g7uZh2gTjyaA7xzB5d6TazmyiwMM
id(uuid, primary key)problem_text(text) - The generated math word problemfinal_answer(numeric) - The correct numerical answercreated_at(timestamptz) - When the problem was generated
id(uuid, primary key)session_id(uuid, foreign key to math_problem_sessions)user_answer(numeric) - The answer submitted by the useris_correct(boolean) - Whether the answer was correctfeedback(text) - AI-generated personalized feedbackcreated_at(timestamptz) - When the answer was submitted
Create a .env.local file with:
NEXT_PUBLIC_SUPABASE_URL=https://eouhvfiknjcacmkaxbpx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVvdWh2ZmlrbmpjYWNta2F4YnB4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTk1NDM0OTgsImV4cCI6MjA3NTExOTQ5OH0.B9PY2yuWhakH790g7uZh2gTjyaA7xzB5d6TazmyiwMM-
Clone the repository
git clone <repository-url> cd ai-math-tutor
-
Install dependencies
npm install
-
Set up environment variables
- Copy
.env.local.exampleto.env.local - Add your Supabase and OpenAI API keys
- Copy
-
Run the development server
npm run dev
-
Open your browser
- Navigate to http://localhost:3000
Generates a new math word problem using AI.
Response:
{
"id": "uuid",
"problem_text": "Emma has 24 apples...",
"final_answer": 33,
"created_at": "2025-01-04T..."
}Submits a user's answer and generates feedback.
Request:
{
"sessionId": "uuid",
"userAnswer": 33
}Response:
{
"id": "uuid",
"session_id": "uuid",
"user_answer": 33,
"is_correct": true,
"feedback": "Great job! 🎉...",
"correct_answer": 33,
"created_at": "2025-01-04T..."
}ai-math-tutor/
├── app/
│ ├── api/
│ │ ├── generate-problem/
│ │ └── submit-answer/
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
├── components/
│ └── ui/
│ ├── alert.tsx
│ ├── button.tsx
│ ├── card.tsx
│ └── input.tsx
├── lib/
│ ├── supabase.ts
│ └── utils.ts
├── supabase/
│ └── migrations/
└── package.json
- Row Level Security (RLS) enabled on all tables
- Public access policies for anonymous users
- Environment variables for sensitive data
- Input validation and error handling
- Generate Problem: Click "Generate New Problem" to create a math word problem
- Submit Answer: Enter your numerical answer in the input field
- Get Feedback: Receive personalized AI feedback on your submission
- Try Again: Generate new problems to continue practicing
Built with a minimal set of shadcn/ui components:
Button- For all interactive actionsInput- For answer submissionCard- For content layoutAlert- For error messages
- Optimized bundle size (removed 35+ unused components)
- Server-side rendering with Next.js
- Efficient database queries with Supabase
- Mobile-first responsive design
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
Note: The Supabase project URL and Anon Key are included above for direct interaction with the live demo.