Skip to content

abchau/architecture-by-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Architecture By Examples

This repository demonstrates different architectures of the same simple use case.

Use case

The application has

  • one external endpoint

  • one use case

  • one aggregate

    • one entity

    • two value objects

  • one database table

use case
Figure 1. A single subscription use case
Database table
CREATE TABLE IF NOT EXISTS subscriptions (
	id BINARY(36) PRIMARY KEY,
	email VARCHAR(512) NOT NULL,
	status VARCHAR(256) NOT NULL,
	created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
	version BIGINT NOT NULL
);

Usage

Requires

  • Java 21

Build

  • Import in your favourite IDE

  • Start each project as a spring boot application individually or run ./mvnw spring-boot:run

Testing

Architectures

# Name Architecture Summary Pros Cons

1

anarchy

Anarchy Architecture

Everything is completely wrong

Job Security

Chaotic Mess

2

layered

Layered Architecture

Traditional 3-layer architecture

Simple

Poor package naming by technical functions

2

layered-ddd-1

Minimal DDD Architecture

Small Improvement of Layered Architecture

Simple

No "Modeling"

3

layered-ddd-2

DDD Architecture

More Improvement of Layered Architecture

Clear boundary

Extra complexity

5

layered-hex

Hexagonal Architecture (Ports and Adapters)

More Improvement of Layered Architecture

Clear boundary

Extra complexity

7

fn

Functional Domain Driven Design

Implement DDD using Clojure

Functional

Difficult to get start