mongo-erd-generator
v1.0.1
Published
Interactive CLI tool to generate Entity Relationship Diagrams (ERD) from MongoDB databases
Maintainers
Readme
🍃 Mongo ERD Generator
Instantly visualize your MongoDB schema relations with zero configuration.
Mongo ERD Generator is a CLI tool that reverse-engineers your MongoDB database to create beautiful, interactive Entity Relationship Diagrams (ERDs). It uses advanced schema analysis to deduce relationships between collections without requiring any manual schema definition.
✨ Features
- 🔮 Automatic Relationship Detection: Intelligent analysis of
ObjectIdreferences to infer relations. - 🖼️ Interactive Visualization: Powered by Mermaid.js and ELK layout engine for clean diagrams.
- 🚀 Zero Config: Just connect and go. No schema files needed.
- 🔍 Deep Inspection: Detects field types, embedded documents, and junction tables.
- 🌐 Web-Based Viewer: Zooms, pans, and exports to PNG directly from your browser.
- 🖥️ Cross-Platform: Works seamlessly on macOS, Windows, and Linux.
📦 Installation
Install globally via npm:
npm install -g mongo-erd-generator🚀 Usage
Simply run the command in your terminal:
mongo-erdInteractive Mode (Recommended)
- Enter your MongoDB connection string (default:
mongodb://localhost:27017) - Select the database you want to visualize from the list.
- The tool will generate the ERD and open it in your default browser.
Non-Interactive Options
You can also pass arguments directly for CI/CD or quick access:
mongo-erd --url "mongodb://localhost:27017" --db "my_database" --port 8080🛠️ How it Works
- Connects to your MongoDB instance using the provided credentials.
- Samples documents from each collection to infer schema structure and types.
- Indexes all
ObjectIdfields to cross-reference collections. - Deduces relationships (1:1, 1:Many, Many:Many) based on reference matching.
- Generates a Mermaid.js diagram and serves it locally.
🤝 Contributing
We love contributions! This is a passion project aimed at making MongoDB visualization accessible to everyone.
See CONTRIBUTING.md for how to get started.
📝 License
This project is licensed under the ISC License.
