- type
- entity
- created
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- updated
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- sources
- raw/articles/CHANGELOG, raw/articles/DISCOVERIES, raw/notes/activeContext
- tags
- entity data-migration legacy morichal import
MorichalAI
Overview
MorichalAI is Rafael's (co-founder) previous system for managing paper trading data. It contained years of accumulated business relationships, product specifications, buyer preferences, and transaction history. This data was migrated to bootstrap the marketplace with real-world records rather than synthetic test data.
Migration Architecture
Source
- Database: PostgreSQL, restored from
downloaded_db.sqlinto a database namedmorichal_source - Access: Read-only (the marketplace only reads from this source, never writes)
- Connection: psycopg 3.3.3 (notably not psycopg2) for direct DB access
Import Service
Located at backend/common/services/morichal_import/ with 11 modules handling different entity types and their relationships. The import is orchestrated by a management command.
Management Command
python manage.py import_morichal [options]
| Flag | Purpose |
|---|---|
--dry-run |
Preview import without writing to database |
--phases |
Selective import (e.g., --phases mills,buyers) |
--clear-existing |
Delete existing imported records before re-importing |
--report-file |
Save import report to a file |
Import Results
| Entity | Count | Notes |
|---|---|---|
| Mills | 111 | Company details, capabilities, regions |
| Buyers | 162 | Company type, country, preferences |
| Products | 486 | Full specifications (paper type, GSM, width, etc.) |
| Buyer Specs | 170 | Paper type ranges, GSM ranges, width ranges |
| Freight Rates | 12 | Common trade routes with LCL/FCL pricing |
| Transactions | 773 | Historical deal records |
| Total | 1,714 |
Data Quality and Provenance
- All imported records are tagged with
[Imported from MorichalAI ...]in their notes field, providing clear provenance tracking - Legacy paper types were mapped to the marketplace's PaperType enum values
- Freight rates were stored as FreightRate records linked to origin/destination regions
- Transaction history is preserved so that
derive_specsandderive_productscommands can infer BuyerSpecs and Products from historical patterns
Idempotency
The import uses get_or_create patterns throughout, making it safe to re-run. Running the command a second time creates zero new records -- all existing records are matched and skipped.
Test Coverage
119 tests cover the migration:
- 95 unit tests for individual entity importers
- 16 integration tests for cross-entity relationships
- 8 command tests for the management command interface
Significance
The MorichalAI migration is important because:
- Real data: The marketplace launched with actual business relationships, not fake data
- Validation: The 773 historical transactions validate that the data model supports real-world paper trading scenarios
- Bootstrap: The
derive_specsandderive_productscommands use transaction history to auto-generate BuyerSpecs and Products, bootstrapping the matching algorithm - Credibility: When Thierry demos the platform to mills, the buyer list is real and recognizable
Sources
- raw/articles/CHANGELOG -- migration completion entry (2026-02-26)
- raw/articles/DISCOVERIES -- migration architecture details
- raw/notes/activeContext -- import results summary
Related
- wiki/concepts/database-credentials-and-roles -- the morichal_source database
- wiki/summaries/changelog-summary -- when the migration was completed
- wiki/summaries/discoveries-summary -- technical decisions around the import
- wiki/concepts/phases-0-to-13-recap -- where the migration fits in the build timeline
- wiki/concepts/seed-accounts -- demo data populated by this migration
- wiki/entities/b2bpaper -- the platform that received this data