liveBook · Manning

Application core

As explained in Grokking Software Architecture

The application core is the central part of a software system that contains its essential business logic while remaining isolated from external technical concerns.

The application core is the part of a system that holds its business entities and rules. Think of it as a clean room: the important work happens inside, while databases, user interfaces, APIs, and frameworks stay outside. section 5.2.2 section 5.2.3

A layered system can leave business logic anchored to a database. Hexagonal architecture changes the question from “What sits on top?” to “What belongs inside?” The core defines interfaces called ports; outside adapters connect technologies to those ports. Dependencies point inward: adapters know the core, but the core does not depend on them. section 5.1 section 5.11

Requests and results can cross the boundary in both directions:

  • A driving adapter, such as an HTTP controller, translates a request and calls a primary port to start an action in the core. section 5.3.3
  • The core calls a driven port when it needs something done; an adapter implements that interface and handles the technology, such as saving an order with SQL. section 5.3.3 section 5.4.1

Data may flow outward while the dependency still points inward: the database adapter references the core’s interface, not the other way around. This allows an adapter to be replaced without changing the business logic, as long as the replacement honors the port. section 5.3.3 section 5.3.4

A server monitor with interchangeable alerts

A server monitor keeps its logic in the core and defines an alert port. Console, Twilio, and Kafka adapters provide different ways to send alerts. A fake adapter can collect messages in a list, letting a test check that an overheating server sends one alert without contacting an external service. section 5.5.3 section 5.5.4

/5.4-Port-Adapter-Example/After/
│
├── /Core/                       <-- THE INSIDE (Pure Business Logic)
│   ├── /Domain/
│   │   └── ServerMonitor.cs     # The Logic (The "Clean Room")
│   │
│   └── /Ports/                  <-- THE BOUNDARY
│       └── IAlertPort.cs               # The Interface (The Contract)
│
├── /Infrastructure/          <-- THE OUTSIDE (The Tech Stack)
│   ├── /Adapters/
│   │   ├── ConsoleAdapter.cs     # Implements IAlertPort
│   │   ├── TwilioAdapter.cs        # Implements IAlertPort
│   │   └── KafkaAlertAdapter.cs # Implements IAlertPort
│   │
│   └── /ExternalLibs/                # (3rd Party SDKs live here)
│       ├── FakeTwilioClient.cs
│       └── FakeKafkaTypes.cs
│
├── Program.cs                        # Composition Root (The Wiring)
└── After.csproj

See how the project places domain logic and ports inside the core while grouping adapters under infrastructure. section 5.5.3

Keep the boundary clean: a port that exposes SQL types leaks infrastructure into the core, while business rules placed in a controller or repository leak logic out. Design ports around what the application needs to do, and keep adapters focused on translation. section 5.3.5

How Grokking Software Architecture covers it

How deep it goes
Explains inward dependencies, driving and driven adapters, project organization, tests, and boundary pitfalls through a worked design.
Examples
Illustrates a server monitor with interchangeable alert adapters and a fake that records messages for a test.
What you can do after
Diagnose leaky ports and misplaced business rules, and test core behavior with a fake adapter.
How it connects
Connects the core to ports and adapters, dependency inversion, layered architecture, and separation of concerns.

Also explained in

Compare how 2 books explain application core →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.