In modern software development, we often face a hidden challenge: our most valuable asset, our business logic, is trapped. It's buried deep within monolithic applications, duplicated across microservices, and tightly coupled to the infrastructure it runs on. Changing a simple pricing rule or updating a tax calculation can trigger a cascade of code changes, tests, and redeployments.
What if we could liberate that logic? What if we could define each business rule as an independent, reusable, and versioned component?
That's the mission behind function.do. We're introducing a new way to think about your code: as Atomic Functions that can be composed into powerful, automated services. It's time to turn your business logic into a flexible, scalable API.
Think about a standard e-commerce platform. The logic to calculateOrderTotal might exist in the shopping cart service. But what about the return processing system? Or the financial reporting dashboard? Often, that same logic is rewritten, leading to:
The core principle of function.do is to treat business logic as a first-class citizen. We do this by encapsulating it into atomic functions.
An atomic function is a discrete, single-purpose unit of logic. It does one thing, and it does it well.
Think of them as super-powered Lego bricks for your business. Each brick is simple, but you can build incredibly complex and robust structures by combining them.
With function.do, you define this logic as code using our SDKs. Let's look at how you would encapsulate the calculateOrderTotal logic using TypeScript.
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 };
  }
}
In this example, the OrderCalculator agent contains a single piece of business logic. The @property() decorator exposes calculateOrderTotal as an executable function. Once you deploy this agent to the .do platform, it instantly becomes a secure, scalable Business Logic API endpoint that any authorized service can call.
No more duplicating code. Just call the OrderCalculator function.
The true power of function.do is unlocked when you start composing these atomic functions into composable workflows.
The calculateOrderTotal function is just one brick. An entire order processing workflow might look like this:
Each of these steps is a separate, atomic function.do agent. They are chained together to form a sophisticated, automated service. If you need to change your payment provider, you only update the processPayment function; the rest of the workflow remains untouched. This is agility and resilience by design.
While function.do leverages serverless principles, it's more than just a Function as a Service (FaaS) platform. Standard serverless functions are often just isolated snippets of code. function.do is a platform designed for business composition.
Our functions, or "agents," are natively:
Q: What is a function.do?
A: 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.
Q: How is this different from a standard serverless function?
A: 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.
Q: Can a single function call other functions?
A: 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.
Q: What languages can I use to write my functions?
A: The .do platform supports modern languages like TypeScript and Python, providing robust SDKs that streamline development and help you define your business logic as code quickly and safely.
Stop burying your critical business logic. Extract it, define it as code, and deploy it as a powerful, composable API with function.do.
Ready to unlock infinite possibilities with atomic functions?
Explore our documentation or Sign up for a free account to get started!