Skip to content

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

VishvaRoop

License Node.js React AI Powered

Universal AI-Powered Algorithm Visualizer

Visualize any algorithm problem instantly using the power of Generative AI. ๐Ÿช„โœจ

VishvaRoop is a next-generation education tool that transforms static algorithm problems into dynamic, step-by-step visualizations. By combining Large Language Models (Gemini/Ollama) with a robust "Entity-Action" architecture, it understands complex problem statements and renders semantic animations. ๐ŸŽฌ


๐Ÿš€ Key Features

  • ๐ŸŒ Universal Visualization: Currently supports 4 data structures: Arrays, Stacks, Queues, and BST. We are actively working on adding more!
  • ๐Ÿง  AI-Driven Core: Leverages Google Gemini โœจ and Ollama ๐Ÿฆ™ to parse problems and generate deterministic execution steps.
  • ๐Ÿ—๏ธ Entity-Action Architecture: A novel approach that normalizes LLM output into verifiable actions (Create, Select, Move, Highlight) for consistent rendering.
  • ๐Ÿ›ก๏ธ Adaptive Fallbacks: Built-in deterministic executors ensure visualization continuity even if the AI output is imperfect.
  • โฏ๏ธ Interactive Playback: Full control with Play/Pause, Step Forward/Back.
  • ๐Ÿ“š Rich Data Structures: Visualizes Arrays, Binary Trees, Stacks, Queues (MVP Phase).
  • ๐ŸŽจ Modern UI: A sleek, dark-themed experience built with React and Tailwind CSS.

๐Ÿ› ๏ธ Tech Stack

๐Ÿ–ฅ๏ธ Frontend

โš™๏ธ Backend

  • Runtime: Node.js ๐ŸŸข & Express ๐Ÿš‚
  • AI Integration:
    • Google Gemini (Cloud) โœจ
    • Ollama (Local LLM) ๐Ÿฆ™
  • Architecture: Service-Controller pattern with Custom Normalizers ๐Ÿ“

๐Ÿ”„ Architecture & Flow

  1. โŒจ๏ธ Input: User inputs a problem statement (e.g., "Find the maximum subarray sum").
  2. ๐Ÿ” Analysis: The LLM Service (Gemini/Ollama) analyzes the problem type and generates a logical plan.
  3. ๐Ÿ“ Normalization: The Universal Normalizer converts raw AI output into a strictly structured JSON of Entities and Actions.
  4. โš™๏ธ Execution: The Executor Engine runs the logic (with deterministic fallbacks).
  5. ๐ŸŽจ Rendering: The Frontend VisualCanvas interprets the frames and manages state transitions using Anime.js.

๐Ÿ“š Supported Algorithms & Data Structures

๐Ÿ“Š Data Structures

  • Arrays - Linear data structure with indexing support
  • Binary Search Trees (BST) - Hierarchical structure with ordered nodes
  • Stacks - LIFO (Last In, First Out) operations
  • Queues - FIFO (First In, First Out) operations

๐Ÿงฎ Algorithms

  • Sorting Algorithms: Bubble Sort, Selection Sort, Insertion Sort, Quick Sort, Merge Sort
  • Searching Algorithms: Binary Search, Linear Search
  • Tree Traversals: Inorder, Preorder, Postorder, Level-order (BFS)
  • Tree Operations: Insert, Remove, Search in BST
  • Stack Operations: Push, Pop, Peek, Valid Parentheses
  • Queue Operations: Enqueue, Dequeue, BFS Traversal
  • Array Algorithms: Two Sum, Three Sum, Sliding Window, Two Pointer Problems
  • Dynamic Programming: Work In Progress! ๐Ÿšง
  • Graph Algorithms: Work In Progress! ๐Ÿšง

๐ŸŒ API Documentation

๐Ÿ”Œ Backend Endpoints

POST /api/classify

Classifies an algorithm problem and generates visualization frames.

Request Body:

{
  "problemStatement": "string"
}

Response:

