Nov 23, 20268 min read

Sanctions Screening Backend: Name Matching Against OFAC Lists

How fintech backends screen customers and payment parties against sanctions lists: loading list data, fuzzy name matching that survives transliteration, scoring with date of birth and country, a human review queue and daily rescreening, with a Go example on Encore.

Illustration for Sanctions Screening Backend: Name Matching Against OFAC Lists

Every fintech that moves money has to screen customers and payment parties against sanctions lists. The lists are public, but matching is hard: names arrive in different scripts, spellings and orders, and screening either misses real hits or buries compliance in false positives.

This guide explains how screening works end to end, from list data to the review queue, and builds the backend in Go on Postgres.

Which lists do you screen against?

Most US-connected businesses start with OFAC's Specially Designated Nationals (SDN) list and the consolidated non-SDN lists, published through the OFAC Sanctions List Service in CSV and XML formats. Businesses in the UK and EU add the UK consolidated list and the EU financial sanctions list, and the FATF Recommendations set the international baseline for targeted financial sanctions that these regimes implement. Which lists apply to you is a legal question for your compliance team, and the backend should treat lists as data, each with its own source and refresh time.

Load every name variant, primary names and aliases alike, as its own row linked to the list entry, with whatever identifiers the list provides: date or year of birth, nationality, addresses and passport numbers.

How do you match names that are spelled differently?

Normalize first: lowercase, strip accents and punctuation. Then compare with a fuzzy measure that does not care about word order, since "Müller, Hans Jürgen" and "Hans Jurgen Muller" are the same person. Trigram similarity from Postgres's pg_trgm does this well. On our local Postgres 17 test data, "Hans Jurgen Muller" scored 1.0 against "Müller, Hans Jürgen" after removing accents with unaccent, and the transliterated "Hans Juergen Mueller" still scored 0.6, comfortably above a 0.4 threshold.

Transliteration from Cyrillic, Arabic or Chinese is the harder case, since one name can have several Latin spellings. Lists help by including common aliases, and dedicated screening engines add phonetic and transliteration models on top, which is a reason to keep the matching step behind a clean interface you can swap later.

How do you cut false positives?

Fuzzy name matches alone flag every namesake. Score potential matches with the secondary data: a birth year that differs by more than a year or two lowers the score sharply, a matching nationality raises it, and an entry type mismatch (a vessel against a person) rules it out. Keep the threshold and weights in configuration your compliance team owns, and log the score breakdown on each hit so an analyst can see why it fired.

What does the review workflow need?

Every hit above the threshold becomes a pending alert. An analyst reviews it and records a decision, cleared as a false positive or confirmed, with who decided, when and why. Cleared hits for the same party and list entry should not reappear on the next rescreen unless the entry changes. Confirmed hits block the customer or payment and feed whatever reporting your compliance program requires. All of this belongs in an append-friendly audit trail, since regulators ask how a decision was made long after it happened.

How does rescreening work?

Lists change several times a week. After each list refresh, every existing party has to be screened again against the new data, which is a batch job over your whole customer base. Splitting it into one queue message per party keeps it restartable and lets it run in parallel without overloading the database.

Sanctions screening with Encore

Encore

Encore is a backend framework with built-in infrastructure, and the list data, hits, rescreen queue and schedule are all declared in the Go screening service. An Encore Postgres database holds list entries and hits with pg_trgm and unaccent enabled, a Pub/Sub topic fans the daily rescreen out to one message per party, and an Encore cron job, managed by the Encore platform, starts it after the list refresh. Customer names never leave your own AWS or GCP account, where Encore provisions the database and queue. Pave Bank uses Encore to maintain full control of their own secure cloud environment in GCP, and Echo built with the Encore platform as their development platform from day one, deploying to their own cloud on AWS.

Set up the app

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

