Skip to content

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

Description

@hrshjswniii

Problem Statement

DevTrack allows developers to set manual coding goals (e.g., commits, merged PRs). However, users often struggle to set realistic, challenging, and meaningful goals. They either set arbitrary targets that are trivial to pass, or overshoot and set unreachable goals, leading to low completion rates. There is currently no feature that looks at a user's actual historical coding output (such as most active repositories, languages, and WakaTime coding hours) and offers personalized, data-backed goals.

Proposed Solution

We should build an AI Goal Mentor feature that provides personalized goal suggestions based on the user's recent contribution history.

  1. AI API Route (/api/goals/mentor-suggestions):
    • Fetch the user's last 14-30 days of metrics, including commits by repository, total PRs, language breakdowns, and average coding hours.
    • Format these metrics into a system prompt for the Groq/Gemini models.
    • Ask the model to return 3 goal suggestions in a structured JSON schema:
      {
        "suggestions": [
          {
            "title": "Boost JavaScript contributions",
            "target": 15,
            "unit": "commits",
            "repo": "owner/repo-name",
            "recurrence": "weekly",
            "reasoning": "You made 11 commits in JavaScript last week. Let's aim to push it to 15!"
          }
        ]
      }
  2. Caching:
    • Store generated suggestions in the ai_insights table under a new insight_type = 'goal_suggestions' with a 24-hour TTL (similar to /api/personality). This avoids repeating expensive model requests on page refreshes.
  3. Frontend UI Panel (src/components/GoalTracker.tsx):
    • Display a clean "AI Goal Mentor" section inside the goal-tracking page.
    • Render the recommendations as interactive cards showing the suggested target, unit, and the AI's brief reasoning.
    • Provide an "Accept Goal" action button that automatically fills and submits the goal creation form.
  4. Graceful Fallback:
    • If GROQ_API_KEY or GEMINI_API_KEY is not set, display a few standard rule-based recommendations (e.g., "Aim for 10 commits this week") and an educational message.

Feature Area

API / Backend

Alternatives Considered

  1. Simple Rule-Based Suggestion Engine:
    • Approach: Calculate suggestions strictly with hardcoded math (e.g., target = previous_week_commits * 1.2).
    • Why not chosen: This lacks conversational encouragement and cannot combine cross-repository context (e.g., noticing a user switched focus to a new Rust repository and suggesting a goal for that specific repository).
  2. Scheduled Weekly Suggestions:
    • Approach: Run a weekly cron job to calculate suggestions for all users and email them.
    • Why not chosen: Causes massive API cost spikes and database overhead. Generating on-demand with a 24-hour cache is much more cost-effective and responsive.

Acceptance Criteria

  • A new API route /api/goals/mentor-suggestions is created and secure (requires an active NextAuth session).
  • The prompt returns valid JSON adhering to the specified schema, utilizing Groq or Gemini.
  • Suggestions are cached in the database for 24 hours to enforce rate limits and optimize speed.
  • The Goal Tracker page features a responsive UI card section for the Goal Mentor, utilizing smooth transitions.
  • Clicking a suggestion card populates the goal form and allows single-click creation.
  • The feature degrades gracefully without throwing JavaScript errors if API keys are missing.

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgssoc:assignedGSSoC: Issue assigned to a contributorneeds-triageNeeds maintainer triage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions