AI-powered TUI tool for MongoDB schema diffing and migration script generation.
Built with Java 17 + JLine 3 + Anthropic Claude SDK.
- Schema Diff — Compare two MongoDB document schemas (JSON files or pasted JSON)
- Smart Detection — Identifies added, removed, renamed fields, type changes, and structural changes
- AI Script Generation — Uses Claude API to generate production-ready
mongoshmigration scripts - Fallback Mode — Generates template scripts even without an API key
- Type Inference — Detects strings that should be Dates, Decimals, ObjectIds, Integers
- Rollback Scripts — Every migration includes a reverse/rollback section
- Sample Data — Built-in insurance domain sample for quick demo
- Java 17+
- Maven 3.8+
- (Optional) Anthropic API key for AI-powered script generation
# Clone / navigate to project
cd MongoSchemaMigrationAssistant
# Build
mvn clean package -q
# Set API key (optional, enables AI mode)
export ANTHROPIC_API_KEY=sk-ant-api03-...
# Run
java -jar target/mongo-migration-assistant-0.1.0-SNAPSHOT.jar
# Or run via Maven
mvn exec:java -qPrepare two JSON files representing your MongoDB documents:
source.json (current schema):
{
"name": "John Doe",
"premium": "1250.50",
"createdAt": "2024-01-15T00:00:00Z"
}target.json (desired schema):
{
"fullName": "John Doe",
"premium": 1250.50,
"createdAt": "2024-01-15T00:00:00Z",
"updatedAt": ""
}Launch the app, select option 1, enter file paths, and run the diff.
Select "Paste JSON" to enter schemas directly in the TUI.
Select "Use Sample" to see a full insurance domain migration example.
dev.mongomigrate/
├── App.java # Entry point
├── tui/
│ └── TuiManager.java # JLine TUI screens & navigation
├── core/
│ ├── SchemaDiffer.java # Schema comparison engine
│ ├── DiffEntry.java # Single diff item model
│ └── DiffResult.java # Complete diff result
├── ai/
│ └── ClaudeService.java # Anthropic SDK integration
└── model/
└── MigrationContext.java # Shared state between screens
- Direct MongoDB connection for live schema introspection
- Batch processing with progress bars for large collections
- Dry-run mode (apply to N sample docs and show results)
- Config file support (~/.mongomigrate.yaml)
- Export diff as HTML report
- Multi-collection migration workflows
- Index diff and migration
- Integration with mongosh for direct execution
MIT