A Node.js utility that parses, analyzes, documents, and visualizes the Magento 2 core codebase to help developers understand how components interconnect, identify anti-patterns, and explore architectural relationships.
Current Phase: Phase 0 - Planning Complete, Implementation Starting
POC Target: Magento_Customer module Timeline: 4-week POC, then 5 phases over 18-21 weeks
See magento-mapping-tool-project-plan.txt for complete project roadmap.
- β Parse Magento XML configuration (di.xml, events.xml, module.xml)
- β Build in-memory graph of relationships
- β CLI queries for plugins, observers, and dependencies
- β Generate Mermaid diagrams
- Neo4j graph database integration
- PHP method call chain analysis
- Interactive D3.js visualization
- Known issues/gotchas annotation system
- Community contribution workflow
- Node.js 18+ (Download)
- Docker & Docker Compose (Download)
- Magento 2 installation (2.4.6+ recommended)
-
Clone or copy this directory to your machine
# If copying to a new machine, just copy the entire folder rsync -av /Volumes/External/magento-core/ /path/on/new/machine/ -
Run setup script
cd magento-core ./scripts/setup.shThis will:
- Check Node.js and Docker versions
- Install npm dependencies
- Guide you through configuration
-
Configure environment
cp .env.example .env nano .env # or use your preferred editorSet
MAGENTO_PATHto your Magento installation:MAGENTO_PATH=/Users/you/projects/magento2 # or MAGENTO_PATH=./magento2 # if Magento is in this folder
-
Start Docker services
npm run docker:up
This starts:
- Neo4j at http://localhost:7474 (user: neo4j, pass: magento-analyzer)
- PHP Parser container with nikic/php-parser
-
Verify setup
npm start -- init
# Show help
npm start -- --help
# Parse a Magento module
npm start -- parse Magento_Customer
# Show plugins for an interface
npm start -- plugins CustomerRepositoryInterface
# Show observers for an event
npm start -- observers customer_save_after
# Show module dependencies
npm start -- deps Magento_Customer
# Generate diagram
npm start -- diagram CustomerRepository::save --output ./diagrams# Start all services
npm run docker:up
# Stop all services
npm run docker:down
# View logs
cd docker && docker-compose logs -f
# Access Neo4j browser
npm run neo4j:browser
# Or manually: open http://localhost:7474# Install dependencies
npm install
# Run CLI in watch mode (auto-reload on changes)
npm run dev
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lintmagento-core/
βββ src/
β βββ cli/ # CLI entry point
β β βββ index.js # Command definitions
β βββ parsers/ # Magento configuration parsers
β β βββ xml/ # di.xml, events.xml, module.xml parsers
β β βββ php/ # PHP AST parser wrapper
β βββ graph/ # Graph database logic
β βββ commands/ # CLI command implementations
β βββ analyzers/ # Analysis algorithms
β βββ visualizers/ # Diagram generators
βββ tests/
β βββ fixtures/ # Test data
βββ docker/
β βββ docker-compose.yml # Docker services definition
βββ scripts/ # Helper scripts
β βββ setup.sh # Initial setup
β βββ docker-up.sh # Start services
β βββ docker-down.sh # Stop services
βββ data/ # Parsed graph data (JSON)
βββ diagrams/ # Generated diagrams
βββ annotations/ # Known issues YAML files
βββ schemas/ # JSON schemas
βββ package.json # Node.js dependencies
βββ .env.example # Environment template
βββ README.md # This file
| Variable | Default | Description |
|---|---|---|
MAGENTO_PATH |
./magento2 |
Path to Magento 2 installation |
NEO4J_URI |
bolt://localhost:7687 |
Neo4j connection URI |
NEO4J_USER |
neo4j |
Neo4j username |
NEO4J_PASSWORD |
magento-analyzer |
Neo4j password |
NEO4J_HEAP_SIZE |
2G |
Neo4j JVM heap size |
OUTPUT_DIR |
./data |
Parsed data output directory |
DIAGRAMS_DIR |
./diagrams |
Diagram output directory |
The docker-compose.yml includes:
- neo4j: Graph database for storing relationships
- php-parser: PHP AST parser using nikic/php-parser
- portainer (optional): Docker management UI
To start only specific services:
cd docker
docker-compose up -d neo4j # Only Neo4jThe tool parses Magento XML configuration files:
<!-- di.xml -->
<preference for="CustomerRepositoryInterface" type="CustomerRepository" />
<plugin name="validate_customer" type="ValidationPlugin" sortOrder="10" />
<!-- events.xml -->
<event name="customer_save_after">
<observer name="notify_customer" instance="NotificationObserver" />
</event>Creates a graph representation:
Interface (CustomerRepositoryInterface)
β PREFERS
Class (CustomerRepository)
β INTERCEPTS (sortOrder: 10)
Plugin (ValidationPlugin)
Answers questions like:
- What plugins affect this method?
- What observers listen to this event?
- What modules does this depend on?
Generates diagrams:
graph LR
A[CustomerRepository::save] -->|before| B[ValidationPlugin]
B --> C[Original Method]
C -->|after| D[CachePlugin]
Week 1-2: XML Parsing
- Parse di.xml, events.xml, module.xml for Magento_Customer
- Build in-memory graph
Week 3: CLI & Queries
- Implement 3 core queries (plugins, observers, deps)
- Generate Mermaid diagrams
Week 4: Validation
- QA against known Magento structure
- GO/NO-GO decision for Phase 2
Success Criteria:
- Parse Magento_Customer in <5 minutes
- All 3 queries return correct results
- At least 1 diagram generated
# Check Docker is running
docker ps
# Check logs
cd docker && docker-compose logs
# Restart services
npm run docker:down
npm run docker:up# Wait for Neo4j to be ready (can take 30 seconds)
docker-compose logs neo4j
# Test connection
curl http://localhost:7474
# Access browser manually
open http://localhost:7474# Verify path in .env
cat .env | grep MAGENTO_PATH
# Test path exists
ls $MAGENTO_PATH/vendor/magento/module-customer# Make scripts executable
chmod +x scripts/*.sh- magento-mapping-tool-project-plan.txt: Complete 5-phase project plan
- Neo4j Browser: http://localhost:7474 (when running)
Once Phase 3 is complete, contributions will be via:
- GitHub PRs for code
- YAML annotations for known issues
- JSON schema validation for quality
MIT License - See LICENSE file for details
- PHPStan Magento Extensions: Static analysis
- bin/magento dev:di:info: Single class DI info
- Magerun2: CLI utilities
- Magento DevDocs: Official documentation
Differentiation: This tool provides visual relationship mapping, known gotcha detection, and interactive exploration that existing tools don't offer.
- Phase 0: Planning & Architecture (Complete)
- Phase 1: POC - Magento_Customer (4 weeks) β Current
- Phase 2: Scale to Full Core + Neo4j (6 weeks)
- Phase 3: Known Issues Annotation System (3 weeks)
- Phase 4: Interactive Visualization UI (5 weeks)
- Phase 5: Launch & Hardening (3 weeks)
Questions? See the project plan for comprehensive roadmap.