Skip to content

Hexagonal Architecture example written in Deno

Notifications You must be signed in to change notification settings

kemicofa/hadeno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

HADeno (WIP)

# Check for available cli commands
deno run --allow-env --allow-read --allow-write src/infrastructure/adapters/primary/cli.ts --help

Hexagonal Architecture with Deno

In Hexagonal Architecture, the applicaiton is split up into multiple layers in an attempt to make each part much more easily testable.

There are 3 main folders:

  • adapters
  • application
  • infrstructure (aka framework)

Adapters

There are two types of adapters (1) primary and (2) secondary.

Primary adapters are for incoming data/inputs. For example, we could have an adapter for HTTP Restful API, or command line interface, or graphql, etc.

Secondary adapters are for outgoing data. For example, we could have an adapter for in memory storage, database storage, or external APIs, etc.

Adapters in general have no understanding of what exists within the application layer. They communicate with the application layer through "ports" (interfaces).

Application

The application layer can be broken down into three more layers

  • features (aka use-cases)
  • domain (aka core or business logic)
  • ports (interfaces)

Features

Features (or use-cases) are like the traditional MVC controllers of Hexagonal Architecture but without any knowledge of what happens on an adapter level.

Features simply call the domain, possibly outbound ports and possibly return a result.

When a primary adapter needs to communicate with the application layer, it always indirectly goes through a feature via a port. Essentially, this means that the port (interface) is implemented by the feature and then injected within the adapter, which accepts a specific interface.

When a feature needs to call a secondary adapter, then the secondary adapter implements the port and is injected into the feature.

Domain

The domain is the location where all the busienss logic exists. The domain should not use complex libraries and should never attempt to access other parts of the application.

Ports

There are two types of port, inbound and outbound ports. Inbound ports, are implemented by the features and allow for the primary adapteres to communicate witht he application. Outbound ports, are implemented by the secondary adapters and allow the features to communicate with the secondary adapters.

About

Hexagonal Architecture example written in Deno

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published