Automatic Underwriting Tool
automatic-uw-tool automates the identity-verification and background-check steps of Payability’s supplier underwriting (KYC / KYB). It orchestrates external data vendors behind a uniform process abstraction, runs the slow vendor calls asynchronously on AWS Simple Workflow (SWF), persists results to DynamoDB and S3, and notifies the rest of the platform through EventBridge.
|
The golden rule: the Web API never calls a vendor API directly. It authenticates the caller, validates input, persists state, and starts an SWF workflow. All external verification I/O happens in handle tasks on the worker. This keeps HTTP requests fast and makes vendor latency and vendor failures a background concern. |
What it does
Given a supplier and a person (a supplier owner), the tool runs one of four underwriting processes:
| Process | Vendor | Purpose |
|---|---|---|
|
Au10tix / Entrust |
Verify that a government ID is authentic, unexpired, good quality, and matches the owner on record. |
|
Thomson Reuters CLEAR (EIDV) |
KYC — confirm the owner’s submitted PII matches vendor records, field by field. |
|
Thomson Reuters CLEAR |
Criminal / bankruptcy / lien / lawsuit report, scored into |
|
Thomson Reuters CLEAR |
Business-entity background report, archived as raw data. |
Every process is a two-step pipeline: a synchronous request step served by the Web API, and an asynchronous handle step run by the SWF worker. The Entrust identity-verification flow is the one deliberate exception — its request step is a dedicated endpoint and its handle step is triggered by a vendor webhook. See Domain model: processes & tasks and Process catalog.
The 30-second model
-
Two containers, one repository. The Web API (
web_api_app.py) and the SWF worker (swf_app.py) are built from the same code and deployed as separate ECS services. -
Four layers.
interface/(HTTP) →task/(domain) →components/(integrations) →config/+utils/(cross-cutting). -
One join key. A
correlation_idties the request step, the SWF payload, every persisted row, the S3 object, and the outbound events for a single execution. -
Config is Dynaconf.
settings_setup.pygenerates non-secret settings,config_setup.pypulls secrets from AWS Secrets Manager; app code only readsconfig.config.settings.
x-session-token
Client ─────────────────────────► Web API (FastAPI, ECS)
│ 1. persist task (DynamoDB)
│ 2. set tool PENDING
│ 3. start workflow ──► B2B Task Manager ──► AWS SWF
▼
{correlation_id}
AWS SWF ──poll activity task──► SWF Worker (swf_app.py, ECS)
│ call Au10tix / Entrust / Thomson Reuters
│ write raw result to S3
│ update final-status + tool tables
▼
EventBridge (process finished, TR match / mismatch)
Where to read next
| If you want… | Read |
|---|---|
The big picture, containers, layers |
|
How one request flows end to end |
|
The domain: processes, tasks, factories, failure handling |
|
What each process actually does, rule by rule |
|
Every HTTP endpoint, its auth and its payloads |
|
SWF orchestration and the outbound event catalog |
|
Table shapes, keys, S3 key conventions |
|
Vendor, AWS and internal clients |
|
Running it locally, configuring it, shipping it |
|
The rules new code must follow |
|
A term you do not recognise |
Repository layout
| Path | Contents |
|---|---|
|
FastAPI application entry point (Web API container). |
|
SWF activity-worker entry point (worker container). |
|
Domain layer: processes and tasks — Domain model: processes & tasks. |
|
Integration layer: vendor, AWS and internal clients — Component layer. |
|
Routers, endpoint handlers, pydantic schemas — API overview. |
|
Dynaconf entry point plus the generated |
|
Small helpers (dict, string, time, metric, task utilities). |
|
|
|
Dockerfiles and |
|
ECS |
|
Sample vendor responses used by tests and test mode. |
|
AWS CodeBuild pipeline. |
|
Settings and secrets bootstrap. |
|
This Antora documentation component. |