Fast request path
User-facing transactions do not wait for model processing or callback delivery.
A financial backend and detached AI worker designed as one distributed system, with durable state before delivery and idempotency at every retry boundary.
Financial document processing and model-assisted classification are slower and less predictable than transactional API work. Running them inside the request path would couple user-facing reliability to a broker, model provider, and callback network.
The system instead commits business state and an outbox event together, then lets a detached worker perform AI processing and report typed results through a secured callback.
Four boundaries have distinct failure behavior: the database transaction, message delivery, AI work, and result callback.
The worker acknowledges only after the result is safely accepted or the failure is classified as permanent. Retryable failures are negatively acknowledged.
User-facing transactions do not wait for model processing or callback delivery.
An event cannot exist without its committed source state, and unpublished outbox rows remain retryable.
Redis locks and callback idempotency defend both sides of at-least-once delivery.
The worker owns model integration while the backend owns financial truth and result acceptance.