{
  "structures": [
    {
      "id": "string",
      "type": "string",
      "label": "string",
      "data": "array"
    }
  ],
  "frames": [
    {
      "id": "string",
      "title": "string",
      "description": "string",
      "entities": [
        {
          "id": "string",
          "type": "string",
          "data": "array",
          "meta": "object"
        }
      ],
      "actions": [
        {
          "type": "string",
          "target": "string",
          "indices": "array",
          "value": "any"
        }
      ],
      "variables": "object"
    }
  ],
  "intent": {
    "domain": "string",
    "algorithm": "string",
    "source": "string"
  }
}

GET /health

Health check endpoint to verify server status.

Response:

{
  "status": "OK",
  "timestamp": "ISO date string"
}

๐Ÿƒโ€โ™‚๏ธ How to Run Locally

๐Ÿ“‹ Prerequisites

  • Node.js (v18 or higher) ๐ŸŸข
  • npm or yarn ๐Ÿ“ฆ
  • (Optional) Ollama ๐Ÿฆ™ installed locally for offline AI support.

๐Ÿ“ฅ Installation

  1. Clone the repository ๐Ÿ‘ฏ

    git clone https://github.com/PatilSharvil/AI-Problem-Visualizer.git
    cd AI-Problem-Visualizer
  2. Install Backend Dependencies ๐Ÿ› ๏ธ

    cd backend
    npm install
  3. Install Frontend Dependencies ๐Ÿ’…

    cd ../frontend
    npm install

โš™๏ธ Configuration

Create a .env file in the backend/ directory:

# Server Port
PORT=5000

# AI Provider Configuration (Choose 'gemini' or 'ollama')
LLM_PROVIDER=gemini

# If using Gemini โœจ
GEMINI_API_KEY=your_gemini_api_key_here

# If using Ollama ๐Ÿฆ™
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5-coder:7b-instruct

# Enable/disable executors (default: true)
ENABLE_EXECUTORS=true

# Local model flag (set to true if using Ollama)
LOCAL_MODEL=false

๐Ÿ Start the Application

Backend: ๐Ÿ”Œ

cd backend
npm run dev
# Server running on http://localhost:5000

Frontend: ๐Ÿ–ฅ๏ธ

cd frontend
npm run dev
# App running on http://localhost:5173

๐Ÿ› ๏ธ Development Setup

๐Ÿงช Running Tests

Currently, the project doesn't have automated tests set up, but we recommend manual testing of new features.

๐Ÿงน Linting & Formatting

The project follows standard JavaScript/React formatting conventions. Use your IDE's formatter for consistency.

๐Ÿš€ Environment Variables Explained

Variable Description Required
PORT Backend server port Yes
LLM_PROVIDER AI provider ('gemini' or 'ollama') Yes
GEMINI_API_KEY Google Gemini API key (if using gemini) Conditional
OLLAMA_URL Ollama server URL Conditional
OLLAMA_MODEL Ollama model name Conditional
LOCAL_MODEL Flag to enable local model mode No (defaults to false)
ENABLE_EXECUTORS Enable deterministic fallback executors No (defaults to true)

๐Ÿ› ๏ธ Debugging Tips

  1. Enable detailed logging: Add console.log statements in the backend controllers to trace the flow
  2. Check network tab: Monitor API requests in browser DevTools to see request/response details
  3. Verify data format: Ensure the backend is returning properly formatted frames that the frontend expects
  4. Test with simple problems: Start with basic problems like "binary search for 5 in [1,2,3,4,5,6,7]" to verify functionality

๐Ÿ“‹ Example Problems

Try these sample problems to see the visualizations in action:

๐Ÿ” Searching Algorithms

  • "Binary search for 5 in [1,2,3,4,5,6,7]"
  • "Linear search for 3 in [10,20,30,40,5,50]"

๐Ÿงฎ Sorting Algorithms

  • "Sort array [64,34,25,12,22,11,90] using bubble sort"
  • "Sort [5,2,4,6,1,3] using insertion sort"

๐ŸŒณ Tree Operations

  • "Insert 4,2,6,1,3,5,7 into BST and then search for 5"
  • "Inorder traversal of BST [4,2,6,1,3,5,7]"
  • "Preorder traversal of BST [4,2,6,1,3,5,7]"

