Leanpub Header

Skip to main content

Fundamentals of Software Engineering for Fintechs

How to Design Correct, Auditable, and Resilient Financial Systems

Build financial systems that stay correct when requests repeat, events arrive late, and services fail. Learn practical patterns for money modeling, double-entry ledgers, idempotency, reconciliation, auditability, security, and invariant-driven testing—so every balance and transaction can be explained and trusted.

Minimum price

$29.85

$39.85

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Financial software cannot afford to be “almost right.” A duplicated request can charge a customer twice. A rounding error can break reconciliation. An out-of-order event can expose a balance that does not exist. And an audit trail without reliable evidence can turn a technically sound system into an operational and regulatory risk.

Fundamentals of Software Engineering for Fintechs provides a practical foundation for designing financial systems that remain correct, auditable, and resilient under real-world conditions. Starting with the fundamentals of money modeling, the book progresses through double-entry ledgers, idempotency, distributed consistency, payment processing, reconciliation, security, observability, and invariant-driven testing.

You will learn how to:

  • Represent monetary values without silent precision or rounding errors.
  • Design balanced, immutable double-entry ledgers.
  • Prevent duplicate financial effects across APIs, queues, and background jobs.
  • Model authorization, capture, settlement, refunds, reversals, and disputes.
  • Distinguish ledger balance, available balance, and external settlement state.
  • Reconcile internal records with processors, banks, and payment networks.
  • Build audit trails that support investigations, incidents, and compliance reviews.
  • Test financial invariants under concurrency, retries, delays, and partial failures.
  • Use metrics and controls that reveal actual financial and operational risk.

Written for software engineers, architects, technical leaders, and professionals working in product, risk, finance, and operations, this book combines mental models, implementation patterns, pseudocode, SQL examples, checklists, and practical exercises.

It does not prescribe a single architecture or technology stack. Instead, it teaches you how to make financial assumptions explicit, convert business rules into enforceable invariants, preserve reliable evidence, and design systems in which every balance and transaction can be explained.

Author

About the Author

Geison Goes

Geison Felipe Góes Flores is a technical author focused on the principles behind correct, auditable, and resilient financial systems. He wrote Fundamentals of Software Engineering for Fintechs to help professionals understand what happens beneath balances, transfers, payment confirmations, and financial APIs.

His work connects software architecture, distributed systems, accounting concepts, payment operations, reconciliation, security, observability, and invariant-driven testing. Rather than prescribing a single technology stack, Geison presents practical models for identifying where money or financial facts could be duplicated, lost, delayed, corrupted, or accepted without sufficient evidence.

Throughout the book, he transforms complex financial rules into mechanisms engineering teams can implement and verify: balanced ledger entries, explicit state machines, idempotency contracts, immutable histories, reconciliation procedures, audit trails, risk-oriented metrics, and controlled recovery paths.

Geison’s central belief is that trust is not merely a feature presented through an interface—it is a technical property earned through every modeling, architecture, implementation, and operational decision.

“A trustworthy financial system must be able to explain not only what happened, but why it happened and how its correctness can be demonstrated.”

With practical examples, pseudocode, SQL, checklists, exercises, and architecture review frameworks, Geison helps engineers, architects, technical leaders, and fintech teams turn financial complexity into systems they can understand, operate, and trust.

Contents

Table of Contents

Fundamentals of Software Engineering for Fintechs

  1. How to Design Correct, Auditable, and Resilient Financial Systems
  2. Copyright
  3. Dedication
  4. Preface
  5. How to Use This Book
  6. Conventions
  7. Introduction — Trust Is a Technical Outcome

Part I — Money as a Domain

1. Money Is Not a double

  1. Learning outcome
  2. Real-world problem
  3. Mental model: money is a typed measurement
  4. Invariant
  5. Data model
  6. Main flow
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

2. Accounting Fundamentals for Engineers

  1. Learning outcome
  2. Real-world problem
  3. Mental model: the entity’s perspective
  4. Invariant
  5. Data model
  6. Main flow
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

3. Currencies, Minor Units, Precision, Allocation, and Rounding

  1. Learning outcome
  2. Real-world problem
  3. Mental model: three kinds of precision
  4. Invariants
  5. Conservation-preserving allocation
  6. Rounding as policy
  7. Main flow
  8. Failures and recovery
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

4. Financial Time: Occurrence, Booking, Value, and Settlement

  1. Learning outcome
  2. Real-world problem
  3. Mental model: four clocks and an order
  4. Invariants
  5. Data model
  6. Main flow
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

Part II — The Ledger

