- Live at: https://perplexitree.app/
- Live demo: https://www.youtube.com/watch?v=P5U9jo97fCk
A beautiful, interactive web game that combines the meditative puzzle mechanics of "Prune" with AI-powered knowledge exploration. Players grow knowledge trees by pruning branches while leveraging the Perplexity API to discover unique, real-time information on any topic. Each growth session returns fresh, non-redundant search results to build comprehensive understanding.
Purpose: perplexitree transforms learning into an engaging, visual experience where users cultivate knowledge trees through strategic pruning and AI-enhanced exploration. The game addresses information overload by presenting unique, curated insights through an intuitive tree metaphor.
Technical Approach: Built with a modular architecture featuring FastAPI backend and vanilla JavaScript frontend, the application integrates Perplexity's real-time search capabilities to generate unique knowledge areas for each growth session. The system ensures non-redundant information retrieval through intelligent query generation and structured output parsing.
Perplexity API Integration: The game leverages Perplexity's reasoning and retrieval capabilities through a two-phase approach:
- Initial Search: Uses Perplexity's
sonar-prochat completion model with structured JSON output to generate 5 unique knowledge areas from the initial query - Subsequent Growth: Uses Perplexity's search model with negative prompting to find unique web results for each new branch
- Flashcard Generation: Uses
sonar-prochat completion to create study materials from search results - Unique Results: Negative prompting system ensures each growth session returns fresh, non-redundant information
The integration ensures players receive diverse, comprehensive information while maintaining the game's meditative, focused learning experience.
- AI-Powered Knowledge Tree: Grow branches that represent real search results from Perplexity API
- Interactive Tools: 7 different tools for managing your knowledge tree
- Unique Search Results: Each growth session returns fresh, non-redundant information
- Study System: Create flashcards from search results for enhanced learning
- Visual Progression: Transform knowledge into flowers and fruits
- Game State Persistence: Save and load your knowledge trees
- Growth Tool: Click on nodes to grow new branches with search results
- Cut Tool: Click and drag to prune unwanted branches
- Leaves Tool: Create flashcards from search results on branches
- Flower Tool: Add flowers to branch ends (knowledge blossoming)
- Fruit Tool: Transform flowers into apples (fruit of labor)
- Reposition Tool: Drag branch ends to move and resize branches
- Study Tool: Hover over nodes to view search result details
- Pan Tool: Drag to move around the view
- Start: Enter a search query to begin growing your knowledge tree
- Grow: Use the growth tool to expand branches with AI-powered search results
- Prune: Cut away branches that don't contribute to your learning goals
- Study: Create flashcards and study materials from your search results
- Progress: Watch your knowledge tree evolve with flowers and fruits
- Python 3.8+
- Virtual environment (recommended)
- Navigate to the backend directory:
cd backend- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the server:
python main.py- Open your browser and go to:
http://localhost:8001
Create a .env file in the backend/ directory:
PERPLEXITY_API_KEY=your_perplexity_api_key_here
- Backend: FastAPI server with SQLite database
- Frontend: Vanilla JavaScript with HTML5 Canvas rendering
- AI Integration: Perplexity API for real-time knowledge generation
POST /api/search - Initial Knowledge Tree Creation
- Uses Perplexity
sonar-prowith structured JSON output - Generates exactly 5 unique knowledge areas from user query
POST /api/web-search - Branch Growth with Negative Prompting
- Key Feature: Uses negative prompting to exclude existing results
- Ensures each growth session returns fresh, non-redundant information
- Constructs queries like:
"machine learning -"existing result 1" -"existing result 2"
POST /api/save-game-state - Public Game Storage
- Saves complete game state (public saves - all games are shareable)
- Stores branches, search results, flashcards, and visual elements
POST /api/create-flashcards - AI Study Material Generation
- Uses Perplexity to create flashcards from search content
- Links flashcards to specific tree nodes with difficulty ratings
- Initial Search:
sonar-prochat completion for structured knowledge areas - Subsequent Growth: Search API with negative prompting for unique results
- Purpose: Prevents redundant information across growth sessions
- Implementation: Excludes existing search result titles and snippets
- Result: Each branch growth returns fresh, unique content
- Relational Model: GameSession → SearchResult → Branch hierarchy
- Public Access: All saved games are publicly accessible
- Cascade Deletion: Automatic cleanup when sessions are deleted
Backend: FastAPI, SQLAlchemy, Perplexity API
Frontend: HTML5 Canvas, Vanilla JavaScript
Database: SQLite with relational modeling
Created for Perplexity Hackathon. Tree growth/prune mechanic inspired by Prune game by Joel McDonald.