🎯 n8n Singleton Migration Workflow
A powerful n8n workflow for analyzing JavaScript/Vue codebases and identifying singleton pattern migration opportunities.
🚀 Quick Start
1. Start n8n
npx n8n2. Import Workflow
- Open http://localhost:5678
- Click Workflows → Import from File
- Select
singleton-migration-research-workflow.json
3. Execute
Click "Execute Workflow" and view results!
✨ Features
- 🔍 Automatic Detection - Finds singleton pattern candidates in your codebase
- 📊 Priority Classification - Categorizes files by migration priority (High/Medium/Low)
- 📋 Action Plan - Generates detailed conversion recommendations
- 🎯 Smart Analysis - Detects existing singleton patterns and suggests optimizations
- 🔧 Customizable - Easy to adapt for your project structure
- ⚡ Fast - Analyzes projects in seconds
- 📦 No Dependencies - Works out of the box with n8n
📊 What It Does
Node 1: Analyze Project Structure
Scans your project directory and counts files by type (JS, Vue, MJS)
Node 2: Identify Singleton Candidates
Analyzes JavaScript files for singleton patterns and classifies by priority
Node 3: Generate Conversion Plan
Creates a prioritized migration plan with specific recommendations
🎯 Use Cases
- Initial Assessment - Understand your codebase's singleton usage
- Migration Planning - Create a roadmap for pattern adoption
- Code Review - Guide architecture discussions
- Progress Tracking - Monitor refactoring progress
- CI/CD Integration - Automate as part of your pipeline
📁 Files
| File | Description |
|---|---|
singleton-migration-research-workflow.json |
Main n8n workflow (import this) |
START_HERE.md |
Quick start guide |
QUICK_START_GUIDE.md |
Detailed step-by-step instructions |
README_SINGLETON_WORKFLOW.md |
Complete documentation |
WORKFLOW_DIAGRAM.md |
Visual flow diagrams |
START_N8N.md |
n8n startup instructions |
🔧 Customization
Edit Node 1 to change your project path:
const PROJECT_PATH = '/path/to/your/project';📖 Documentation
- START_HERE.md - Begin here for quickest start
- QUICK_START_GUIDE.md - Step-by-step instructions
- README_SINGLETON_WORKFLOW.md - Full documentation
- WORKFLOW_DIAGRAM.md - Visual guides
🎨 Workflow Structure
Manual Trigger
↓
Analyze Project Structure
↓
Identify Singleton Candidates
↓
Generate Conversion Plan
↓
Results (High/Medium/Low Priority)
📋 Example Output
{
"conversionPlan": {
"highPriority": [
{
"file": "src/controllers/UserController.js",
"recommendation": "Convert to singleton pattern - core application component"
}
],
"summary": {
"totalCandidates": 3,
"highPriority": 1,
"mediumPriority": 1,
"lowPriority": 1
},
"recommendations": [
"Focus on 1 high-priority candidates first",
"Review 1 medium-priority candidates",
"Run analysis after each refactor"
]
}
}🛠️ Requirements
- n8n (any version with Code node support)
- Node.js (for running n8n)
- A JavaScript/Vue project to analyze
💡 Pro Tips
- Start with mock data to test the workflow
- Customize priority logic in Node 2 for your needs
- Add HTTP Request nodes to fetch real repository data
- Connect to GitHub API for live analysis
- Add notifications (email/Slack) for automated reports
- Schedule automatic runs to track progress
🐛 Troubleshooting
"Cannot find module 'fs'"
✅ Fixed - This workflow uses n8n-compatible code without fs module
"Code doesn't return items properly"
✅ Fixed - Returns data in correct n8n format
Port 5678 in use
lsof -i :5678
kill -9 <PID>🤝 Contributing
Contributions are welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
- Improve documentation
📄 License
MIT License - feel free to use this workflow in your projects!
🙏 Acknowledgments
- Built for the n8n automation platform
- Inspired by software architecture best practices
- Created to help teams adopt design patterns systematically
📞 Support
- Issues: Open an issue on GitHub
- Documentation: Check the docs folder
- n8n Community: community.n8n.io
🌟 Star This Repo!
If you find this workflow helpful, please give it a star ⭐
Made with ❤️ for the n8n community
Created: December 1, 2025