How many times has this happened to you? You're digging through a microservice that handles user profiles and you find a function for calculating a user's subscription tier. It looks familiar. A week later, you're in the mobile app's backend and you find it again—almost the same, but with a slight variation. Then, you find a third version in a batch-processing job that generates monthly reports.
This is the silent technical debt that cripples development velocity. Scattered, duplicated business logic is a nightmare to maintain, a breeding ground for inconsistencies, and a direct risk to your business. When a rule changes, which "source of truth" do you update? Did you even find them all?
What if you could write that critical logic once, deploy it as a secure and scalable API, and reuse it everywhere? This is the promise of treating your business logic as a composable service, and it's the core philosophy behind function.do.
In modern software architecture, we strive to break down problems into smaller, manageable pieces. But often, the most critical pieces—the business rules—get lost in the shuffle. They are duplicated across monolithic applications, microservices, and serverless functions, leading to several major problems:
The function.do platform proposes a fundamental shift: Stop embedding business logic. Start encapsulating it. We believe your business logic is a valuable asset that should be treated as a first-class citizen—independent, versioned, and reusable.
We call these encapsulated assets Atomic Functions. They are discrete, single-purpose units of logic that do one thing and do it well.
Think of our OrderCalculator example. This is a perfect candidate for an atomic function.
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 };
  }
}
This OrderCalculator has one job. It's clear, testable, and completely self-contained. Once deployed on the .do platform, it becomes a secure, scalable API endpoint—a reusable building block for any application that needs to calculate an order total.
This is where the true power of the platform emerges. Atomic functions are designed for composition. You can build powerful, complex services and automated workflows simply by chaining these simple functions together.
Imagine a complete e-commerce checkout process built with function.do:
Each step in this chain is an independent, atomic function. If your tax logic changes, you only update calculateOrderTotal(). If you switch email providers, you only touch triggerOrderConfirmationEmail(). The rest of the workflow remains unchanged. This is how you build resilient, agile systems.
While built on similar principles, function.do is designed specifically for business composition. Standard FaaS (Function as a Service) platforms are excellent for event-driven computing but don't provide the "connective tissue" needed to treat logic as a reusable service.
function.do provides a true Business Logic API with features that go beyond simple code execution:
It's time to elevate your business logic from a scattered liability to a centralized, powerful asset. By encapsulating your rules into atomic functions and composing them into powerful workflows, you can increase development speed, reduce errors, and build more resilient applications.
Ready to turn your code into a reusable service? Explore the function.do platform and start building your library of atomic, composable business logic today.
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.
What languages can I use to write my functions?
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.