MathBro is an AI-powered math learning assistant built with Next.js, Prisma, and PostgreSQL. It helps students solve problems step-by-step, track weak areas, save important solutions, and revise formulas in one focused workspace.
🌐 Live website: https://mathbro.doniyorlab.uz/
- Ask AI for step-by-step solutions with final answers and short summaries.
- Save solved problems for revision later.
- Mark confusing problems so you can revisit what felt hard.
- Track weak areas by topic and score.
- Practice and auto-update progress based on your submissions.
- Browse formulas and topics with examples and quiz-style checks.
- See a dashboard overview (saved work, weak topics, formula of the day, progress stats).
- Framework: Next.js 14 (App Router) + TypeScript
- UI: Tailwind CSS
- Database: PostgreSQL
- ORM: Prisma
- Auth: JWT + HTTP-only cookie sessions
- Validation: Zod
- AI: OpenAI API (with local fallback logic in code)
app/
api/
ai/solve/ # AI solving endpoint
auth/ # Register, login, logout
dashboard/ # Personalized dashboard data
formulas/ # Formula vault API
practice/submit/ # Practice submission + weak-area scoring
saved-problems/ # Save/list solved questions
topics/ # Topic listing/details
weak-areas/ # Weak area tracking
ask-ai/ # Ask AI page
formulas/ # Formula vault page
practice/ # Practice mode page
topics/ # Topics pages
weak-areas/ # Weak-area insights page
prisma/
schema.prisma # DB models
seed.ts # Initial topic/formula seed
lib/ # Auth, API helpers, validation, AI utils
components/ # Shared UI and app shellCore entities:
UserTopicFormulaSavedProblemWeakArea
Relations are set so each user can have many saved problems + weak areas, and each topic can map to formulas/problems/weak-area records.
- Register/login via API routes.
- Passwords are hashed with
bcryptjs. - JWT token is issued and stored in a cookie.
- Protected routes require a valid token.
npm installCreate .env from .env.example:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/mathbro"
JWT_SECRET="replace-with-strong-secret"
OPENAI_API_KEY=""npm run prisma:generatenpm run prisma:migratenpm run db:seednpm run devOpen http://localhost:3000.
npm run dev— start development servernpm run build— production buildnpm run start— start production servernpm run lint— run ESLintnpm run prisma:generate— generate Prisma clientnpm run prisma:migrate— run Prisma dev migrationsnpm run db:seed— seed starter topics/formulas
POST /api/auth/registerPOST /api/auth/loginPOST /api/auth/logoutPOST /api/ai/solveGET /api/dashboardGET,POST /api/saved-problemsGET /api/weak-areasGET /api/formulasGET /api/topicsGET /api/topics/[id]POST /api/practice/submit
Some endpoints require authentication.
- The app is structured to be easy to extend with more topics, formulas, and adaptive learning logic.
OPENAI_API_KEYcan be left empty during early local development if you rely on fallback response behavior.
Doniyor Musayev
- GitHub: @MusayevDoniyor
- Portfolio: doniyorweb.uz
- LinkedIn: linkedin.com/in/doniyor-musayev
- Telegram: @Musayev_Doniyor
Built with ❤️ for students mastering mathematics. Contributions and feedback are warmly welcome!