Skip to content

[FEAT] : add AI-Driven Goal Mentor (AI Feature) #2997

Open
hrshjswniii wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
hrshjswniii:feature/Goal-Mentor
Open

[FEAT] : add AI-Driven Goal Mentor (AI Feature) #2997
hrshjswniii wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
hrshjswniii:feature/Goal-Mentor

Conversation

@hrshjswniii

Copy link
Copy Markdown
Contributor

Summary

Implements the AI-Driven Goal Mentor to suggest personalized, data-backed weekly and monthly coding goals. It leverages Gemini (or Groq) to analyze recent contributions, streaks, PRs, and active language statistics, caches results in the database, and exposes an interactive dashboard UI that allows developers to pre-fill and set goals with a single click.

Closes #2984


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • [supabase/schema.sql]:
    • Updated the check constraint on ai_insights.insight_type to support personality and goal_suggestions values, preventing database validation errors when storing generated insights.
  • [src/lib/ai-prompts.ts]:
    • Defined GoalMentorPromptParams interface and added the goalMentorPrompt template function. The prompt instructs the model to return exactly 3 goals in a structured JSON schema alongside personalized logic/reasoning.
  • [src/app/api/goals/mentor-suggestions/route.ts]:
    • Created a backend API route utilizing NextAuth session mapping and Supabase admin connections.
    • Added caching (24-hour TTL in ai_insights) and rate-limiting (5 requests/hour via Upstash Redis or local memory fallback).
    • Aggregated user commits, streaks, merges, and language profiles to pass to the LLM.
    • Wired up Gemini (gemini-2.5-flash) as the primary generator, Groq (llama-3.3-70b-versatile) as the secondary fallback, and structured static heuristics as the tertiary local fallback.
  • [src/components/GoalTracker.tsx]:
    • Extended layout state hooks to fetch AI recommendations on widget mount.
    • Rendered the "AI Goal Mentor" cards section above the Goal Creation form.
    • Implemented skeleton loading indicators, error boundaries, and source metadata labels.
    • Programmed clicking a card to auto-fill the creation fields and scroll to/highlight the creation form.

How to Test

  1. Start the local server and verify that environment keys are set (e.g., GEMINI_API_KEY or GROQ_API_KEY).
  2. Go to the dashboard and open the Goals widget.
  3. Locate the new AI Goal Mentor section loaded above the creation form. Verify that three personalized suggestions appear (or standard static suggestions if keys are omitted).
  4. Click on any of the suggestion cards: the creation form below should instantly pre-populate with the suggestion's title, target, unit, and recurrence, while smooth-scrolling and highlighting the input border.
  5. Click Create Goal and verify that it syncs and updates successfully.
  6. Click Regenerate suggestions in the mentor header: verify that loading skeletons display and fresh suggestions are fetched (cache bypass).

Expected result: AI suggestions populate successfully on mount or regeneration, and auto-populate the creation form correctly on click.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

  • Keyboard navigation works correctly (cards are focusable and clickable via keyboard)
  • Color contrast meets WCAG AA standard
  • ARIA labels / roles added where needed
  • Tested on mobile / responsive layout (cards transition from columns on desktop to stack on mobile)

Additional Context

Caching is used to minimize external LLM token fees and guarantee dashboard loads stay fast. The API route fallbacks guarantee a fully-functioning experience even in local environment setups without keys.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

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

@hrshjswniii

Copy link
Copy Markdown
Contributor Author

Hiii @Priyanshu-byte-coder , do review the issue implemented and feel free to merge the Pr !!

@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

New feature/UI PRs are on hold during the code-quality sprint — see discussion #2651. We'll revisit this after the sprint; meanwhile tests, refactors, and bug-fix PRs are very welcome.

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

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] : AI-Driven Goal Mentor (AI Feature)

2 participants