File size: 11,924 Bytes
240e5bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | # π§ Technical Mindmap Generator
> An AI-powered Streamlit application that generates interactive radial mindmaps for technical keywords using Gemini, Tavily, and Knowledge Graph APIs.



---
## β¨ Features
- π― **Interactive Radial Mindmaps**: Beautiful, explorable visualizations with zoom, pan, and hover
- π€ **AI-Powered Analysis**: Leverages three powerful APIs for comprehensive results
- β‘ **Optimized Performance**: Sequential API calls with async processing
- π¨ **Modern UI**: Clean, responsive design inspired by GPT/Claude/Perplexity
- π **Query History**: Track and revisit previous mindmaps in the same session
- π **Real-time Data**: Fresh insights from authoritative web sources
---
## ποΈ Architecture
### Sequential API Call Strategy
The application uses an optimized 3-step approach for maximum data quality:
```
User Input (Technical Keyword)
β
βββββββββββββββββββββββββββββββββββ
β STEP 1: Tavily API β
β β’ Web search & context β
β β’ Related term extraction β
β β’ Source collection β
βββββββββββββββββββββββββββββββββββ
β (context + terms)
βββββββββββββββββββββββββββββββββββ
β STEP 2: Knowledge Graph API β
β β’ Structured entity data β
β β’ Relationship mapping β
β β’ Entity descriptions β
βββββββββββββββββββββββββββββββββββ
β (entities + relationships)
βββββββββββββββββββββββββββββββββββ
β STEP 3: Gemini AI β
β β’ Synthesis of all data β
β β’ Mindmap structure generation β
β β’ Hierarchical organization β
βββββββββββββββββββββββββββββββββββ
β
PyVis Radial Visualization
```
**Why Sequential?**
Each API call benefits from context gathered in previous steps, maximizing relevance and reducing noise.
---
## π¦ Installation
### Prerequisites
- **Python 3.9+**
- **pip** package manager
- **API Keys:**
- [Gemini API Key](https://ai.google.dev/) (Free tier available)
- [Tavily API Key](https://tavily.com/) (Free tier: 1000 requests/month)
- [Google Cloud Project](https://console.cloud.google.com/) with Knowledge Graph API enabled
### Step-by-Step Setup
#### 1. Clone or Download the Project
```bash
# If using git
git clone <repository-url>
cd technical-mindmap-generator
# Or download and extract the ZIP file
```
#### 2. Create Virtual Environment
```bash
# Create virtual environment
python -m venv venv
# Activate it
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
```
#### 3. Install Dependencies
```bash
pip install -r requirements.txt
```
This will install:
- streamlit
- pyvis
- networkx
- google-generativeai
- tavily-python
- google-cloud-enterpriseknowledgegraph
- aiohttp
- python-dotenv
- pydantic
- requests
#### 4. Configure API Keys
Create a `.env` file in the project root:
```bash
# Copy the example file
cp .env.example .env
# Edit with your API keys
nano .env # or use any text editor
```
Add your API keys to `.env`:
```env
GEMINI_API_KEY=your_actual_gemini_api_key_here
TAVILY_API_KEY=your_actual_tavily_api_key_here
GOOGLE_CLOUD_PROJECT_ID=your_google_cloud_project_id_here
# Optional settings
MAX_CONCURRENT_REQUESTS=3
CACHE_ENABLED=true
DEBUG_MODE=false
MAX_NODES=20
MAX_DEPTH=2
```
#### 5. Get Your API Keys
**Gemini API Key:**
1. Visit https://ai.google.dev/
2. Click "Get API Key"
3. Sign in with Google account
4. Create new API key
5. Copy the key
**Tavily API Key:**
1. Visit https://tavily.com/
2. Sign up for free account
3. Navigate to API Keys section
4. Copy your API key
**Google Cloud Knowledge Graph:**
1. Visit https://console.cloud.google.com/
2. Create new project or select existing
3. Enable "Enterprise Knowledge Graph API"
4. Copy your project ID
#### 6. Run the Application
```bash
streamlit run app.py
```
The application will open automatically in your browser at `http://localhost:8501`
---
## π Usage
### Basic Workflow
1. **Enter Keyword**: Type any technical term (e.g., "Machine Learning", "Kubernetes")
2. **Generate**: Click the "π Generate Mindmap" button
3. **Wait**: Processing takes 10-15 seconds as data is fetched from all APIs
4. **Explore**: Interact with the mindmap:
- π **Zoom**: Mouse wheel or pinch gesture
- π **Pan**: Click and drag
- βΉοΈ **Hover**: View detailed node information
- π§ **Navigate**: Use built-in navigation controls
5. **View Details**: Expand the metadata section for sources and statistics
6. **New Query**: Enter another keyword; previous mindmaps saved in history
### Example Keywords to Try
- **AI/ML**: Machine Learning, Neural Networks, Deep Learning, Transformers
- **DevOps**: Kubernetes, Docker, CI/CD, Microservices
- **Blockchain**: Ethereum, Smart Contracts, DeFi, NFTs
- **Cloud**: AWS, Serverless, Cloud Native, Edge Computing
- **Programming**: Python, JavaScript, Rust, TypeScript
---
## π Project Structure
```
technical-mindmap-generator/
β
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .env # Your API keys (create this)
βββ README.md # This file
β
βββ config/
β βββ __init__.py
β βββ settings.py # Configuration management
β
βββ utils/
βββ __init__.py
βββ api_handler.py # API integration layer
βββ mindmap_generator.py # PyVis visualization
```
---
## βοΈ Configuration
### Environment Variables
Edit `.env` to customize behavior:
| Variable | Default | Description |
|----------|---------|-------------|
| `GEMINI_API_KEY` | Required | Gemini AI API key |
| `TAVILY_API_KEY` | Required | Tavily search API key |
| `GOOGLE_CLOUD_PROJECT_ID` | Required | Google Cloud project ID |
| `MAX_CONCURRENT_REQUESTS` | 3 | Max parallel API calls |
| `CACHE_ENABLED` | true | Enable result caching |
| `DEBUG_MODE` | false | Enable debug logging |
| `MAX_NODES` | 20 | Maximum nodes in mindmap |
| `MAX_DEPTH` | 2 | Maximum hierarchy depth |
### Customization
**Mindmap Colors** (in `utils/mindmap_generator.py`):
```python
self.level_colors = {
0: "#ff6b6b", # Center - red/coral
1: "#4ecdc4", # Primary - teal
2: "#95e1d3", # Secondary - light teal
3: "#f9ca24", # Tertiary - yellow
4: "#a29bfe" # Quaternary - purple
}
```
**UI Theme** (in `app.py` CSS section):
- Modify gradient colors
- Adjust border radius
- Change font sizes and families
---
## π Troubleshooting
### Common Issues
**Issue: "Missing API Keys" error**
- **Solution**: Ensure `.env` file exists and contains valid API keys
- Check that `.env` is in the project root directory
- Verify no extra spaces around `=` in `.env`
**Issue: Mindmap not displaying**
- **Solution**: Check browser console for JavaScript errors
- Try refreshing the page (Ctrl+R or Cmd+R)
- Ensure PyVis generated HTML successfully
**Issue: Slow performance**
- **Solution**:
- Reduce `MAX_NODES` in `.env`
- Check internet connection
- Verify API rate limits not exceeded
**Issue: "Import Error" on startup**
- **Solution**:
- Ensure virtual environment is activated
- Run `pip install -r requirements.txt` again
- Check Python version is 3.9+
**Issue: Knowledge Graph API error**
- **Solution**:
- Verify Google Cloud project has Knowledge Graph API enabled
- Check project ID is correct
- Ensure billing is enabled (free tier available)
### Debug Mode
Enable debug logging:
```bash
# In .env
DEBUG_MODE=true
```
Then check console output for detailed error messages.
---
## π§ Development
### Adding New Features
**Add a new API source:**
1. Edit `utils/api_handler.py`
2. Add new async method (e.g., `fetch_xyz_data`)
3. Integrate into `fetch_all_data()` method
4. Update documentation
**Customize visualization:**
1. Edit `utils/mindmap_generator.py`
2. Modify `create_radial_mindmap()` method
3. Update PyVis options for physics/styling
### Testing
Run a simple test:
```python
# test_api.py
from utils.api_handler import fetch_mindmap_data
from config.settings import settings
result = fetch_mindmap_data(
keyword="Python",
gemini_key=settings.gemini_api_key,
tavily_key=settings.tavily_api_key,
google_project_id=settings.google_cloud_project_id
)
print(f"Nodes: {len(result['mindmap']['nodes'])}")
print(f"Edges: {len(result['mindmap']['edges'])}")
```
---
## π― API Usage & Costs
### Free Tier Limits
**Gemini API:**
- 60 requests per minute
- 1500 requests per day
- Free for personal use
**Tavily API:**
- 1000 requests per month (free tier)
- Upgrade available for more
**Knowledge Graph API:**
- 100,000 free calls per day
- No credit card required for free tier
### Cost Optimization Tips
1. Enable caching to reduce redundant calls
2. Use `MAX_NODES` to limit result size
3. Batch similar queries if possible
4. Monitor usage in respective dashboards
---
## π Tech Stack
| Technology | Purpose | Version |
|------------|---------|---------|
| **Streamlit** | Web framework | 1.28+ |
| **PyVis** | Graph visualization | 0.3.2+ |
| **NetworkX** | Graph algorithms | 3.1+ |
| **Gemini AI** | Language model | Latest |
| **Tavily** | Web search | Latest |
| **Knowledge Graph** | Entity data | Latest |
| **AsyncIO** | Async operations | Built-in |
| **Pydantic** | Data validation | 2.0+ |
---
## π€ Contributing
Contributions are welcome! Here's how:
1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request
### Development Guidelines
- Follow PEP 8 style guide
- Add docstrings to all functions
- Test thoroughly before submitting
- Update documentation as needed
---
## π License
This project is licensed under the MIT License - see LICENSE file for details.
---
## π Acknowledgments
- [Streamlit](https://streamlit.io/) - Amazing web framework
- [PyVis](https://pyvis.readthedocs.io/) - Interactive visualizations
- [Google Gemini](https://ai.google.dev/) - Powerful AI synthesis
- [Tavily](https://tavily.com/) - Real-time web search
- [Google Knowledge Graph](https://developers.google.com/knowledge-graph) - Structured data
---
## π§ Support
For issues, questions, or suggestions:
- Open an issue on GitHub
- Email: your.email@example.com
- Documentation: See inline code comments
---
## π Roadmap
### Upcoming Features
- [ ] Export mindmaps as PNG/SVG/PDF
- [ ] Persistent storage with database
- [ ] User authentication and sharing
- [ ] Custom color themes
- [ ] Advanced filtering options
- [ ] Integration with more knowledge sources
- [ ] Collaborative editing
- [ ] Mobile app version
- [ ] API endpoint for programmatic access
---
**Built with β€οΈ using Python, Streamlit, and AI**
---
## πΈ Screenshots
*Add screenshots of your application here*
---
**Last Updated:** October 2025
**Version:** 1.0.0
**Status:** Production Ready
|