Data / External Systems

The layer where the databases, caches, legacy systems, and external providers that sustain or complement the system's operation live.

What this layer includes

  • Relational databases
  • NoSQL databases
  • Caches such as Redis
  • Legacy systems
  • Third-party APIs
  • External services for payments, email, or ERP

Database per service

In microservice architectures, the recommended approach is for each service to control its own persistence.

This doesn’t necessarily mean a separate physical database in every case, but it does mean clear ownership and access boundaries.

Relational vs document

Relational

Useful when you need integrity, joins, strong consistency, and clear transactional structures.

Document

Useful when the model is more flexible or when the query pattern favors aggregate documents.

The choice should follow the domain, not just technological trends.

Redis and caching

Redis can be used for:

  • caching responses
  • sessions
  • throttling
  • simple queues in certain contexts

The cache is not the source of truth; it’s an optimization.

External systems

Not everything is within our control.

We have to coexist with:

  • ERP
  • payment gateways
  • email services
  • logistics providers
  • legacy platforms

That’s why the architecture needs to account for adapters, fault tolerance, and model translation.

Summary

This layer brings together persistence and external systems. It’s essential to understand that critical dependencies live here, but not the core domain logic.