Case study · Responsible AI in lending

Decisions people can question: explainable AI credit scoring for a Brazilian digital lender

A Brazilian digital lender approved and priced loans in seconds with machine learning models. Customers could not easily find out why they were declined, and reviewing a decision meant digging through logs. The goal was to make every automated credit decision explainable, reviewable by a person and ready for the AI rules Brazil is debating.

Case studyConsumer lending · BrazilSumanta Mukhopadhyay9 min read
#ai#governance#data
CASE STUDY · CASE STUDY · RESPONSIBLE AI IN LENDING30 Oct 2026 · 01:20 GST
At a glance
SectorConsumer lending · Brazil
My roleFractional CTO and AI architect
EngagementAssessment, architecture and delivery leadership
ScopeDecision service, reason codes, human review, model governance, data protection
What changed
  • Every automated decision stored with model version, inputs used and reason codes
  • Customers given clear reasons and a route to request human review
  • Reviews handled in a workbench with the full decision context
  • Models released through a governed gate with performance and stability checks
  • Data used for credit decisions documented and minimised
Credit decision serviceGradient-boosted modelsReason code generationReview workbenchEvent streamingOpenTelemetry tracingModel registryData catalogue

Anonymised composite. Client names, identifying details and confidential figures are withheld; public facts are cited in the references.

The situation

A digital lender in Brazil offered personal loans and credit lines through its app. Machine learning models approved, declined and priced applications in seconds, using bureau data, open finance data shared with consent and in-app behaviour. Growth was strong. Complaints were the warning sign: declined customers could not get a useful answer about why, and when the team reviewed a decision it meant piecing together logs from several services.

Why now. Brazil's data protection law, the LGPD, already gives people the right to request review of decisions taken solely through automated processing that affect their interests, including credit profiling, and to receive clear information about the criteria used1. The national data protection authority, ANPD, oversees it2. On top of that, Brazil's AI bill, PL 2338/2023, passed the Senate in December 2024 and was pending in the Chamber of Deputies, with a vote reported as expected after the October 2026 elections345. It is not law yet, but a lender relying on automated credit decisions could not afford to wait.

What had to be true

  • Every decision reconstructable: model version, data used and outcome, stored together.
  • Clear reasons a customer can understand, without exposing trade secrets.
  • Human review on request, handled quickly with full context.
  • Governed models: tested before release and monitored after.
  • Data minimised and documented, especially open finance data used with consent.

Architecture

Channels
Appapplication and resultCustomer servicereview requests
Decision
Credit decision serviceone entry pointPolicy ruleshard limits firstScoring modelsversioned
Explain
Reason codestop factors, plain languageDecision recordinputs, versions, outcome
Review
Review workbenchfull context for analystsOutcome feedbackoverturns tracked
Govern
Model registrytests and approvalsMonitoringdrift and stabilityData cataloguepurpose and consent
One decision service produces the outcome, the reasons and the record in the same step.

The data flow, end to end

  1. ApplyApplication submitted with consented data sources
  2. RulesPolicy rules applied first, with their own reasons
  3. ScoreVersioned model scores; top factors extracted
  4. RecordDecision, inputs, versions and reason codes stored together
  5. ExplainCustomer sees outcome, main reasons and how to ask for review
  6. ReviewAn analyst reviews with full context and can overturn
The record is written at decision time, not reconstructed later.

The hard part: reconstructing a decision months later

A review request can arrive weeks or months after the decision. By then models have been retrained and data has changed. The team made the decision record immutable and complete at the moment of decision, and linked each application event to the processing that handled it with distributed tracing. OpenTelemetry instrumentation for Kafka links the receive and process steps of a message in one trace, so analysts can follow an application from arrival to outcome6.

Jaeger trace view showing a Kafka receive span and a linked process span for the same message, with messaging attributes and references between spans
Receive and process steps linked in one trace: the same pattern ties each application to the decision made about it. Source: OpenTelemetry blog, Paolo Patierno · CC BY 4.0

An explanation you generate later is a story. An explanation recorded at decision time is evidence. Build for the second.

Reason codes were generated from the model's own attributions and mapped to plain-language statements reviewed by legal and customer teams, so explanations were truthful without revealing model internals. More on evidence and evaluation in evaluation sets that predict production and high-impact AI in hiring.

How it ran

Credit risk
  1. Policy rules
  2. Reason code library
  3. Model approval
Engineering and data
  1. Decision service
  2. Decision record and tracing
  3. Monitoring
Legal and customer service
  1. LGPD requirements
  2. Customer wording
  3. Review process
Risk owned the reasons, engineering the evidence, customer service the review.
Phase 1Consolidate
  • One decision service
  • Policy rules separated
  • Model registry
Phase 2Record
  • Immutable decision records
  • Tracing
  • Data catalogue
Phase 3Explain
  • Reason codes
  • Customer messages
  • Review workbench
Phase 4Govern
  • Release gate
  • Drift monitoring
  • Overturn analysis
Consolidating decision logic first made everything else possible.

Key decisions and trade-offs

DecisionAlternativeWhy
One decision serviceScoring spread across servicesOne place to record, explain and govern
Record at decision timeReconstruct from logs on requestModels and data change; records must not
Reason codes from model attributionsGeneric decline messagesTruthful, useful and consistent explanations
Policy rules before modelsModel-only decisionsHard limits are easy to explain and audit
Prepare for the AI bill nowWait for the final textThe LGPD already requires most of this

What I'd do again, and differently

Again: consolidate decisions into one service before adding explanations; scattered logic cannot be explained. Differently: track overturned decisions from day one. They were the clearest signal of where models or rules needed work. Related: structured outputs and where I work.

If you make automated decisions about customers in Brazil or elsewhere in Latin America, my AI architecture work explains how I approach it, or analyse your challenge and bring the result to a call.

References
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
    Instrumenting Apache Kafka clients with OpenTelemetryOpenTelemetry blog (Paolo Patierno) · 6 Sep 2022
FAQ

Common questions

Does the LGPD cover automated credit decisions?

Yes. The LGPD gives data subjects the right to request review of decisions taken solely on the basis of automated processing that affect their interests, including profiling such as credit, and to receive clear information about the criteria and procedures used, subject to trade secrets.

Is Brazil's AI bill law yet?

Not at the time of writing. Bill 2338/2023 was approved by the Senate in December 2024 and was pending in the Chamber of Deputies, with a vote reported as expected after the October 2026 elections.

What are reason codes?

Short, standardised explanations of the main factors behind a decision, such as income stability or existing debt, generated from the model and the inputs it used, so customers and reviewers can understand and challenge the outcome.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.