5. Double-Entry Bookkeeping and the Accounting Equation

  1. Learning outcome
  2. Real-world problem
  3. Mental model: one transaction, multiple postings
  4. Invariants
  5. Data model
  6. Main flow
  7. Where to enforce the rule
  8. Failures and recovery
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

6. Accounts, Transfers, Postings, and References

  1. Learning outcome
  2. Real-world problem
  3. Mental model: each identity answers a question
  4. Accounts
  5. Transfers and postings
  6. Invariants
  7. Main flow
  8. Failures and recovery
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

7. Ledger, Available, Reserved, and Pending Balances

  1. Learning outcome
  2. Real-world problem
  3. Mental model: balance is a function
  4. Invariants
  5. Calculation strategies
  6. Concurrency
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

8. Reservations, Authorizations, and Captures

  1. Learning outcome
  2. Real-world problem
  3. Mental model: prepare and resolve
  4. Invariants
  5. Main flow
  6. Partial and incremental capture
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

9. Reversals, Refunds, Adjustments, and Closed Periods

  1. Learning outcome
  2. Real-world problem
  3. Mental model: neutralize, do not rewrite
  4. Invariants
  5. Data model
  6. Main flow
  7. Closed periods
  8. Failures and recovery
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

10. Immutable Ledger, System of Record, and Audit Trail

  1. Learning outcome
  2. Real-world problem
  3. Mental model: narrow authority and end-to-end proof
  4. Invariants
  5. Schema evolution
  6. Audit trail
  7. Closing and hashes
  8. Failures and recovery
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

Part III — Distributed Financial Systems

11. Concurrency, Linearizability, and Overspending Prevention

  1. Learning outcome
  2. Real-world problem
  3. Mental model: the operation must appear indivisible
  4. Invariants
  5. Data model and command
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

12. Idempotency, Retries, Timeouts, Backoff, and Jitter

  1. Learning outcome
  2. Real-world problem
  3. Mental model: stable intention, variable attempts
  4. Invariants
  5. Main flow
  6. Timeouts and retries
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

13. Local Transactions, Two-Phase Commit, and the Limits of Coordination

  1. Learning outcome
  2. Real-world problem
  3. Mental model: coordination buys atomicity with dependencies
  4. Invariants
  5. Decision matrix
  6. Main flow
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

14. Sagas, Compensations, and Durable Execution

  1. Learning outcome
  2. Real-world problem
  3. Mental model: persisted history
  4. Invariants
  5. Data model
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

15. Transactional Outbox, CDC, and Reliable Event Propagation

  1. Learning outcome
  2. Real-world problem
  3. Mental model: fact and announcement in the same commit
  4. Invariants
  5. Polling versus CDC
  6. Event contract
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

16. Replay, Schema Evolution, Projections, and External Effects

  1. Learning outcome
  2. Real-world problem
  3. Mental model: reproduce calculation, not the world
  4. Invariants
  5. Schema evolution
  6. Projections and snapshots
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

Part IV — Integration with Financial Networks

17. Financial APIs and Integration Contracts

  1. Learning outcome
  2. Real-world problem
  3. Mental model: a translation boundary
  4. Invariants
  5. Main flow
  6. Resilience
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

18. Webhooks, Signatures, Redelivery, and Out-of-Order Events

  1. Learning outcome
  2. Real-world problem
  3. Mental model: persist before interpreting
  4. Invariants
  5. Order and precedence
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

19. Clearing, Settlement, and Financial Finality

  1. Learning outcome
  2. Real-world problem
  3. Mental model: message, obligation, and cash
  4. Invariants
  5. Files and batches
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

20. Transaction-, Batch-, and Balance-Level Reconciliation

  1. Learning outcome
  2. Real-world problem
  3. Mental model: three layers
  4. Classification
  5. Invariants
  6. Data model
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

21. Cards: Authorization, Capture, Clearing, Settlement, and Disputes

  1. Learning outcome
  2. Real-world problem
  3. Mental model: identities by stage
  4. Invariants
  5. State machines
  6. Failures and recovery
  7. Security and scope
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

22. Pix and Instant Payments

  1. Learning outcome
  2. Real-world problem
  3. Mental model: instruction, completion, and return
  4. Invariants
  5. Directories and keys
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

23. ACH, Wire Transfers, Returns, Chargebacks, and Other Rails

  1. Learning outcome
  2. Real-world problem
  3. Mental model: capability matrix
  4. Invariants
  5. Adapter architecture
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

Part V — Trust, Security, and Controls