-- screening/migrations/1_create_screening.up.sql CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS unaccent; CREATE TABLE sanctions_entries ( id BIGSERIAL PRIMARY KEY, list TEXT NOT NULL, list_ref TEXT NOT NULL, name TEXT NOT NULL, name_norm TEXT NOT NULL, birth_year INT, country TEXT, UNIQUE (list, list_ref, name) ); CREATE INDEX sanctions_name_trgm ON sanctions_entries USING gin (name_norm gin_trgm_ops); CREATE TABLE parties ( id TEXT PRIMARY KEY, name TEXT NOT NULL, birth_year INT, country TEXT, last_screened_at TIMESTAMPTZ ); CREATE TABLE screening_hits ( party_id TEXT NOT NULL REFERENCES parties (id), entry_id BIGINT NOT NULL REFERENCES sanctions_entries (id), score REAL NOT NULL, status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'cleared', 'confirmed')), decided_by TEXT, reason TEXT, decided_at TIMESTAMPTZ, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), PRIMARY KEY (party_id, entry_id) );
// screening/screening.go package screening import ( "context" "encore.dev/beta/errs" "encore.dev/cron" "encore.dev/pubsub" "encore.dev/rlog" "encore.dev/storage/sqldb" ) var db = sqldb.NewDatabase("screening", sqldb.DatabaseConfig{Migrations: "./migrations"}) const alertThreshold = 0.5 type ScreenParams struct { PartyID string Name string BirthYear *int Country *string } type ScreenResult struct { Decision string // "clear" or "review" Hits int } //encore:api private method=POST path=/screen func Screen(ctx context.Context, p *ScreenParams) (*ScreenResult, error) { if _, err := db.Exec(ctx, ` INSERT INTO parties (id, name, birth_year, country) VALUES ($1, $2, $3, $4) ON CONFLICT (id) DO UPDATE SET name = $2, birth_year = $3, country = $4`, p.PartyID, p.Name, p.BirthYear, p.Country); err != nil { return nil, err } return screenParty(ctx, p.PartyID) } func screenParty(ctx context.Context, partyID string) (*ScreenResult, error) { tx, err := db.Begin(ctx) if err != nil { return nil, err } defer tx.Rollback() if _, err := tx.Exec(ctx, `SET LOCAL pg_trgm.similarity_threshold = 0.4`); err != nil { return nil, err } // Undecided hits are rebuilt on every run, so a party that no longer matches drops them. if _, err := tx.Exec(ctx, `DELETE FROM screening_hits WHERE party_id = $1 AND status = 'pending'`, partyID); err != nil { return nil, err } // Name similarity, adjusted by birth year and country when both sides have them. res, err := tx.Exec(ctx, ` INSERT INTO screening_hits (party_id, entry_id, score) SELECT p.id, e.id, scored.score FROM parties p JOIN sanctions_entries e ON e.name_norm % lower(unaccent(p.name)) CROSS JOIN LATERAL (SELECT similarity(e.name_norm, lower(unaccent(p.name))) - CASE WHEN p.birth_year IS NOT NULL AND e.birth_year IS NOT NULL AND abs(p.birth_year - e.birth_year) > 1 THEN 0.3 ELSE 0 END + CASE WHEN p.country IS NOT NULL AND p.country = e.country THEN 0.1 ELSE 0 END AS score) scored WHERE p.id = $1 AND scored.score >= $2 ON CONFLICT (party_id, entry_id) DO NOTHING`, partyID, alertThreshold) if err != nil { return nil, err } if _, err := tx.Exec(ctx, `UPDATE parties SET last_screened_at = now() WHERE id = $1`, partyID); err != nil { return nil, err } var pending int if err := tx.QueryRow(ctx, `SELECT count(*) FROM screening_hits WHERE party_id = $1 AND status IN ('pending', 'confirmed')`, partyID).Scan(&pending); err != nil { return nil, err } if err := tx.Commit(); err != nil { return nil, err } if res.RowsAffected() > 0 { rlog.Info("new sanctions screening hits", "party_id", partyID, "hits", res.RowsAffected()) } decision := "clear" if pending > 0 { decision = "review" } return &ScreenResult{Decision: decision, Hits: pending}, nil } type DecideParams struct { PartyID string EntryID int64 Status string // "cleared" or "confirmed" DecidedBy string Reason string } //encore:api private method=POST path=/hits/decide func Decide(ctx context.Context, p *DecideParams) error { if p.Status != "cleared" && p.Status != "confirmed" { return &errs.Error{Code: errs.InvalidArgument, Message: "status must be cleared or confirmed"} } _, err := db.Exec(ctx, ` UPDATE screening_hits SET status = $3, decided_by = $4, reason = $5, decided_at = now() WHERE party_id = $1 AND entry_id = $2 AND status = 'pending'`, p.PartyID, p.EntryID, p.Status, p.DecidedBy, p.Reason) return err } type RescreenJob struct { PartyID string } var Rescreens = pubsub.NewTopic[*RescreenJob]("rescreen-jobs", pubsub.TopicConfig{ DeliveryGuarantee: pubsub.AtLeastOnce, }) var _ = pubsub.NewSubscription(Rescreens, "rescreen-party", pubsub.SubscriptionConfig[*RescreenJob]{ Handler: func(ctx context.Context, j *RescreenJob) error { _, err := screenParty(ctx, j.PartyID) return err }, MaxConcurrency: 8, }) var _ = cron.NewJob("rescreen-all", cron.JobConfig{ Title: "Rescreen all parties after the nightly list refresh", Schedule: "30 5 * * *", Endpoint: QueueRescreen, }) type QueueRescreenResult struct { Queued int } //encore:api private func QueueRescreen(ctx context.Context) (*QueueRescreenResult, error) { rows, err := db.Query(ctx, `SELECT id FROM parties WHERE last_screened_at IS NULL OR last_screened_at < now() - interval '20 hours'`) if err != nil { return nil, err } defer rows.Close() out := &QueueRescreenResult{} for rows.Next() { var id string if err := rows.Scan(&id); err != nil { return nil, err } if _, err := Rescreens.Publish(ctx, &RescreenJob{PartyID: id}); err != nil { return nil, err } out.Queued++ } return out, rows.Err() }

