X-ray vision for your Python data structures - ASCII mind maps and tree visualizations
Project description
๐ MXRay
X-ray vision for your Python data structures
See through complex nested data structures with beautiful ASCII mind maps and trees
๐ Quick Install
```bash
pip install mxray
๐ก Instant Insight
from mxray import xray
data = {
'project': 'MXRay',
'creator': 'Midhun Haridas',
'features': ['smart_icons', 'multiple_styles', 'exporters'],
'config': {
'debug': True,
'max_depth': 5
}
}
xray(data)
๐ Output
๐ฆ root
โโโ ๐ project: 'MXRay'
โโโ ๐จ๐ป creator: 'Midhun Haridas'
โโโ โจ features
โ โโโ ๐ง smart_icons
โ โโโ ๐จ multiple_styles
โ โโโ ๐พ exporters
โโโ โ๏ธ config
โโโ ๐ debug: True
โโโ ๐ max_depth: 5
๐ Table of Contents
Why MXRay?
Quick Start
Core Features
Usage Examples
Advanced Features
Command Line Interface
API Reference
Installation
Contributing
License
Support
โ Why MXRay?
The Problem
import json
print(json.dumps(complex_data, indent=2))
# Output: Hundreds of lines of nested braces and brackets
# ๐ต Hard to understand structure
# ๐ Difficult to find specific data
# ๐ No visual hierarchy
The Solution
from mxray import xray
xray(complex_data)
# Output: Beautiful, intuitive ASCII mind map
# ๐ฏ Instant understanding of data structure
# ๐ Clear parent-child relationships
# ๐จ Visual hierarchy with smart icons
๐ Quick Start
Basic Usage
from mxray import xray
# One-liner magic
xray(your_data)
# Or with more control
from mxray import MindMap
mind_map = MindMap(your_data)
print(mind_map)
From Various Sources
from mxray import MindMapFactory
# From JSON string
mind_map = MindMapFactory.from_json('{"name": "Midhun", "project": "MXRay"}')
# From file
mind_map = MindMapFactory.from_file('data.json')
# From URL
mind_map = MindMapFactory.from_url('https://api.github.com/users/MidhunHaridas')
# From API response
import requests
response = requests.get('https://api.example.com/data')
xray(response.json())
โจ Core Features
๐จ Multiple Visualization Styles
from mxray import Styles
data = {'api': {'users': [], 'settings': {}}}
xray(data, style=Styles.TREE) # Default tree style
xray(data, style=Styles.MINIMAL) # Clean minimal style
xray(data, style=Styles.ARROW) # Arrow connectors
xray(data, style=Styles.BOXED) # Boxed sections
๐ Smart Search & Highlight
from mxray import MindMap
mind_map = MindMap(complex_data)
mind_map.search("Midhun") # Highlights all occurrences
print(mind_map)
๐ Data Type & Memory Insights
xray(data, show_types=True, show_memory=True)
Output
๐ฆ root (dict) [240 bytes]
โโโ ๐ค user (dict) [48 bytes]
โ โโโ ๐ name: 'Midhun' (str) [54 bytes]
โ โโโ ๐ข age: 25 (int) [28 bytes]
๐ญ Beautiful Themes
from mxray import Themes
xray(data, theme=Themes.PROFESSIONAL) # Clean business icons
xray(data, theme=Themes.COLORFUL) # Vibrant colorful icons
xray(data, theme=Themes.EMOJI) # Fun emoji icons (default)
๐พ Multiple Export Formats
from mxray import save_mind_map
mind_map = MindMap(data)
save_mind_map(mind_map, "structure.md") # Markdown
save_mind_map(mind_map, "structure.html") # Interactive HTML
save_mind_map(mind_map, "structure.json") # JSON structure
๐ ๏ธ Usage Examples
API Response Analysis
import requests
from mxray import xray
# Analyze GitHub API response
response = requests.get('https://api.github.com/users/MidhunHaridas')
xray(response.json(), show_types=True)
Configuration File Inspection
import yaml
from mxray import xray
with open('config.yaml') as f:
config = yaml.safe_load(f)
xray(config, style="minimal", show_memory=True)
Database Schema Visualization
from mxray import xray
from my_app import models
# Visualize Django model structure
xray(models.User.__dict__)
Real-time Data Monitoring
from mxray import MindMap
import time
class DataMonitor:
def __init__(self):
self.previous_map = None
def monitor(self, data_source):
while True:
current_data = data_source.get_data()
current_map = MindMap(current_data)
if current_map != self.previous_map:
print("\033[2J\033[H") # Clear terminal
print(current_map)
self.previous_map = current_map
time.sleep(1)
๐ฌ Advanced Features
Focus on Specific Paths
# Zoom into specific data branches
xray(complex_data).focus_on("users[0].profile.settings")
Custom Filtering
from mxray import MindMap
mind_map = MindMap(data)
# Show only nodes with string values
filtered = mind_map.filter(lambda node: isinstance(node.value, str))
# Show only nodes with more than 2 children
complex_nodes = mind_map.filter(lambda node: len(node.children) > 2)
Custom Themes
custom_theme = {
"name": "midhun_theme",
"icons": {
"user": "๐จ๐ป",
"email": "๐จ",
"api_key": "๐",
"created_at": "๐",
"dict": "๐๏ธ",
"list": "๐"
}
}
xray(data, theme=custom_theme)
Interactive Exploration
from mxray import MindMap
# Explore large data structures interactively
mind_map = MindMap(huge_json_data)
mind_map.explore() # Opens interactive terminal browser
Command Line Interface
Basic Usage
# From JSON file
mxray data.json
# From URL
mxray https://api.github.com/users/MidhunHaridas
# From JSON string
mxray '{"name": "Midhun", "project": "MXRay"}'
# From stdin
echo '{"test": "data"}' | mxray
Advanced CLI Options
# Different visualization styles
mxray data.json --style minimal
mxray data.json --style arrow
# Show additional information
mxray data.json --show-types --show-memory
# Search and highlight
mxray data.json --search "Midhun"
# Custom theme
mxray data.json --theme professional
# Export to file
mxray data.json --output structure.html --format html
mxray data.json --output structure.md --format md
Full CLI Reference
mxray --help
usage: mxray [-h] [--style {tree,minimal,arrow,boxed}]
[--theme {default,professional,colorful,emoji}]
[--output OUTPUT] [--format {txt,md,html,json}]
[--search SEARCH] [--show-types] [--show-memory] [--no-icons]
[input]
X-ray data structures as ASCII mind maps
positional arguments:
input Input file, URL, or JSON string
options:
-h, --help show this help message and exit
--style {tree,minimal,arrow,boxed}
Visualization style
--theme {default,professional,colorful,emoji}
Icon theme
--output OUTPUT, -o OUTPUT
Output file
--format {txt,md,html,json}
Output format
--search SEARCH, -s SEARCH
Search and highlight text
--show-types Show data types
--show-memory Show memory usage
--no-icons Hide icons
๐ API Reference
Main Functions
xray(data, **kwargs)
The main one-liner function for instant visualization.
Parameters:
data: Any Python data structure (dict, list, etc.)
style: Visualization style ('tree', 'minimal', 'arrow', 'boxed')
show_icons: Boolean to enable/disable icons (default: True)
show_types: Boolean to show data types (default: False)
show_memory: Boolean to show memory usage (default: False)
theme: Icon theme ('default', 'professional', 'colorful', 'emoji')
max_depth: Maximum depth to visualize (default: None)
MindMap(data, **kwargs)
The main class for advanced usage.
Methods:
.render(): Returns the mind map as string
.search(query): Highlights nodes matching query
.filter(predicate): Filters nodes based on function
.focus_on(path): Zooms into specific data path
.explore(): Interactive exploration (future)
Factory Methods
MindMapFactory
.from_json(json_str): Create from JSON string
.from_file(file_path): Create from file
.from_url(url): Create from URL (requires requests)
Export Functions
save_mind_map(mind_map, file_path, format='auto')
Save mind map to various formats.
Formats:
txt: Plain text (default)
md: Markdown with code blocks
html: Interactive HTML
json: JSON structure
๐ฆ Installation
From PyPI (Recommended)
pip install mxray
From Source
git clone https://github.com/GxDrogers/mxray.git
cd mxray
pip install -e .
For Development
git clone https://github.com/GxDrogers/mxray.git
cd mxray
pip install -e ".[dev]"
pytest tests/ -v
Dependencies
Python 3.7+
Optional: requests for URL support
๐ค Contributing
We love contributions! Here's how you can help: Reporting Issues
Check existing issues
Create new issue with detailed description
Feature Requests
Suggest new features via issues
Discuss implementation approach
Code Contributions
Fork the repository
Create feature branch: git checkout -b feature/amazing-feature
Commit changes: git commit -m 'Add amazing feature'
Push to branch: git push origin feature/amazing-feature
Open Pull Request
Development Setup
git clone https://github.com/GxDrogers/mxray.git
cd mxray
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e ".[dev]"
pre-commit install
Running Tests
pytest tests/ -v
pytest tests/ --cov=mxray --cov-report=html
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐จ๐ป Author
Midhun Haridas
๐ง Email: midhunharidas0@gmail.com
๐ป GitHub: @GxDrogers
๐ Acknowledgments
Inspiration: Every developer who struggled with complex JSON structures
Testing: Early adopters and contributors
Community: Python packaging and open-source ecosystem
Icons: Twitter Emoji for the beautiful icons
๐Support
Documentation: GitHub Wiki
Issues: GitHub Issues
Discussions: GitHub Discussions
Email: midhunharidas0@gmail.com
๐ Ready to X-ray Your Data?
pip install mxray
โญ Star the repo if you find MXRay useful!
MXRay - See your data structures, don't just read them
```Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mxray-0.1.1.tar.gz.
File metadata
- Download URL: mxray-0.1.1.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01a0d2d682ac86c974748a05eb2a2f1901c81a5e2b3e2eb26abc23fbeb2ea3e5
|
|
| MD5 |
47a86c1b4ed9fe566f29de427719bb86
|
|
| BLAKE2b-256 |
06276828870c8c398728c97126ca6e77c17e9cfe3af1dbfaeeb225d66dc24d0b
|
File details
Details for the file mxray-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mxray-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c831785e540793c55feb8103c1c987e4a8211490d7c51892b77456193c48833
|
|
| MD5 |
52c32eb9bd89f048815d4dcbc2d11322
|
|
| BLAKE2b-256 |
60c7a0b446c6e7eec8e2642bbc35461736c3ec4b91277bf321d8eaeeea46e6a9
|