Skip to content

feat: support multi-platform DSA problems and code optimization display #5

Description

@TruCoded

Feature Request: Multi-Platform Coding Problems & Code Optimization Output

Context & Scope

  • Maintainer / Repository Owner: @TruCoded
  • Difficulty: 🟡 Medium (Updates existing parsing tags, mock data, and UI dropdown logic)

📖 Description

We want to expand our AI analysis feature to support multi-platform coding recommendations instead of restricting links strictly to LeetCode. Additionally, the backend and frontend need updates to extract, pass, and render the best-optimized version of the user's code along with its time and space complexities.


Backend Implementation Tasks

ai_service.py

  • Rename Tags: Change LEETCODE_PROBLEMS_START / LEETCODE_PROBLEMS_END to PLATFORM_PROBLEMS_START / PLATFORM_PROBLEMS_END.
  • Update Prompt (get_explain_prompt):
    • Update instructions inside the prompt to request problem recommendations from LeetCode, GeeksforGeeks, HackerRank, Coding Ninjas, Codolio, and Codeforces.
    • Enforce a strict output format for these problems: Platform | Title | Link.
  • Add New Tracking Tags: Add regex tracking markers for:
    • OPTIMIZED_CODE_START / OPTIMIZED_CODE_END
    • OPTIMIZED_TIME_COMPLEXITY_START / OPTIMIZED_TIME_COMPLEXITY_END
    • OPTIMIZED_SPACE_COMPLEXITY_START / OPTIMIZED_SPACE_COMPLEXITY_END
  • Enhance Gemini Prompt: Update the prompt to command the AI model to generate the most optimal version of the analyzed code along with its precise complexities.
  • Update Parsing (analyze_code): Update the return dictionary keys to extract and return: platform_problems, optimized_code, optimized_time_complexity, and optimized_space_complexity.

test_mock_ai.py

  • Update MOCK_EXPLAIN_RESPONSE: Swap out old LeetCode tags for the new PLATFORM_PROBLEMS tags.
  • Mock Multi-Platform Data: Add realistic mock problem data showcasing mixed platforms (e.g., GFG, Codeforces, HackerRank) using the Platform | Title | Link pattern.
  • Inject Optimization Mock Data: Add mock string segments wrapped in the new optimization tags.

test_features.py

  • Fix Assertions: Change verification logic to check for platform_problems instead of leetcode_problems.
  • Add Verification Prints: Ensure the test prints the extracted optimized code and complexities to verify the parser works seamlessly.

Frontend Implementation Tasks

index.html (CSS & HTML Markup)

  • Dropdown Styling: Add premium, glassmorphic dark-blue theme CSS styles for a new dropdown element: #dsa-platform-select. Include smooth transitions for :hover and :focus states.
  • DSA Section UI: Replace the static "LeetCode Practice Problems" header inside #sec-dsa with a flex container housing the section title and the new #dsa-platform-select dropdown menu.
  • Optimization Section UI: Create an "Optimized Code Block" container inside the Optimization Suggestions panel. Add a <pre> element to display the code cleanly, alongside functional "Copy" buttons.

Frontend JavaScript Logic

  • Global State: Declare a global tracking variable (e.g., currentPlatformProblems or cachedProblems) to hold the complete parsed array of multi-platform problems.
  • Dropdown Event Listener: Monitor changes on #dsa-platform-select to filter and re-render only the problems matching the selected platform (or show all if default).
  • Render Pipeline: Update the rendering engine to process the new optimized_code, optimized_time_complexity, and optimized_space_complexity values and inject them into the DOM.

Acceptance Criteria

  1. The AI successfully returns links from multiple coding platforms.
  2. Selecting a platform from the frontend dropdown correctly filters the displayed problem links in real-time.
  3. The UI perfectly renders a dedicated block displaying the optimized code with its time/space complexity.
  4. All backend mock and integration tests pass successfully without breaking existing code analysis tools.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions