AI-Powered Database Migration from PostgreSQL to MongoDB
Mongrate is an intelligent migration platform that automates the process of migrating applications from PostgreSQL to MongoDB. Using AI agents powered by Claude, it analyzes your codebase, creates migration plans, transforms your schema and queries, and even generates pull requests with the changes.
- 🤖 AI-Powered Analysis - Claude AI agents analyze your codebase and database schema
- 🔄 Automated Migration - Automatic code transformation from PostgreSQL to MongoDB
- 🎯 Smart Schema Mapping - Intelligent conversion of relational schemas to document models
- 🌿 Auto PR Creation - Generates pull requests with migrated code on a new branch
- 📊 Real-time Progress - Track migration status with live updates
- 💬 Interactive Chat - Communicate with AI agents during the migration process
- 🎨 Modern UI - Clean, accessible interface with dark mode support
- Node.js 18+ and npm/pnpm
- MongoDB Atlas account (or local MongoDB instance)
- GitHub account and personal access token (for repository cloning and PR creation)
- PostgreSQL database credentials (for source data migration)
- Clone the repository:
git clone https://github.com/AndresNinou/mongodb_hackathon.git
cd nextjs-template-mongodb- Install dependencies:
npm install
# or
pnpm install- Create a
.env.localfile in the project root:
cp .env.example .env.local- Add your MongoDB connection string to
.env.local:
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster-url>/<database>?retryWrites=true&w=majorityStart the development server:
npm run dev
# or
pnpm devOpen http://localhost:3000 to see the application.
Click "New Migration" and provide:
- Name: A descriptive name for your migration
- GitHub Repository URL: The repo containing your PostgreSQL application
- Branch (optional): Target branch (defaults to main)
- PostgreSQL URL: Connection string for your source database
- MongoDB URL: Connection string for your target database
- GitHub Token: Personal access token for cloning and PR creation
The AI agent will:
- Clone your repository
- Analyze the codebase structure
- Identify PostgreSQL queries and schema definitions
- Create a comprehensive migration plan
- Map relational tables to MongoDB collections
Once you approve the plan:
- Code is automatically transformed
- PostgreSQL queries are converted to MongoDB operations
- Schema is migrated to document model
- Data is transferred from PostgreSQL to MongoDB
- Changes are committed to a new branch
- Review the generated pull request
- Test the migrated code
- Merge when ready
The application is configured to work with tunneling services like ngrok:
// next.config.ts
allowedDevOrigins: ['*']This allows you to access your development server through ngrok or other tunneling services without CORS issues.
| Variable | Description | Required |
|---|---|---|
MONGODB_URI |
MongoDB connection string | ✅ Yes |
Per-migration configuration (provided through UI):
repoUrl: GitHub repository URLbranch: Target branch namepostgresUrl: PostgreSQL connection stringmongoUrl: MongoDB connection stringgithubToken: GitHub personal access token
nextjs-template-mongodb/
├── app/
│ ├── api/
│ │ └── migrations/ # Migration API endpoints
│ ├── page.tsx # Main application page
│ └── layout.tsx # Root layout
├── components/
│ ├── migration/ # Migration UI components
│ │ ├── MigrationCard.tsx
│ │ ├── MigrationDetail.tsx
│ │ ├── AgentChatPanel.tsx
│ │ └── CreateMigrationModal.tsx
│ ├── layout/ # Layout components
│ └── ui/ # Reusable UI components
├── lib/
│ ├── db/ # Database utilities
│ ├── services/ # Business logic
│ │ └── migration/
│ │ ├── orchestrator.ts # Migration orchestration
│ │ └── sessionManager.ts
│ └── agents/ # AI agent prompts
├── types/ # TypeScript type definitions
└── data/ # Migration data and cloned repos
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Database: MongoDB with MongoDB Node.js Driver
- AI: Claude AI (Anthropic API)
- Styling: Tailwind CSS with custom brutal/neo-brutalist design
- UI Components: Custom components + Lucide Icons
- Never commit
.env.localor expose sensitive credentials - Use environment variables for all secrets
- GitHub tokens should have minimal required permissions
- Consider using read-only database connections for analysis phase
Contributions are welcome! Please feel free to submit a Pull Request.
This project is part of the MongoDB Hackathon submission.
Built for the MongoDB Hackathon as a demonstration of AI-powered database migration capabilities.
Team: AndresNinou
Project: Mongrate - AI Database Migration Platform
Powered by Claude • MongoDB • Next.js
