Profile the source boundary
Inspect schemas, row counts, nulls, duplicates, delimiters, and volume to establish a data-quality baseline before migration logic changes the data.
Project case study · Python · Salesforce
This project builds a reusable migration layer, currently connecting SAP Commerce (Hybris) CSV exports to Salesforce. It uses CSV as a simple data boundary, with client-specific mappings and rules kept configurable. Salesforce Bulk API 2.0 is the current destination connector; other platforms can be supported by adding destination-specific CSV mappings and a connector for their API.
The pipeline is deliberately staged. Every boundary has a defined input, output, validation point, and operational responsibility, making the migration easier to test, restart, audit, and scale than a single all-in-one script.
SAP Commerce CSV exports are profiled for schema, row counts, nulls, duplicates, delimiters, and volume before transformation begins.
Run identity, optional root batching, relationship resolution, and scoped working data establish a deterministic input for later stages.
Configured mappings, normalization, type conversion, filters, and business rules produce destination-shaped CSV files.
The current Salesforce Bulk API 2.0 connector retains job and row results; recovery, rollback, and reconciliation provide separate operational controls.
Client-specific source structures, field mappings, relationship rules, and migration behavior are configured around a shared pipeline, reducing the need to rebuild the workflow for each dataset.
CSV is the exchange contract between source preparation, transformation, and loading. Salesforce is the implemented destination for this use case; supporting another platform means adding its target mappings and an API connector that consumes the resulting CSVs.
The HLD shows two ways to prepare a run, followed by one shared path through validation, relationship resolution, transformation, Salesforce loading, reconciliation, and the target system. The batch and single-run examples show file types and processing rules without dataset volumes.
The root-batch planner and the direct run script produce different input layouts, then converge at registry validation. The profiling and source-dictionary notebooks support preparation and analysis.
Relationship resolution keeps the Customer default address and expands address rows when the Billing and Shipping flags are true. Transformations produce Salesforce-shaped Account, User, ContactPointAddress, and Order files.
A local Salesforce loader profile configures Bulk API 2.0 jobs. The rollback utility separates analysis from execution so recovery can be reviewed before it is applied.
The configured flow and reconciliation reports use run-scoped files and may perform read-only SOQL checks against Salesforce. Outputs are kept under the run’s reports directory.
Each stage makes its inputs and outputs explicit, so the next stage receives a defined contract rather than discovering files or inferring run state on its own.
Inspect schemas, row counts, nulls, duplicates, delimiters, and volume to establish a data-quality baseline before migration logic changes the data.
A direct run creates a unique migration_run_id and canonical run root. The same identity scopes raw data, intermediate stages, load evidence, reports, and Salesforce records through MigrationRunId__c.
The root-batch planner validates the relationship graph, partitions Customer-rooted data into restartable relational batches, and creates independent roots for standalone file graphs.
Relationship resolution reconstructs foreign-key-like links across flat files, scopes child data, and records missing, orphaned, or ambiguous relationships in audit evidence.
Resolved files and required raw files are assembled under transform_input/, giving transformation a stable contract instead of ad hoc input discovery.
Transformation normalizes fields, converts types, applies configured filters and business rules, and writes Salesforce-ready object files under transform_output/.
The loader validates the registry, file plan, dependencies, mode, and run identity before authentication or job creation. It streams files, chunks large inputs, polls asynchronous jobs, and downloads result evidence.
Read-only reports compare local and optional Salesforce-side evidence. Complete, partial, and inconclusive results remain distinct; an inconclusive required check blocks sign-off.
Object registries, relationship graphs, source-file maps, loader metadata, mappings, and reconciliation rules define behavior outside the orchestration code.
PowerShell wrappers coordinate run-root-scoped Python entry points and expose operational parameters without hiding the stage sequence.
Python modules implement profiling, batching, relationship resolution, transformation, loader planning, result processing, reporting, and rollback.
Canonical folders and JSON/CSV artifacts retain stage outputs, recovery state, result files, metrics, and report evidence for later analysis.
Every run keeps its inputs, intermediate data, load evidence, recovery
state, and reports under one canonical root:
data/runs/<env>/<load-mode>/<migration-run-id>/
| Run folder | Purpose and retained evidence |
|---|---|
raw/ | Original source CSVs for a direct run or each prepared batch. |
working/ | Relationship-resolved, run-scoped working data and resolution evidence. |
transform_input/ | Deterministic inputs assembled for the transformation stage. |
transform_output/ | Salesforce-shaped object files produced by configured transformations. |
bulk2/ | Loader summary, job state, row results, and recovery manifests and chunks. |
reports/ | overall_flow_report.* and reconciliation_report.* outputs for the same migration run. |
All downstream stages and evidence use the same run root and migration_run_id.
Planner-created roots are not reinitialized, and loader evidence stays inside its run root.
Stage artifacts remain available for later analysis; reports are read-only and do not delete records.
Local profiles and private keys remain outside source control.
Missing or unexpected files, invalid mappings, unknown object keys, invalid registry configuration, and missing delta External IDs fail before authentication or job creation.
Durable recovery manifests and chunks support resume without discarding the original run. Accepted, failed, and unprocessed results remain available for analysis.
Rollback is a separate, explicit Bulk API delete workflow. It is not an implicit side effect of recovery or reconciliation.
An inconclusive required reconciliation check produces a failed, non-sign-off-eligible result. The system surfaces the evidence gap instead of masking it.
The framework starts from SAP Commerce CSV exports. It does not connect to SAP or extract data from a live source system.
Local checks and optional Salesforce SOQL checks inspect outcomes; they do not modify Salesforce records.
The framework turns a high-risk migration into a controlled sequence of contracts. It is configuration-driven, dependency-aware, conscious of large-file processing, recoverable, and auditable. The outcome is not simply that records can be loaded; it is that the load can be explained, resumed, challenged, and signed off using durable evidence.