๐Ÿ“ฆ Stack Operations

  • "Validate parentheses in string '()[]{}'"
  • "Reverse string 'hello' using stack"

๐Ÿ“ฅ Queue Operations

  • "Level order traversal of BST [4,2,6,1,3,5,7]"

๐Ÿ“Š Performance Considerations

  • Response Times: API calls typically take 2-5 seconds depending on the complexity of the problem and the selected AI provider
  • Rate Limits: When using cloud providers, be aware of API rate limits
  • Local Models: Ollama provides faster response times but requires more local resources
  • Complexity: More complex algorithms with many steps will generate more frames and take longer to process

๐Ÿค Contributing

We welcome contributions to VishvaRoop! Here's how you can help:

๐Ÿ› ๏ธ Development Guidelines

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

โ“ Frequently Asked Questions (FAQ)

Q: What types of algorithm problems does VishvaRoop support?

A: Currently, VishvaRoop supports problems involving Arrays, Binary Search Trees, Stacks, and Queues. This includes sorting, searching, traversal, and basic operations on these data structures.

Q: Can I use VishvaRoop without an internet connection?

A: Yes! By configuring the system to use Ollama with a local LLM, you can run VishvaRoop completely offline.

Q: How accurate are the visualizations?

A: VishvaRoop uses a combination of AI and deterministic executors to ensure accuracy. The system has fallback mechanisms to maintain correctness even when AI output is imperfect.

Q: Is my problem statement sent to external servers?

A: If you use cloud providers like Google Gemini, your problem statement is sent to their servers. For complete privacy, use the local Ollama option.

Q: Can I extend VishvaRoop to support new data structures?

A: Absolutely! The entity-action architecture is designed to be extensible. You can add new visualization components and corresponding executors.

๐Ÿ“‚ Folder Structure

VishvaRoop/
โ”œโ”€โ”€ backend/ โš™๏ธ
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/      # Request handlers ๐Ÿ•น๏ธ
โ”‚   โ”‚   โ”œโ”€โ”€ services/         # LLM Adapter, Executors, Normalizer ๐Ÿง 
โ”‚   โ”‚   โ”œโ”€โ”€ schemas/          # Validation schemas ๐Ÿ›ก๏ธ
โ”‚   โ”‚   โ””โ”€โ”€ routes/           # API Endpoints ๐Ÿ›ฃ๏ธ
โ”‚   โ””โ”€โ”€ server.js             # Entry point ๐Ÿšช
โ”‚
โ”œโ”€โ”€ frontend/ ๐ŸŽจ
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ entities/     # Visualizers (Array, Tree, Graph...) ๐Ÿ“Š
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚   โ”œโ”€โ”€ pages/            # Landing, VisualizerPage ๐Ÿ“„
โ”‚   โ”‚   โ””โ”€โ”€ App.jsx
โ”‚   โ””โ”€โ”€ index.html
โ””โ”€โ”€ README.md

๐Ÿšง Known Limitations

  • Limited Data Structures: Currently supports only Arrays, BSTs, Stacks, and Queues
  • AI Dependency: Quality of visualizations depends on AI model's understanding
  • Complex Problem Parsing: Very complex or ambiguous problem statements may not be interpreted correctly
  • Performance: Complex algorithms may take longer to generate visualizations
  • Language Support: Optimized for English problem statements

๐Ÿ”ฎ Future Enhancements

  • ๐Ÿ“ˆ Expanded Graph algorithms (Dijkstra, Bellman-Ford, etc).
  • ๐Ÿ—๏ธ Expanded Data structures (Linked List, Graph, Matrix, etc).
  • ๐Ÿงฉ Expanded Algorithms (Sorting, Searching, Graph Traversal, etc).
  • ๐Ÿค– Betterment in deterministic engine.
  • ๐Ÿ“ฑ Mobile-responsive improvements
  • ๐ŸŽจ Customizable visualization themes
  • ๐Ÿ“ค Export visualizations as images/videos
  • ๐ŸŒ Multi-language support for problem statements
โ€œThe future of engineering belongs to those who help others understand.โ€

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages