brief contents....6
contents....7
preface....14
acknowledgments....15
about this book....16
Who should read this book....16
How this book is organized: A road map....16
About the code....17
liveBook discussion forum....18
about the authors....19
about the cover illustration....20
Part 1....21
1 Exploring FinTech and generative AI....23
1.1 The Futuristic FinTech project....24
1.2 ACH dashboard....25
1.2.1 How important is the ACH?....26
1.3 SAFe Agile....27
1.4 The ACH dashboard....29
1.4.1 Tools of the trade....33
1.5 A first look at generative AI....33
1.5.1 A better rubber duck....34
1.5.2 Hello, Check 21!....34
1.5.3 Help! This code is not working!....38
1.5.4 Help! I forgot the syntax!....41
1.5.5 Did I just give away my data?....44
1.5.6 Privacy and security....46
1.5.7 Staying up to date....46
2 Parsing payments....49
2.1 Modernizing our legacy software....49
2.2 Understanding the ACH....51
2.3 Parsing an ACH file....52
2.3.1 Asking ChatGPT to parse an ACH file....54
2.3.2 Parsing an ACH file with Copilot....58
2.3.3 Generative AI: Trust but verify....60
2.4 Automated testing....61
2.4.1 Testing the number of records read....62
2.4.2 Parsing the records....62
2.4.3 File header record (type 1)....65
2.4.4 Batch header record (type 5)....68
2.5 Entry detail record (type 6)....70
2.5.1 Addenda record (type 7)....71
2.5.2 Batch control record (type 8)....72
2.5.3 File trailer record (type 9)....73
2.5.4 Passed!....74
2.6 The not-so-happy path....74
2.6.1 File rejection....75
2.6.2 Batch rejection....76
2.6.3 Entry rejection....77
2.7 Interpreting the code....77
2.7.1 Wheres my switch statement?....77
2.7.2 Type hints....78
2.7.3 Secure coding....79
Part 2....83
3 Getting started with Docker....85
3.1 Where to begin....86
3.2 Creating a docker-compose.yml file....88
3.2.1 Creating a CloudBeaver container....90
3.2.2 Create a PostgreSQL container....92
3.2.3 API container....94
3.2.4 Web server container....96
3.3 Connecting our containers....96
3.3.1 Connecting to the database....97
3.3.2 Troubleshooting PostgreSQL and FastAPI....98
3.4 Calling our API....99
3.4.1 Troubleshooting our web site....102
3.5 Container security....103
3.6 Optimizing Docker....105
3.6.1 General maintenance....106
3.6.2 Optimizing image size....107
3.6.3 Optimizing build time....108
3.7 Removing the hardcoded usernamepassword....109
3.8 Health checks....112
4 APIs: The piping between our components....114
4.1 API-driven design....114
4.2 Our APIs....116
4.3 Building our APIs with FastAPI....117
4.3.1 Retrieving files with GET files....119
4.3.2 Adding a file with POST files....122
4.3.3 Finishing the rest of the APIs....124
4.4 Adding our API to Docker....124
4.4.1 Preparing the project....125
4.4.2 Docker setup....125
4.5 Documenting our API....126
4.5.1 Swagger....127
4.5.2 Redoc....128
4.5.3 What is so great about API documentation?....128
4.6 Managing our APIs....129
4.6.1 Benefits of API management....129
4.6.2 Adding WSO2 API manager to our project....130
4.6.3 OpenAPI Version....131
4.6.4 Create an API in WSO2....132
4.6.5 Troubleshooting....133
4.7 Testing with Postman....134
4.8 Load testing with Locust....136
4.9 Improving our code....141
4.9.1 Using a prefix and versioning....141
4.9.2 Adding Pydantic....142
4.9.3 Validation with Pydantic....143
4.9.4 Troubleshooting Pydantic....145
5 Storing our ACH files....147
5.1 Designing our database....148
5.2 Using SQL directly....152
5.2.1 Adding records to the ach_files table....153
5.3 Storing the file header record....158
5.3.1 Using generative AI....158
5.3.2 Full example....159
5.4 Storing the rest of our ACH records....163
5.4.1 Storing ACH files challenge: Lessons learned....163
5.5 Storing exceptions....165
5.6 Uploading an ACH file....167
5.7 Storing records with integrity....172
5.8 Using Pydantic....173
5.9 Lessons learned....176
5.10 Coding changes....179
5.10.1 Creating Pydantic schema for the unparsed ACH records....179
5.10.2 Creating Pydantic schema for the parsed ACH records....179
5.10.3 Unit test changes....180
5.11 Design and different approaches....180
6 Taking the next step with Next.js....183
6.1 Getting started with Next.js....184
6.2 Creating an upload page....186
6.2.1 Testing our upload page....186
6.3 Refactoring our navigation....188
6.4 Converting recent order to recent ACH uploads....190
6.5 Mocking our ACH uploads data....195
6.5.1 Adding WireMock to Docker....196
6.5.2 Setting up mappings in WireMock....197
6.5.3 Accessing endpoints with axios....199
6.6 Expanding the UI with an ACH batch view....201
6.6.1 Defining our WireMock data for the ACH batch view....202
6.6.2 Updating the dashboard to take us to the batches screen....204
6.6.3 Displaying batch details....205
6.7 Creating a ScatterPlot component....206
6.7.1 Scatterplot component....207
6.7.2 Scatterplot custom tooltip....209
6.7.3 Scatterplot custom ticks....209
6.7.4 Using colors for the chart....210
6.8 Deploying the dashboard in Docker....212
7 Our minimum viable product....214
7.1 Which minimum are we talking about?....215
7.2 Preparing for the MVP....216
7.3 Building out the files APIs....217
7.3.1 Testing the API....224
7.4 ACH batches APIs....227
7.4.1 Adding the filesidbatches API....227
7.4.2 Supporting ACH batches in the dashboard....233
7.4.3 Uploading files....235
7.5 Putting the puzzle together....237
7.5.1 Cleaning up the configuration files....237
7.5.2 Ensuring APIs are accessible....240
7.5.3 Programming challenges....240
7.5.4 Exploring the dashboard....241
7.6 Gotta have more files....241
7.7 Adding a basic login page....244
7.8 Adding TLS to our dashboard....249
7.9 Testing with Playwright....251
7.10 MVP wrap-up....253
7.10.1 Troubleshooting the MVP....253
Part 3....257
8 Exceptions....259
8.1 Planning enhancements....260
8.2 Exceptions and warnings....261
8.3 Creating ACH files with exceptions....264
8.3.1 Creating ACH files with file-level exceptions....264
8.3.2 Creating ACH files with batch-level exceptions....265
8.3.3 Creating ACH files with entry-level exceptions....266
8.3.4 Clean-up of our file creation syntax....266
8.4 Expanding the ACH processing for exceptions....267
8.4.1 ACH exceptions in the database....267
8.4.2 Recovery options....269
8.5 Updating the ACH parser....270
8.5.1 Creating unit tests for the exceptions....271
8.5.2 Supporting the exceptions in our parser....272
8.5.3 Validation in Pydantic....275
8.6 Updating the APIs....276
8.6.1 Retrieving an unparsed record....282
8.7 Insights into exceptions with the UI....283
8.7.1 Showing all the exceptions....284
8.7.2 A visual cue for exceptions....287
8.8 Additional UI changes....289
8.8.1 Creating an exceptions component....289
8.8.2 Batch statistics component....291
8.8.3 Adding the application....295
8.8.4 Making our UI more responsive....297
9 Searching and auditing....301
9.1 Sprint planning....302
9.2 Searching ACH transactions....303
9.2.1 BDD testing for searching....304
9.2.2 Search API....306
9.2.3 UI search page....311
9.2.4 Integration testing with Playwright....315
9.3 Auditing user interactions....317
9.3.1 Database design....317
9.3.2 TDD testing for auditing....318
9.3.3 Auditing logic....320
9.4 Using middleware for our logging....321
9.5 Viewing the audit log....323
9.5.1 Creating the page....323
9.5.2 Creating the page components....324
9.5.3 Adding the APIs for the audit log....328
10 Company information....331
10.1 Sprint planning....332
10.2 Company Information....333
10.2.1 Database design: Company information....333
10.2.2 Using generative AI to generate mock data ....337
10.2.3 API design ....339
10.2.4 User interface....342
10.3 Company dashboard....346
10.3.1 Navigation for the company dashboard....346
10.3.2 Creating ACH files for our companies....347
10.4 Company Information component....348
10.5 Recent Batches component....353
10.5.1 Implementing the recent batches API....353
10.5.2 Displaying recent batches....356
10.6 Expected Files component....357
10.6.1 Storing expected files....358
10.6.2 Implementing the expected files API....359
10.6.3 Displaying the expected files....363
10.7 Company Limits component....364
10.7.1 Storing the company limits....365
10.7.2 Implementing the company limits API....366
10.7.3 Displaying the company limits....369
11 International ACH transactions and OFAC scanning....375
11.1 Sprint planning....376
11.2 IAT....377
11.2.1 IAT batches: An overview....377
11.3 Creating IAT batches....379
11.3.1 Database changes....381
11.4 IAT record parsing....383
11.5 IAT file processing....387
11.5.1 Unit testing....388
11.5.2 Updating file processing....392
11.6 Effects on the dashboard....395
11.6.1 The get_batches method....395
11.6.2 Batch entries....396
11.7 OFAC scanning....398
11.7.1 Sanctioned individuals and countries....398
11.7.2 Scanning for individuals....399
11.8 API....403
11.8.1 Unit test....404
11.8.2 Creating the endpoint....405
11.8.3 Finishing the API....405
11.9 User interface....407
11.9.1 The OFAC page....407
11.9.2 OFAC components....408
11.9.3 OFAC results....410
12 Where to go from here....413
12.1 Backend processing....414
12.1.1 Asynchronous processing....414
12.1.2 ORM frameworks....415
12.1.3 APIs....415
12.2 Infrastructure....416
12.2.1 Docker....416
12.2.2 Multitenant environment....416
12.2.3 Continuous integration and delivery....417
12.2.4 Testing....417
12.2.5 Database....417
12.3 User interface....418
12.3.1 Charts and forms....418
12.3.2 Configurable dashboards....420
12.3.3 Mobile version....420
12.4 Finance....420
12.4.1 Accounts and customers....420
12.4.2 ACH origination and returns....421
12.4.3 Positive Pay....422
12.4.4 Service charges....422
12.5 Final thoughts....422
index....424
Build working and regulation-compliant financial software—from scratch!
The software used by banks, trading firms, and other financial services has special requirements at every level, from securing the UI to making sure backend services comply with a host of regulations.Build Financial Software with Generative AI (From Scratch)shows you how to deliver full stack financial services software—and how generative AI can make you even more productive.
In Build Financial Software with Generative AI (From Scratch) you will:
In Build Financial Software with Generative AI (From Scratch) you’ll build working software for processing Automated Clearing House (ACH) files, a cornerstone technology of banking that moves trillions of dollars every year. You’ll work with generative AI technology throughout the full stack application, including researching the tech for your application, spinning up a bare bone starting project, answering domain questions, clarifying functionality, and troubleshooting. Along the way, you’ll learn what sets FinTech projects apart from normal web apps.
The financial industry is awash with regulatory and compliance challenges, complex technical requirements, and stringent security demands. There’s a huge demand for developers who can create financial services software and this book will get you started. You’ll build your own FinTech app from the ground up—with a big productivity boost from Generative AI!
Build Financial Software with Generative AI (From Scratch) guides you through modernizing a full-stack Automated Clearing House (ACH) application, layer-by-layer. You’ll start with a quick review of FinTech basics and an introduction to GenAI tools. Then, you’ll develop a data visualization dashboard with React, containerize components with Docker, create and refine APIs, implement backend processing, and even design a custom database. Throughout, you’ll see how AI tools aid with coding, testing, research, security, documentation, and even Agile practices.
Examples are in Python. No experience with generative AI or financial services required.