- Front Matter
- Standing Boundary and Copyright Note 2
- Contents 3
- Preface 4
- How to Read This Book (and the Trilogy Map) 5
- Part I — The Persistence Boundary
- 1 · The Seam, Signed 7
- 2 · The NexusDbContext 16
- 3 · Mapping the Citizens 23
- 4 · Repositories — the Three-Line Adapters 32
- 5 · The Unit of Work and the Commit Seam 39
- 6 · Optimistic Concurrency 46
- 7 · The Outbox — the Write Half 52
- 8 · Migrations and Seeding 58
- Part II — The API Layer
- 9 · The Composition Root Completed 66
- 10 · Controllers and the Primitive Boundary 73
- 11 · DTOs and Translation 79
- 12 · Refusals Over the Wire 85
- 13 · Idempotency 92
- 14 · Versioning and the Browsable Contract 99
- Part III — The Security Context (The Closing Act)
- 15 · Operators and Roles in Code 106
- 16 · Authentication — JWT Issuance and Validation 112
- 17 · Authorization — OperatorId, No Longer on Faith 118
- Part IV — First Light
- 18 · The Choreographed Night, Over a Wire 126
- Back Matter
- Epilogue: The Honest Boundary of Volume II 132
- Appendix A · Installation Guide (SQL Server / LocalDB) 135
- Appendix B · The Full Volume-II Solution Skeleton 138
- Appendix C · Tools and Packages 141
- Appendix D · Bounded Context → Schema → DbContext Map 144
- Appendix E · Refusal Code → HTTP Status Registry 147
- Source References 150
- Glossary 151
- Index 153
From Core to Contract
Give the tested core a database and a public API — without letting either touch its rules. Build NEXUS-1's Infrastructure and API layers in .NET: EF Core, repositories, the outbox, RFC 7807, JWT. 654 tables, one seam that stays signed — every rule proven by watching it fail.
Minimum price
$79.99
$99.99
You pay
Author earns
About
About the Book
Volume I built a core with no database and no web server, and dared you to call that a limitation. From Core to Contract is the volume where the database and the wire finally arrive — and the entire discipline is keeping them on their own side of the seam.
This is the second volume of the NEXUS-1 backend trilogy. It takes the fully tested Domain and Application layers built in From Blueprint to Core and gives them the two things Clean Architecture spends its whole life holding at arm's length: persistence and a public API. By the last page, EF Core is mapping an aggregate to real SQL Server tables, HTTP requests are flowing in and problem-details refusals are flowing back out, JWTs are being issued and validated — and not one line of that infrastructure has reached up past the boundary to change a rule the core already proved.
That restraint is the subject of the book. Anyone can wire up a DbContext and a controller. The hard part — the part most books wave through — is doing it so that the framework, the database, and the wire format stay below the seam, adapters to ports that were declared before any of them existed. This volume implements those ports against the exact 654 tables of the published schema atlas, across 17 bounded contexts, and it does so under the same standing rule that governs the whole series: nothing claims to exist that does not. Every project compiles, every class is shown in full, and every invariant is proven by a test that commits the exact crime the rule forbids and watches it fail by name.
It practices what it teaches. Every boundary decision is made once, in the open, and then held to. When the outbox needs a table of its own in Chapter 7, it doesn't quietly appear — it is admitted as a lawful Infrastructure citizen by amending, on the page, the very statute Chapter 2 wrote to keep Infrastructure out of the Domain's tables. When an earlier chapter's own code needs correcting, the fix happens in a visible diff, not in silence.
It shows its refusals, not just its successes. Optimistic concurrency isn't asserted — it's watched, with two real database connections racing for the same row until one loses by name. A DTO leak is proven by shipping the domain-carrying type on purpose and reading the leak back as JSON. Refusals cross the wire as RFC 7807 problem details carrying the platform's published refusal codes, so the client sees the same "no" the core meant.
It draws what it explains. Eighteen chapters are each followed by a two-page Deep Dive companion — plain-language explanations and original UML for readers newer to persistence, EF Core, web APIs, tokens, and authorization, adding floors under the material without lowering the technical ceiling above it. A recurring "Where We Are in the Solution" panel tracks the growing codebase, the migration's table count, and the test total, so you always know exactly how much of the system exists at any page.
It knows exactly what it hasn't built yet. The book closes with an Epilogue — The Honest Boundary of Volume II — an itemized account of what is deliberately deferred (the outbox dispatcher, the integration harness, logging, configuration environments, health checks, the container) and which volume owns each one. The seam to Volume III is stated in plain sight; it is part of the design, not an omission.
What's Inside- Part I — The Persistence Boundary. The
NexusDbContextwired to the configuration atlas of From Entity to Context; repositories as three-line adapters behind Volume I's ports; the Unit of Work with its after-commit dispatch clause; optimistic concurrency armed by a single typedRowVersion; the write half of the outbox; and migrations and seeding that build to the exact tables of the schema atlas. - Part II — The API Layer. The composition root completed; controllers kept honest by a thinness statute; DTOs and the three-vocabularies translation that keeps the Domain off the wire; refusals as RFC 7807; idempotency as a pipeline behavior; and versioning behind a browsable, honest Swagger contract.
- Part III — The Security Context (The Closing Act). Operators and roles modeled in code; JWT issuance and validation; and authorization where
OperatorIdis no longer taken on faith but carried, checked, and enforced. - Part IV — First Light. One operational night, traced end to end over a real wire — the whole stack the book has built, from HTTP request to persisted twin and back, in a single run that proves the layers actually meet.
- Five appendices — an installation guide, the full Volume-II solution skeleton, the tools-and-packages ledger, the bounded-context → schema →
DbContextmap, and the refusal-code → HTTP-status registry — plus source references, a glossary, and an index.
Developers who have read a Clean Architecture or DDD book and then hit the question those books skip: how do you add a database and an HTTP API without the framework leaking upward into the rules you worked so hard to isolate? Architects who want a fully worked persistence-and-API layer to hold their own team's decisions against. And readers of Volume I who want to watch the ports finally get their adapters.
Volume I is a companion, not a prerequisite — but this book assumes a tested Domain and Application core already exists, and From Blueprint to Core is where that core was built. Everything you need to follow this book's code is inside it.
Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης Γρηγόριος, Αγαθαγγελιδης Γρηγοριος, Grigorios Agathangelidis.
Author
About the Author
Grigorios Agathangelidis is not a nuclear physicist, a nuclear engineer, or a power-plant specialist of any kind. His background is in Electrical Engineering and Software Engineering, and NEXUS-1 grew out of that background as a personal project: a deliberate attempt to study the nuclear-energy domain as carefully as a software engineer reasonably can, and then put what he learned to work alongside years of enterprise-software experience. He has never set out to speak with the authority of the nuclear industry. The point has always been the opposite — to take a domain deep and demanding enough to be worth the effort, and to hold his own craft (software architecture, simulation, visualization, user interfaces, and systems design) against it until the craft has to be real.
That is also why the series refuses to stop at "it ships." A dedicated retrospective volume, From Certainty to Calibration, returns to the published books and re-examines their earlier decisions against evidence that only arrived later — not as an apology, but as the same audit the series turns on reactor telemetry and alarm floods, aimed at itself. From Core to Contract is where that discipline meets its hardest test: the moment a tested core is finally handed a database and a public API, when it would be easiest to let the framework quietly leak upward and call the result done. Instead the volume states its boundary in the open, keeps every piece of infrastructure below the seam, and closes with an itemized ledger of exactly what it has deferred to Volume III — an honest inheritance rather than a vague promise.
Grigorios writes the NEXUS-1 Companion Series from Edessa, Greece, building each volume as a fully worked, independently verifiable software project rather than a collection of snippets — code that compiles, tests that run, and diagrams drawn from the artifacts themselves rather than from memory.
Author: Grigorios Kyriakos Agathangelidis
Greek name: Γρηγόριος Κυριάκος Αγαθαγγελίδης
Also searchable as: Αγαθαγγελίδης Γρηγόριος, Αγαθαγγελιδης Γρηγοριος, Grigorios Agathangelidis.
Contents
Table of Contents
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
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.