In any software system, business actions are the lifeblood. A User follows another User. A Manager approves a Document. A Customer purchases a Product. These interactions define what your business actually does. But if you were asked to point to the exact code that defines "approve a document"—the single source of truth for its rules, side effects, and history—where would you look?
Is it in a frontend component? A backend API controller? Scattered across three different microservices? A message queue worker?
For most systems, the answer is "all of the above." The logic that constitutes a single business action is often fragmented, duplicated, and buried deep within the implementation details of various services. This creates a system that is brittle, difficult to audit, and incredibly slow to change.
What if we could treat these fundamental business actions not as an afterthought, but as first-class citizens in our codebase? What if we could define, manage, and track the entire lifecycle of any interaction? This is the core principle behind Business-as-Code.
Before we can manage an action, we must first define it. Every business action, no matter how complex, can be broken down into a few core components:
The problem in traditional architectures is that while the Verb is conceptual, the Subject, Object, and especially the Effects are implemented imperatively and scattered across the stack. There is no single, declarative definition.
Verbs.do introduces a simple, powerful idea: define your business operations as declarative, executable objects. Instead of writing scattered business logic, you define a Verb.
Let's take the simple example of a "Follow" action in a social application. With Verbs.do, you define it once, as code:
import { Verb } from 'verbs.do';
// Define a 'Follow' action in your system
const follow = new Verb({
name: 'Follow',
subject: { type: 'User', description: 'The user who is following.' },
object: { type: 'User', description: 'The user being followed.' },
effects: [
{ type: 'createEdge', from: 'subject', to: 'object', label: 'follows' },
{ type: 'notify', user: 'object.id', message: '`{subject.name}` started following you.' }
]
});
// Now, any part of your system can execute this action
await follow.execute({ subjectId: 'user-123', objectId: 'user-456' });
Let's break down why this is a game-changer for tracking an action's lifecycle.
The code block above becomes the single source of truth for what "Follow" means in your system.
By codifying actions into Verbs, you centralize your core business logic. The question "What happens when a user follows another?" is answered instantly by looking at this definition, not by hunting through five different repositories.
Once defined, the action is executed through a simple, unified API: follow.execute().
This single interface can be called from anywhere:
This decouples the "what" (the Verb definition) from the "where" (the execution context). Your frontend doesn't need to know how to create a follow relationship or send a notification; it only needs to know that it wants to execute the Follow Verb.
Here is the key to tracking the full lifecycle. Because every action is defined and executed through a central system, Verbs.do automatically creates a perfect, immutable audit trail for every action performed.
When follow.execute({ subjectId: 'user-123', objectId: 'user-456' }) is called, the system doesn't just perform the effects; it records an event:
[Timestamp] Subject 'user-123' performed Verb 'Follow' on Object 'user-456'.
This makes answering critical business questions trivial:
This level of automatic, built-in auditability is nearly impossible to achieve when business logic is scattered.
The real power emerges when you realize that Verbs are composable building blocks. The effects of one Verb can trigger the execution of another, allowing you to build complex, automated business processes from simple, reusable actions.
Consider an e-commerce Purchase Verb. Its effects could be:
Each step is a discrete, well-defined, and auditable action. This creates powerful agentic workflows where the system itself can orchestrate complex processes based on the outcome of individual Verbs. You're no longer just writing code; you're designing an automated, intelligent business engine.
Your business isn't a random collection of functions and API endpoints. It's a cohesive system of meaningful actions. It's time your codebase reflected that reality.
By defining business actions as code, you gain unparalleled clarity, consistency, and control. You transform your operations from a tangled web of imperative code into a portfolio of manageable, trackable, and composable services.
Ready to translate your business operations into powerful, executable verbs? Define your first business action as code with Verbs.do.