24. Zero Trust on Financial Platforms

  1. Learning outcome
  2. Real-world problem
  3. Mental model: verify by resource and action
  4. Invariants
  5. Architecture
  6. Incremental migration
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

25. Segregation of Duties and the Four-Eyes Principle

  1. Learning outcome
  2. Real-world problem
  3. Mental model: divided authority
  4. Invariants
  5. Approval authority and risk
  6. Break-glass
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

26. PCI, Tokenization, HSMs, and Key Management

  1. Learning outcome
  2. Real-world problem
  3. Mental model: reduce, isolate, and govern
  4. Invariants
  5. Envelope-encryption architecture
  6. Rotation
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

27. AML, KYC, Monitoring, and the Risk-Based Approach

  1. Learning outcome
  2. Real-world problem
  3. Mental model: contextual, auditable decisions
  4. Invariants
  5. Risk-based approach
  6. Main flow
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

28. Privacy, Retention, Pseudonymization, and Immutability

  1. Learning outcome
  2. Real-world problem
  3. Mental model: purpose by layer
  4. Invariants
  5. Architecture
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

29. Operational Resilience and External Dependencies

  1. Learning outcome
  2. Real-world problem
  3. Mental model: critical service and tolerable impact
  4. Invariants
  5. Patterns
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

Part VI — Proving Correctness

30. Financial Invariants as Executable Specifications

  1. Learning outcome
  2. Real-world problem
  3. Mental model: the system’s constitution
  4. Categories
  5. Executable catalog
  6. Invariants of this book
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

31. Property-Based Testing

  1. Learning outcome
  2. Real-world problem
  3. Mental model: search for counterexamples
  4. Domain generators
  5. Invariants under test and useful properties
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

32. Crash-and-Resume and Resumption Testing

  1. Learning outcome
  2. Real-world problem
  3. Mental model: cut the flow at every durable boundary
  4. Invariants
  5. Testing technique
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

33. Automated Reconciliation and Discrepancy Management

  1. Learning outcome
  2. Real-world problem
  3. Mental model: a test that never ends
  4. Invariants
  5. Safe automation
  6. Failures and recovery
  7. How to prove correctness
  8. Documented case
  9. Application
  10. Chapter references

34. Financial Observability and Distributed Tracing

  1. Learning outcome
  2. Real-world problem
  3. Mental model: signals in two layers
  4. Invariants
  5. Instrumentation
  6. Alerts
  7. Failures and recovery
  8. How to prove correctness
  9. Documented case
  10. Application
  11. Chapter references

35. Production Testing and Financial Incident Response

  1. Learning outcome
  2. Real-world problem
  3. Mental model: contain, measure, correct, prove
  4. Invariants
  5. First actions
  6. Safe deployment
  7. Failures and recovery
  8. Postmortem
  9. How to prove correctness
  10. Documented case
  11. Application
  12. Chapter references

Epilogue — A Method for Reviewing a Fintech Architecture

  1. Step 1 — Declare the economic event
  2. Step 2 — Write the postings
  3. Step 3 — Mark failure boundaries
  4. Step 4 — Make invariants explicit
  5. Step 5 — Define independent sources
  6. Step 6 — Simulate the worst moment
  7. Step 7 — Prove recovery

Conclusion — Engineering Worthy of Trust

Practical Workbook — Project Atlas

  1. Lab 1 — Write the economic contract
  2. Lab 2 — Design the minimum ledger
  3. Lab 3 — Build the idempotent command
  4. Lab 4 — Implement reconciliation
  5. Lab 5 — Create a safe administrative correction
  6. Lab 6 — Run the readiness review

Appendix A — Financial Architecture Canvas

  1. 1. Economic intention
  2. 2. States
  3. 3. Accounting
  4. 4. Distribution
  5. 5. Control
  6. 6. Security

Appendix B — Invariant Catalog Template

Appendix C — Reconciliation Matrix

Appendix D — Architecture Review Questions

Appendix E — A DSL for Financial Invariants

  1. Minimum structure
  2. Identity and scope
  3. Accounts and postings
  4. States and transitions
  5. Reservations and limits
  6. Generated proofs
  7. Metrics and runbooks
  8. Refund example
  9. DSL governance
  10. Limitations

Appendix F — Financial Incident Runbook

  1. Activation criteria
  2. Roles
  3. First 30 minutes
  4. Impact query
  5. Correction strategy
  6. Stabilization criteria
  7. Closure criteria
  8. Invariant-oriented postmortem

Glossary

References and Recommended Reading

  1. Distributed systems engineering
  2. Architecture and domain
  3. Security and reliability
  4. Payments and messaging
  5. Verified online technical sources

About the Author

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub