Skip to content

Instantly share code, notes, and snippets.

View alexshagov's full-sized avatar
💭
I may be slow to respond.

Alexander Shagov alexshagov

💭
I may be slow to respond.
View GitHub Profile

The "IO to the Boundary" principle

In software architecture, many principles and patterns have emerged over time. However, a lot of these can be boiled down to a single idea: the "IO to the Boundary" principle. This principle suggests that all input/output operations, like database queries, API calls, or file system interactions, should be pushed to the edges (or boundaries) of your application.

Let's look at what some other ideas tell us:

  • Functional Core, Imperative Shell: This principle suggests keeping the core of your application pure and functional, while handling side effects (IO) in an outer layer. This is basically another way of saying "IO to the Boundary."
  • Clean Architecture: Proposed by Robert C. Martin, this architecture emphasizes separating concerns and having dependencies point inwards, which fits with keeping IO at the edges.
  • Command Query Responsibility Segregation (CQRS): While not mainly about IO boundaries, CQRS often leads to separating read and write operations. This separ
@alexshagov
alexshagov / why_nix_on_macos.md
Last active September 23, 2024 11:28
Why Use Nix package manager, Even on macOS?

Why Use Nix package manager, Even on macOS?

Some time ago I wrote a short article on nix first steps (https://dev.to/alexander_shagov/nix-first-steps-4066). However, I realized that I need one more to quickly explain why generally prefer nix over non-nix setups. So here it is.


As a macOS user, you might wonder why you should consider using Nix (package manager) when you already have package managers like Homebrew.

⭐️ One of the most significant advantages of Nix is its ability to create reproducible environments. This means you can:

  • Easily share your exact development setup with teammates.
@alexshagov
alexshagov / service_layer_is_a_lie.md
Last active January 15, 2025 10:00
Ruby on Rails: Your Service Layer is a Lie

Ruby on Rails: Your Service Layer is a Lie

If you're a Rails developer, you've probably seen (or written) code that looks like this:

class UserService
  def self.create(params)
    user = User.new(params)
    if user.save
 UserMailer.welcome_email(user).deliver_later
@alexshagov
alexshagov / deep-research-locally-nix.md
Last active April 28, 2025 16:00
Configuring your own deep research tool (Using Nix Flakes)

So, you've come across deep search tools and are wondering if you can build your own. Well, you certainly can! Building one yourself might involve tasks like scraping web URLs, implementing your own RAG (Retrieval-Augmented Generation) system to find relevant information, and then summarizing it using an agent loop.

Luckily, the open-source community has already created tools that handle many of these steps. The purpose of this article is to demonstrate how easily we can spin up the necessary environment for such a tool using Nix. We'll focus not only on running the service, but also on development environment setup, making it easy to modify the tool if needed.

For demonstration purposes, I'll be using the gpt-researcher tool. Github link: https://github.com/assafelovic/gpt-researcher

The basic setup for almost any Python project often feels trivial: install Python, install requirements.txt, and you're good to go. However, if you manage tens of these projects on your machine, you'll quickly realize

@alexshagov
alexshagov / llm-tdd.md
Created May 15, 2025 13:04
How LLM users accidentally do TDD without realizing it

How LLM users accidentally do TDD without realizing it

Most developers using LLM tools today are unknowingly following a loose version of test-driven development (TDD).

1. TDD and LLM prompting work surprisingly similar

a) Start with failure

  • TDD: You define an interface and write a failing test first. Now you know what needs fixing.
  • LLMs: You write a vague prompt, get bad results, and think "I need to explain this better." Same basic concept.