apoorv-2204

apoorv-2204

Design patterns for Hexagonal / Clean Architecture in Elixir (beyond Behaviour + Impl)

I’m experimenting with Hexagonal / Clean Architecture in Elixir. The classic Behaviour + Impl split works great for mocking and isolating IO—here’s a trimmed-down example from our SFTP adapter:

elixir

# Port (Behaviour)
defmodule Core.SFTP.Port do
  @callback connect(map()) :: {:ok, term()} | {:error, term()}
  @callback write(Path.t(), iodata()) :: :ok | {:error, term()}
  @callback disconnect(term()) :: :ok | {:error, term()}
end

# Adapter (Impl)
defmodule Core.SFTP.Live do
  @behaviour Core.SFTP.Port

  @impl true
  def connect(conf),         do: SFTPClient.connect(conf)
  @impl true
  def write(path, data),      do: SFTPClient.write_file(path, data)
  @impl true
  def disconnect(conn),       do: SFTPClient.disconnect(conn)
end

I wanted to know what are architectural patterns in elixir , apart from behaviour and impl pattern

Where Next?

Popular Backend topics Top

New
New
Jsdr3398
I love how elixir works and some of its perks, but I’m still pretty uncomfortable, especially when mix/hex gets involved. Did anyone els...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
mafinar
So I was thinking of trying out Crystal, I had tried it multiple times but left it midway. Now that there’s a book on it and it’s version...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
jaeyson
Sorry for the very vague noob question, I really want to ask this: When do we use async or sync code in the context of Elixir? AFAIK gen...
New
pillaiindu
Cross posting from Elixir Forum. Build it with Phoenix is a nice course by Geoffrey Lessel @geo. But if you start with Phoenix 1.7.2 or ...
New
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New