Skip to main content

X-ray vision for your Python data structures - ASCII mind maps and tree visualizations

Project description

MXRay Logo

๐Ÿ” MXRay

X-ray vision for your Python data structures

PyPI version Python versions License GitHub stars

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mxray-0.1.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mxray-0.1.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

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

Hashes for mxray-0.1.1.tar.gz
Algorithm Hash digest
SHA256 01a0d2d682ac86c974748a05eb2a2f1901c81a5e2b3e2eb26abc23fbeb2ea3e5
MD5 47a86c1b4ed9fe566f29de427719bb86
BLAKE2b-256 06276828870c8c398728c97126ca6e77c17e9cfe3af1dbfaeeb225d66dc24d0b

See more details on using hashes here.

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

Hashes for mxray-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c831785e540793c55feb8103c1c987e4a8211490d7c51892b77456193c48833
MD5 52c32eb9bd89f048815d4dcbc2d11322
BLAKE2b-256 60c7a0b446c6e7eec8e2642bbc35461736c3ec4b91277bf321d8eaeeea46e6a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page