Quickstart
Using Mapper consists of four steps: define the schema, register it with a processor, add the frontend, and let the user map and import.
Step 1: Define your target schema
Section titled “Step 1: Define your target schema”Create a YAML schema:
version: 1
model: name: subscriber
fields: - name: msisdn type: string required: true
- name: status type: string required: trueSupported types: string, integer, decimal, boolean, datetime.
Names must match ^[a-z][a-z0-9_]*$.
Generate the backend model and TypeScript schema. With generators
configured in the YAML (see Schema compiler):
mapper-gen generate \ --input schema/subscriber.yaml \ --lock schema/subscriber.lock.yamlMapper creates:
subscriber.gen.gosubscriber.lock.yamlThe lock file preserves stable schema and field identities — commit it.
Step 2: Register the schema and processor
Section titled “Step 2: Register the schema and processor”In the backend:
processor := mapper.ImportProcessorFunc( func(ctx context.Context, info mapper.RowContext, record mapper.Record) error { return repository.Save(ctx, record) },)
svc := mapper.New( mapper.WithFileStore(store), mapper.WithSourceAdapter(csv.New()), mapper.WithImporter(executor.New( executor.WithImportProcessor(processor), )),)
_ = svc.RegisterSchema(generated.SubscriberSchema)Expose the HTTP adapter:
handler := mapperhttp.New(svc)
mux.Handle( "/mapper/", http.StripPrefix("/mapper", handler),)The backend now provides the core Mapper APIs:
GET /schemas/{id}POST /files/analyzePOST /imports/syncStep 3: Add the Frontend SDK
Section titled “Step 3: Add the Frontend SDK”Create the API client:
const mapper = createMapperClient({ baseUrl: "/mapper"});Then render the importer:
<MapperImporter client={mapper} schemaId={SUBSCRIBER_SCHEMA_ID}/>The component handles:
schema loadingfile analysismapping UImapping validationimport submissionresult stateFor more control, applications can use the lower-level MappingEditor or the headless API client directly.
Step 4: Let the user map and import
Section titled “Step 4: Let the user map and import”The final user flow is:
Select file ↓Analyze source ↓View columns ↓Connect source fields to target fields ↓Validate mapping ↓Import ↓Application ImportProcessorFor example:
PhoneNumber ──────> msisdnState ──────> statusOnce submitted, Mapper executes the mapping deterministically for every row.
End-to-End Flow
Section titled “End-to-End Flow” BUILD TIME
schema.yaml │ ▼ Mapper Compiler │ ┌─────────┴─────────┐ ▼ ▼ Backend Model Runtime Schema
RUNTIME
User │ │ upload file ▼Frontend SDK │ │ analyze ▼Backend SDK │ ├── read source headers └── return SourceAnalysis │ ▼Frontend SDK │ ├── load TargetSchema └── render Mapping Editor │ ▼User │ │ connect source → target ▼MappingSpec │ │ POST /imports ▼Backend SDK │ ├── validate mapping ├── compile execution plan ├── stream source rows ├── convert values └── create typed Records │ ▼ImportProcessor │ ▼Your Application