How pmpetit/mongo2pg works
mongo2pg is a Rust CLI/library for assessing and migrating MongoDB data into PostgreSQL. The documented user workflow is init → infer → export → import, with reports for pre- and post-import validation; infer samples MongoDB, builds probabilistic schemas, and generates PostgreSQL DDL. Separate command branches provide Kafka import, connectivity checks, and cluster reports. The graph reflects README claims and indexed source relationships; several command implementations were not excerpted, so some runtime links remain unverified.
Main entry points: args.rs CLI dispatch · infer.rs Schema inference · ping.rs Connectivity check · pg.rs PostgreSQL access
Components 24
Migration workflow
- CLI dispatch
src/cli/args.rs - Project setup
src/commands/init.rs - Schema inference
src/commands/infer.rs - Config utilities
src/util.rs
Schema analysis
- Schema analyzer
src/engine/analyzer.rs - DDL generation
src/engine/ddl.rs - Collection stats
src/engine/stats.rs
Data transfer
- CSV export
src/commands/export.rs - Export engine
src/export.rs - Postgres import
src/commands/import.rs - MongoDB access
src/db/mongo.rs - PostgreSQL access
src/db/pg.rs - Kafka import
src/commands/kafka_import.rs - Kafka access
src/db/kafka.rs
Reporting and operations
- HTML reporting
src/report.rs - ER diagram
src/schema_diagram.rs - Report command
src/commands/report.rs - Connectivity check
src/commands/ping.rs - Cluster report
src/commands/cluster_report.rs - Data validation
src/engine/checksum.rs
Other components
- CLI user
- PostgreSQL
- MongoDB
- Kafka
Connections 29
- CLI user → CLI dispatch: runs commands
README.md - CLI dispatch → Project setup: dispatches
- CLI dispatch → Schema inference: dispatches
- CLI dispatch → CSV export: dispatches
- CLI dispatch → Postgres import: dispatches
- CLI dispatch → Kafka import: dispatches
- CLI dispatch → Report command: dispatches
- CLI dispatch → Connectivity check: dispatches
- CLI dispatch → Cluster report: dispatches
- Project setup → Config utilities: creates configuration
- Schema inference → MongoDB: samples collections
README.md - Schema inference → Schema analyzer: processes documents
src/commands/infer.rs - Schema inference → DDL generation: generates DDL
src/commands/infer.rs - Schema inference → Collection stats: computes statistics
src/commands/infer.rs - Schema inference → HTML reporting: refreshes reports
src/commands/infer.rs - Schema inference → ER diagram: creates diagram
src/commands/infer.rs - CSV export → Export engine: streams collections
src/commands/export.rs - Export engine → MongoDB: reads documents
src/export.rs - Postgres import → PostgreSQL access: loads exported data
README.md - PostgreSQL access → PostgreSQL: connects to
src/db/pg.rs - Kafka import → Kafka access: uses connector
src/commands/kafka_import.rs - Kafka access → Kafka: connects to
- Connectivity check → MongoDB: checks connection
- Connectivity check → PostgreSQL access: checks connection
src/commands/ping.rs - Connectivity check → Kafka access: checks connection
src/commands/ping.rs - Report command → HTML reporting: renders reports
src/commands/report.rs - Report command → ER diagram: renders diagram
src/commands/report.rs - Cluster report → HTML reporting: builds overview
src/commands/cluster_report.rs - Data validation → PostgreSQL access: compares target rows
src/engine/checksum.rs