The list loader, which downloads the OFAC files and upserts entries with name_norm = lower(unaccent(name)), is left out for space and fits a second cron job scheduled before 05:30 UTC. Pending hits are rebuilt on each run, while ON CONFLICT DO NOTHING means a cleared alert stays cleared on later rescreens, and a changed list entry with a new name creates a new row and a new alert. The threshold and weights are constants here so the example stays readable, and in production they belong in configuration your compliance team reviews.

The cron jobs do not run locally or in preview environments, so test the batch path by calling QueueRescreen from the local development dashboard, and watch each party's screening query and score in the local trace. encore run starts Postgres with both extensions, which means you can seed a few list entries and check that "Hans Jurgen Muller" produces a pending hit before any change ships.

Matching rules change often and every change has compliance impact, so it helps that an agent proposing a new weight edits one query and can rerun the same seeded test cases locally to show which hits appear or disappear.

Best fit: Fintech teams that screen customers and counterparties in-house and want list data, alerts and decisions kept in their own Postgres database and cloud account.

Frequently asked questions

How does sanctions screening work in a fintech backend?

Names of customers and payment counterparties are compared against sanctions lists such as the OFAC SDN list. Exact and fuzzy matches above a threshold become alerts that a compliance analyst reviews, and the customer base is rescreened whenever the lists change.

Why do sanctions screening systems use fuzzy matching?

The same person appears with different spellings, transliterations, word orders and accents across documents and lists, so exact matching misses real hits. Fuzzy matching on normalized names finds them, and secondary data such as date of birth and nationality separates true matches from namesakes.

How often should customers be rescreened against sanctions lists?

Whenever a list you screen against changes, which for OFAC can be several times a week, plus at onboarding and before payments to new counterparties. A daily job that rescreens every party after the latest list load is a common baseline.

How do I build sanctions screening with Encore?

Store list entries and screening hits in an Encore Postgres database with pg_trgm and unaccent enabled, screen parties from an endpoint, and use an Encore cron job plus Pub/Sub to rescreen every party after each list refresh. Analysts clear or confirm hits through a review endpoint.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders