Skip to content

feat: add AI chatbot with contextual memory and persistent chat history#439

Open
Aayush20253534 wants to merge 10 commits into
Priyanshu-byte-coder:mainfrom
Aayush20253534:feature/ai-dashboard-chatbot
Open

feat: add AI chatbot with contextual memory and persistent chat history#439
Aayush20253534 wants to merge 10 commits into
Priyanshu-byte-coder:mainfrom
Aayush20253534:feature/ai-dashboard-chatbot

Conversation

@Aayush20253534
Copy link
Copy Markdown

@Aayush20253534 Aayush20253534 commented May 20, 2026

Summary

Added an AI-powered DevTrack chatbot with Groq integration, dashboard-aware responses, contextual memory, and persistent user-specific chat history.

Closes #416

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added Groq-powered chatbot backend API route.
  • Added persistent user-specific chatbot history using Supabase.
  • Added contextual memory using recent chat history.
  • Added chatbot history fetch API route.
  • Updated chatbot UI to restore previous conversations.
  • Added markdown-rendered AI responses.
  • Integrated dashboard metrics into chatbot context.
  • Updated Supabase schema with chatbot_messages table.

How to Test

Steps for the reviewer to verify this works:

  1. Add GROQ_API_KEY to .env.local.
  2. Run the updated Supabase schema or manually create the chatbot_messages table.
  3. Start the app using npm run dev.
  4. Log in with GitHub.
  5. Open the dashboard chatbot.
  6. Ask a dashboard-related question such as What are my top repositories?.
  7. Send a contextual message.
  8. Ask a follow up.
  9. Refresh the page and reopen the chatbot.
  10. Verify that previous chat history is restored.

Screenshots (if UI change)

Screenshot 2026-05-20 140508

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

@Aayush20253534 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 20, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production-breaking bug: hardcoded http://localhost:3000.

The getMetric helper fetches http://localhost:3000${path} — this does not work on Vercel or any cloud deployment where serverless functions cannot reach localhost:3000. The chatbot will silently return no context data in production and the AI will answer with empty metrics. Fix: call the underlying service functions/utilities directly instead of making self-HTTP calls.

Additional required fixes:

  1. Wrong user ID keysession.user.email || session.user.name || 'unknown-user' is used to key chatbot_messages. GitHub OAuth email can be null/private; display names are not unique. Two users with the same display name and no public email share chat history. Use session.githubId / resolveAppUser like every other route.

  2. No message length validationmessage is stored in Supabase and forwarded to Groq with no size limit. Add a max length (e.g., 2000 chars).

  3. Session data leaking to LLMsession.user is dumped into the system prompt context wholesale. This may include accessToken or other sensitive fields that should not be sent to Groq. Whitelist only what's needed (e.g., githubLogin).

  4. GROQ_API_KEY missing env var returns "GROQ_API_KEY is missing" verbatim to the client — leaks internal implementation detail. Return a generic error message.

  5. Missing Supabase migrationchatbot_messages is added to schema.sql but no timestamped migration file exists. Existing deployments won't get this table.

  6. Missing EOF newline on supabase/schema.sql.

@Priyanshu-byte-coder Priyanshu-byte-coder added the level:advanced GSSoC: Advanced difficulty (55 pts) label May 20, 2026
@Aayush20253534
Copy link
Copy Markdown
Author

Aayush20253534 commented May 20, 2026

@Priyanshu-byte-coder

Implemented and addressed all requested review fixes:

  • Removed localhost-based self-fetching and replaced it with production-safe direct metric helpers
  • Added centralized chatbot analytics helpers in chatbot-metrics.ts
  • Added persistent chatbot history with contextual conversation memory
  • Added frontend + backend message length validation
  • Sanitized LLM context by whitelisting only safe session fields (githubLogin)
  • Replaced internal GROQ env leakage with generic service error handling
  • Added Supabase migration for chatbot_messages
  • Added missing EOF newline in schema.sql
  • Improved chatbot formatting, analytics coverage, and follow-up context handling

The chatbot now supports:

  • repository analytics
  • PR summaries
  • contribution streak insights
  • contextual follow-up questions
  • persistent user-wise memory
  • production-safe deployment behavior

@Aayush20253534
Copy link
Copy Markdown
Author

@Priyanshu-byte-coder Please Review the changes by me , I have implemented them successfully along with the production bugs I was supposed to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution level:advanced GSSoC: Advanced difficulty (55 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] AI Chatbot for Dashboard Assistance

2 participants