liveBook · Manning

Architectural sovereignty

As explained in Grokking Software Architecture

The property of an application core having authority over its business rules without depending on external databases, frameworks, or infrastructure.

Architectural sovereignty means business logic rules its own territory: databases and frameworks do not dictate how the core works. Boundaries between the core and outside systems let other parts change without rewriting that logic. section 5.5.4

A ServerMonitor core can be driven by different adapters:

  • A web API controller calls CheckTemperature(). section 5.5.4
  • An admin CLI uses a ConsoleAdapter for a health check. section 5.5.4
  • A scheduled background job uses a KafkaAdapter to monitor servers. section 5.5.4

Keeping the core independent makes tests fast and deterministic, and contains changes—such as an external API change—within an adapter rather than spreading them into business rules. section 5.5.4

Listing 5.8 “After”: Unit Tests
 
 
// 1. The Fake lives OUTSIDE the test method
class FakeAlertPort : IAlertPort 
{ 
    public List<string> SentMessages { get; } = new List<string>(); 
    public void SendAlert(string message) => SentMessages.Add(message); 
}
 
[TestClass] 
public class ServerMonitorTests 
{
    public void ServerOverheating_SendsAlert_ExactlyOnce()
    {        
        // Arrange: Use a simple "Fake" adapter (just a list!)
        var fakePort = new FakeAlertPort(); 
        var monitor = new ServerMonitor(fakePort);
 
       // Act: Poke the core
        monitor.CheckTemperature(100); #A
 
       // Assert: Verify the OUTCOME, not the implementation
        Assert.AreEqual(1, fakePort.SentMessages.Count); #B
        Assert.IsTrue(fakePort.SentMessages[0].Contains("Take cover!"));
    }
}

A unit test uses a fake alert port to check the outcome of the core’s behavior. section 5.5.4

How Grokking Software Architecture covers it

How deep it goes
Defines the principle and illustrates its effects on testing, maintainability, and changing application drivers.
Examples
Shows a ServerMonitor driven by a web API, admin CLI, or background job, plus a fake alert port in a unit test.
What you can do after
Build business logic that can be driven by different application entry points without changing its core rules.
How it connects
Connects Hexagonal Architecture with application cores, ports and adapters, Dependency Inversion, and layered architecture.

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.