In modern software development, we spend a lot of time talking about architecture—microservices, serverless, monoliths vs. distributed systems. But what about the heart of it all? The core business logic that dictates how your company actually operates? Too often, this critical logic is scattered, duplicated, and tangled within various applications, becoming a liability rather than an asset.
What if we could change that? What if we could treat each piece of business logic not as a mere implementation detail, but as a discoverable, reusable, and composable "first-class citizen"?
At function.do, we call this the Agent Model. It’s a paradigm shift that transforms your business logic from scattered code into atomic, powerful services.
Think about a common piece of business logic, like calculating the total for an order. Where does that code live in your organization?
When a business rule changes—like a new tax policy or a discount structure—your developers have to hunt down and update every single instance. This is not just inefficient; it's a recipe for inconsistency and bugs. This is the symptom of treating business logic as a second-class citizen, an afterthought embedded deep within larger systems.
The function.do platform introduces the concept of an Agent. An Agent is an atomic, single-purpose piece of business logic, deployed as an independent, executable entity.
Think of it as encapsulating a single business capability and exposing it as a simple API. Instead of being a private function inside a large application, it becomes a public, versioned, and reusable building block for your entire organization.
This elevation to a "first-class citizen" means that each piece of logic is:
Let's see how this works in practice. Imagine you need to implement the order total calculation. With function.do, you define this logic as a simple class.
import { Agent, property } from '@do-sdk/core';
// Define the structure for a line item in an order
interface LineItem {
  productId: string;
  quantity: number;
  unitPrice: number;
}
// Create an agent that encapsulates the 'calculateOrderTotal' function
export class OrderCalculator extends Agent {
  
  @property()
  async calculateOrderTotal(
    items: LineItem[], 
    taxRate: number
  ): Promise<{ subtotal: number; tax: number; total: number }> {
    
    // Calculate the subtotal from the items
    const subtotal = items.reduce(
      (acc, item) => acc + item.quantity * item.unitPrice, 0
    );
    // Calculate tax and the final total
    const tax = subtotal * taxRate;
    const total = subtotal + tax;
    // Return the detailed breakdown
    return { subtotal, tax, total };
  }
}
On its own, this is clean, testable TypeScript code. But once deployed to the .do platform, it becomes something more. The OrderCalculator class is now an Agent, and its calculateOrderTotal method is an action that can be invoked via a secure API endpoint.
Now, your e-commerce site, backend services, and reporting tools don't need to implement this logic themselves. They simply call the OrderCalculator Agent. When the tax logic changes, you update it in one place, and every system that uses it is instantly updated.
You might be thinking, "This sounds a bit like a serverless function." While the underlying technology shares principles with FaaS (Function as a Service), the Agent Model is designed for a higher purpose: business composition.
Standard serverless functions are often focused on infrastructure—reacting to events like file uploads or database changes. The function.do Agent Model is focused on orchestrating business value.
The true power is unlocked when you start composing these atomic functions. An entire "Order Fulfillment" process can be built by chaining Agents together in a workflow:
Each step is a distinct, reusable, and independently maintainable Agent. This creates a Composable Workflow that is resilient, easy to understand, and incredibly simple to modify.
The Agent Model isn't just a technical pattern; it's a strategic advantage. It allows you to build faster, reduce technical debt, and ensure business consistency across your entire digital ecosystem. By elevating your core logic to a first-class citizen, you unlock its true potential as a valuable, reusable asset.
Ready to stop duplicating code and start composing powerful services?
Get started with function.do and deploy your first Agent in minutes.
What is a function.do?
A function.do represents an atomic, single-purpose piece of business logic deployed as an independent, executable agent on the .do platform. Think of it as a reusable building block for your automated workflows and services.
How is this different from a standard serverless function?
While similar in principle, function.do agents are designed for business composition. They are natively discoverable, versioned, and billable within the .do ecosystem, allowing you to treat business logic as a composable Service-as-Software, not just isolated code.
Can a single function call other functions?
Yes. The power of the .do platform lies in its composability. Any function can easily invoke other functions, allowing you to build complex service chains from simple, atomic units of logic.