Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎓 AI Study Assistant

An AI-powered study companion built with NestJS. It generates personalized study plans, teaches concepts, generates and grades quizzes, chats with students, and emails study reports/reminders.

Built for the AI Automation Internship — Session 4 assignment. Covers all four required integrations:

Requirement Implementation
AI chatbot (NestJS + OpenAI) POST /chat, plus AI-driven /study-plan, /teach, /quiz
Resend email integration src/email — sends plans, progress reports, and reminders
Swagger API docs Auto-generated at /api/docs via @nestjs/swagger
Sentry monitoring src/instrument.ts + global SentryExceptionFilter

Features

  • Personalized study plansPOST /study-plan: give it subjects, exam date, daily hours, level, and weak topics; AI returns a day-by-day schedule with time allocations and priorities.
  • Concept teachingPOST /teach: get a tutor-style explanation, key points, a worked example, and common mistakes for any subject/topic.
  • Quiz generation & evaluationPOST /quiz generates mixed MCQ/short-answer questions; POST /quiz/evaluate grades them (MCQs exactly, short answers via AI semantic grading) with per-question feedback.
  • Study chatbotPOST /chat: general conversational study companion with message history.
  • Email delivery (Resend)POST /email/study-plan, /email/report, /email/reminder.
  • Daily remindersPOST /reminders/subscribe + a cron job (@nestjs/schedule, default 8am daily) that emails each subscriber their tasks for the day. /reminders/send-now triggers it manually.
  • Swagger docs — full interactive API docs at /api/docs.
  • Sentry — every unhandled/5xx error is captured with request context; GET /debug-sentry is a convenience endpoint to verify your Sentry project is receiving events.

Project structure

src/
  instrument.ts          # Sentry init (imported first in main.ts)
  main.ts                # Bootstrap: Swagger, validation, CORS
  app.module.ts           # Wires all feature modules + global exception filter
  common/filters/         # SentryExceptionFilter
  openai/                 # Shared OpenAI client wrapper (text + JSON completions)
  study-plan/              # Personalized study plan generation
  teaching/                # Concept explanations
  quiz/                    # Quiz generation + AI grading
  chat/                    # Conversational chatbot endpoint
  email/                   # Resend integration + HTML templates
  reminders/                # Subscription store + daily cron reminder job

Setup

  1. Install dependencies

    npm install
  2. Configure environment

    cp .env.example .env

    Fill in:

  3. Run it

    npm run start:dev
  4. Open Swagger docs

    http://localhost:3000/api/docs
    

Example flow

# 1. Generate a study plan
curl -X POST http://localhost:3000/study-plan \
  -H "Content-Type: application/json" \
  -d '{
    "subjects": ["Database Systems", "Operating Systems", "AI"],
    "examDate": "2026-09-10",
    "hoursPerDay": 3,
    "level": "Intermediate",
    "weakTopics": ["Normalization", "Virtual Memory"]
  }'

# 2. Teach a struggling topic
curl -X POST http://localhost:3000/teach \
  -H "Content-Type: application/json" \
  -d '{ "subject": "Database Systems", "topic": "Normalization", "level": "Intermediate" }'

# 3. Generate a quiz
curl -X POST http://localhost:3000/quiz \
  -H "Content-Type: application/json" \
  -d '{ "subject": "Operating Systems", "topic": "Virtual Memory", "numQuestions": 5 }'

# 4. Evaluate answers (use the questions returned from step 3, plus studentAnswers)
curl -X POST http://localhost:3000/quiz/evaluate \
  -H "Content-Type: application/json" \
  -d '{ "subject": "Operating Systems", "questions": [...], "studentAnswers": [...] }'

# 5. Email a progress report
curl -X POST http://localhost:3000/email/report \
  -H "Content-Type: application/json" \
  -d '{
    "to": "student@example.com",
    "studentName": "Ali",
    "examDate": "2026-09-10",
    "hoursStudied": 12,
    "quizResults": [{ "subject": "Operating Systems", "score": 8, "total": 10 }]
  }'

# 6. Subscribe to daily reminders (sent automatically at 8am, or trigger manually)
curl -X POST http://localhost:3000/reminders/subscribe \
  -H "Content-Type: application/json" \
  -d '{ "email": "student@example.com", "studentName": "Ali", "todaysTasks": "DB — Normalization (60 min)" }'

curl -X POST http://localhost:3000/reminders/send-now

Notes on design choices

  • No database — subscriptions live in memory and quizzes are stateless (the quiz + answer key round-trips through the client between generate and evaluate). This keeps the one-week scope focused on the four required integrations. Swapping in TypeORM/Prisma + Postgres would be the natural next step for persistence across restarts and multiple users.
  • Sentry filter — only 5xx/unexpected errors are sent to Sentry; expected 4xx validation errors are returned to the client without polluting the error tracker.
  • AI JSON modeOpenAiService.completeJson() centralizes prompting the model to return strict JSON and defensively strips markdown fences, so every feature (plan/teach/quiz/grading) gets structured, typed output instead of parsing free text.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages