Fundamentals of Software Engineering for Fintechs
- How to Design Correct, Auditable, and Resilient Financial Systems
- Copyright
- Dedication
- Preface
- How to Use This Book
- Conventions
- Introduction — Trust Is a Technical Outcome
Part I — Money as a Domain
1. Money Is Not a double
- Learning outcome
- Real-world problem
- Mental model: money is a typed measurement
- Invariant
- Data model
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
2. Accounting Fundamentals for Engineers
- Learning outcome
- Real-world problem
- Mental model: the entity’s perspective
- Invariant
- Data model
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
3. Currencies, Minor Units, Precision, Allocation, and Rounding
- Learning outcome
- Real-world problem
- Mental model: three kinds of precision
- Invariants
- Conservation-preserving allocation
- Rounding as policy
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
4. Financial Time: Occurrence, Booking, Value, and Settlement
- Learning outcome
- Real-world problem
- Mental model: four clocks and an order
- Invariants
- Data model
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
Part II — The Ledger
5. Double-Entry Bookkeeping and the Accounting Equation
- Learning outcome
- Real-world problem
- Mental model: one transaction, multiple postings
- Invariants
- Data model
- Main flow
- Where to enforce the rule
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
6. Accounts, Transfers, Postings, and References
- Learning outcome
- Real-world problem
- Mental model: each identity answers a question
- Accounts
- Transfers and postings
- Invariants
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
7. Ledger, Available, Reserved, and Pending Balances
- Learning outcome
- Real-world problem
- Mental model: balance is a function
- Invariants
- Calculation strategies
- Concurrency
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
8. Reservations, Authorizations, and Captures
- Learning outcome
- Real-world problem
- Mental model: prepare and resolve
- Invariants
- Main flow
- Partial and incremental capture
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
9. Reversals, Refunds, Adjustments, and Closed Periods
- Learning outcome
- Real-world problem
- Mental model: neutralize, do not rewrite
- Invariants
- Data model
- Main flow
- Closed periods
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
10. Immutable Ledger, System of Record, and Audit Trail
- Learning outcome
- Real-world problem
- Mental model: narrow authority and end-to-end proof
- Invariants
- Schema evolution
- Audit trail
- Closing and hashes
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
Part III — Distributed Financial Systems
11. Concurrency, Linearizability, and Overspending Prevention
- Learning outcome
- Real-world problem
- Mental model: the operation must appear indivisible
- Invariants
- Data model and command
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
12. Idempotency, Retries, Timeouts, Backoff, and Jitter
- Learning outcome
- Real-world problem
- Mental model: stable intention, variable attempts
- Invariants
- Main flow
- Timeouts and retries
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
13. Local Transactions, Two-Phase Commit, and the Limits of Coordination
- Learning outcome
- Real-world problem
- Mental model: coordination buys atomicity with dependencies
- Invariants
- Decision matrix
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
14. Sagas, Compensations, and Durable Execution
- Learning outcome
- Real-world problem
- Mental model: persisted history
- Invariants
- Data model
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
15. Transactional Outbox, CDC, and Reliable Event Propagation
- Learning outcome
- Real-world problem
- Mental model: fact and announcement in the same commit
- Invariants
- Polling versus CDC
- Event contract
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
16. Replay, Schema Evolution, Projections, and External Effects
- Learning outcome
- Real-world problem
- Mental model: reproduce calculation, not the world
- Invariants
- Schema evolution
- Projections and snapshots
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
Part IV — Integration with Financial Networks
17. Financial APIs and Integration Contracts
- Learning outcome
- Real-world problem
- Mental model: a translation boundary
- Invariants
- Main flow
- Resilience
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
18. Webhooks, Signatures, Redelivery, and Out-of-Order Events
- Learning outcome
- Real-world problem
- Mental model: persist before interpreting
- Invariants
- Order and precedence
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
19. Clearing, Settlement, and Financial Finality
- Learning outcome
- Real-world problem
- Mental model: message, obligation, and cash
- Invariants
- Files and batches
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
20. Transaction-, Batch-, and Balance-Level Reconciliation
- Learning outcome
- Real-world problem
- Mental model: three layers
- Classification
- Invariants
- Data model
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
21. Cards: Authorization, Capture, Clearing, Settlement, and Disputes
- Learning outcome
- Real-world problem
- Mental model: identities by stage
- Invariants
- State machines
- Failures and recovery
- Security and scope
- How to prove correctness
- Documented case
- Application
- Chapter references
22. Pix and Instant Payments
- Learning outcome
- Real-world problem
- Mental model: instruction, completion, and return
- Invariants
- Directories and keys
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
23. ACH, Wire Transfers, Returns, Chargebacks, and Other Rails
- Learning outcome
- Real-world problem
- Mental model: capability matrix
- Invariants
- Adapter architecture
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
Part V — Trust, Security, and Controls
24. Zero Trust on Financial Platforms
- Learning outcome
- Real-world problem
- Mental model: verify by resource and action
- Invariants
- Architecture
- Incremental migration
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
25. Segregation of Duties and the Four-Eyes Principle
- Learning outcome
- Real-world problem
- Mental model: divided authority
- Invariants
- Approval authority and risk
- Break-glass
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
26. PCI, Tokenization, HSMs, and Key Management
- Learning outcome
- Real-world problem
- Mental model: reduce, isolate, and govern
- Invariants
- Envelope-encryption architecture
- Rotation
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
27. AML, KYC, Monitoring, and the Risk-Based Approach
- Learning outcome
- Real-world problem
- Mental model: contextual, auditable decisions
- Invariants
- Risk-based approach
- Main flow
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
28. Privacy, Retention, Pseudonymization, and Immutability
- Learning outcome
- Real-world problem
- Mental model: purpose by layer
- Invariants
- Architecture
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
29. Operational Resilience and External Dependencies
- Learning outcome
- Real-world problem
- Mental model: critical service and tolerable impact
- Invariants
- Patterns
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
Part VI — Proving Correctness
30. Financial Invariants as Executable Specifications
- Learning outcome
- Real-world problem
- Mental model: the system’s constitution
- Categories
- Executable catalog
- Invariants of this book
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
31. Property-Based Testing
- Learning outcome
- Real-world problem
- Mental model: search for counterexamples
- Domain generators
- Invariants under test and useful properties
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
32. Crash-and-Resume and Resumption Testing
- Learning outcome
- Real-world problem
- Mental model: cut the flow at every durable boundary
- Invariants
- Testing technique
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
33. Automated Reconciliation and Discrepancy Management
- Learning outcome
- Real-world problem
- Mental model: a test that never ends
- Invariants
- Safe automation
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
34. Financial Observability and Distributed Tracing
- Learning outcome
- Real-world problem
- Mental model: signals in two layers
- Invariants
- Instrumentation
- Alerts
- Failures and recovery
- How to prove correctness
- Documented case
- Application
- Chapter references
35. Production Testing and Financial Incident Response
- Learning outcome
- Real-world problem
- Mental model: contain, measure, correct, prove
- Invariants
- First actions
- Safe deployment
- Failures and recovery
- Postmortem
- How to prove correctness
- Documented case
- Application
- Chapter references
Epilogue — A Method for Reviewing a Fintech Architecture
- Step 1 — Declare the economic event
- Step 2 — Write the postings
- Step 3 — Mark failure boundaries
- Step 4 — Make invariants explicit
- Step 5 — Define independent sources
- Step 6 — Simulate the worst moment
- Step 7 — Prove recovery
Conclusion — Engineering Worthy of Trust
Practical Workbook — Project Atlas
- Lab 1 — Write the economic contract
- Lab 2 — Design the minimum ledger
- Lab 3 — Build the idempotent command
- Lab 4 — Implement reconciliation
- Lab 5 — Create a safe administrative correction
- Lab 6 — Run the readiness review
Appendix A — Financial Architecture Canvas
- 1. Economic intention
- 2. States
- 3. Accounting
- 4. Distribution
- 5. Control
- 6. Security
Appendix B — Invariant Catalog Template
Appendix C — Reconciliation Matrix
Appendix D — Architecture Review Questions
Appendix E — A DSL for Financial Invariants
- Minimum structure
- Identity and scope
- Accounts and postings
- States and transitions
- Reservations and limits
- Generated proofs
- Metrics and runbooks
- Refund example
- DSL governance
- Limitations
Appendix F — Financial Incident Runbook
- Activation criteria
- Roles
- First 30 minutes
- Impact query
- Correction strategy
- Stabilization criteria
- Closure criteria
- Invariant-oriented postmortem
Glossary
References and Recommended Reading
- Distributed systems engineering
- Architecture and domain
- Security and reliability
- Payments and messaging
- Verified online technical sources