Code Deployment
Deploy MDX Functions & Components as Agents, APIs, Apps, Sites, Services, Workflows, and Businesses
Documentation Status: This documentation describes the planned API design for the .do platform. Code examples represent the intended interface and may not reflect the current implementation state. See roadmap for implementation status.
The .do platform enables you to write code once in MDX and deploy it as multiple primitives: Agents, APIs, Apps, Sites, Services, Workflows, and complete Businesses-as-Code.
What are MDX Functions & Components?
MDX (Markdown + JSX) combines the simplicity of Markdown with the power of React components and executable JavaScript/TypeScript. On the .do platform, MDX serves as the universal format for defining both content and logic.
MDX Functions
Functions written in MDX that can contain business logic, AI operations, data transformations, and integrations:
---
title: Calculate Order Total
description: Compute order totals with tax and shipping
---
export function calculateTotal(items, taxRate = 0.08, shipping = 10) {
const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0)
const tax = subtotal * taxRate
return subtotal + tax + shipping
}
export async function processOrder(order) {
// Validate payment
const payment = await $.payment.validate(order.paymentId)
// Calculate total
const total = calculateTotal(order.items)
// Create record
return await $.db.orders.create({
...order,
total,
status: 'processing'
})
}MDX Components
React components defined in MDX that can be used for UI, interactive experiences, and visual representations:
---
title: Product Card
description: Reusable product display component
---
export function ProductCard({ product }) {
return (
<div className="product-card">
<img src={product.image} alt={product.name} />
<h3>{product.name}</h3>
<p className="price">${product.price}</p>
<button onClick={() => $.cart.add(product)}>Add to Cart</button>
</div>
)
}
# Product Showcase
<ProductCard
product={{
name: 'AI Assistant',
price: 29.99,
image: '/assets/product.jpg',
}}
/>Deployment Targets
The .do platform's write once, deploy everywhere philosophy means you can take the same MDX code and deploy it to multiple targets:
Agents
Deploy your MDX functions as autonomous AI agents that can execute tasks, make decisions, and interact with users and systems independently.
Example Use Cases:
- Customer support automation
- Data analysis and reporting
- Content moderation
- Task scheduling and orchestration
APIs
Expose your MDX functions as REST or RPC APIs with automatic documentation, authentication, and rate limiting.
Example Use Cases:
- Public API endpoints
- Internal microservices
- Third-party integrations
- Webhook receivers
Apps
Build interactive web applications combining your MDX components for UI and functions for backend logic.
Example Use Cases:
- SaaS dashboards
- Admin panels
- Customer portals
- Internal tools
Sites
Create static or server-rendered websites with content, components, and dynamic functionality.
Example Use Cases:
- Marketing sites
- Documentation portals
- Blogs and publications
- Landing pages
Services
Package and monetize your MDX code as Services-as-Software with built-in billing and marketplace distribution.
Example Use Cases:
- AI-powered SaaS products
- API-as-a-Service offerings
- Automation services
- Integration platforms
Workflows
Orchestrate complex multi-step processes with durable execution using your MDX functions as workflow steps.
Example Use Cases:
- Order fulfillment
- Content pipelines
- Data processing jobs
- Approval workflows
Businesses-as-Code
Combine all primitives into complete autonomous business operations that run end-to-end.
Example Use Cases:
- Complete e-commerce stores
- SaaS businesses
- Service marketplaces
- Digital agencies
Unified Development Experience
Single Source of Truth
Write your code once in MDX:
---
title: Newsletter Signup
description: Handle newsletter subscriptions
---
export async function subscribeToNewsletter(email) {
// Validate email
if (!isValidEmail(email)) {
throw new Error('Invalid email address')
}
// Add to database
const subscriber = await $.db.subscribers.create({
email,
subscribedAt: new Date(),
status: 'active'
})
// Send welcome email
await $.email.send({
to: email,
subject: 'Welcome to our newsletter!',
template: 'welcome'
})
return subscriber
}
export function NewsletterForm() {
const [email, setEmail] = useState('')
const [status, setStatus] = useState('idle')
async function handleSubmit(e) {
e.preventDefault()
setStatus('loading')
try {
await subscribeToNewsletter(email)
setStatus('success')
} catch (error) {
setStatus('error')
}
}
return (
<form onSubmit={handleSubmit}>
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Enter your email" />
<button type="submit" disabled={status === 'loading'}>
{status === 'loading' ? 'Subscribing...' : 'Subscribe'}
</button>
{status === 'success' && <p>Thanks for subscribing!</p>}
{status === 'error' && <p>Error subscribing. Please try again.</p>}
</form>
) }Deploy Everywhere
Then deploy the same code to multiple targets:
// As an API endpoint
app.post('/api/newsletter/subscribe', async (c) => {
const { email } = await c.req.json()
const result = await subscribeToNewsletter(email)
return c.json(result)
})
// As part of a website
export default function NewsletterPage() {
return (
<div>
<h1>Join Our Newsletter</h1>
<NewsletterForm />
</div>
)
}
// As an agent capability
export const newsletterAgent = $.agent({
name: 'Newsletter Manager',
capabilities: {
subscribeToNewsletter
}
})
// As a workflow step
export const onboardingWorkflow = $.workflow('onboarding', async (user) => {
await $.step('newsletter', () =>
subscribeToNewsletter(user.email)
)
})Build and Deployment Process
See Build Process for detailed information on:
- Local development workflow
- Build and bundling
- Deployment pipelines
- Environment configuration
- Testing strategies
Configuration Options
See Configuration for comprehensive documentation on:
- Project structure
- Build configuration
- Deployment settings
- Environment variables
- Performance optimization
Examples
See Examples for complete working examples of:
- Simple function deployments
- Full-stack applications
- Multi-target deployments
- Complex business logic
- Integration patterns
Semantic Patterns
All MDX functions follow the .do semantic patterns using $.Subject.predicate.Object:
// ✅ Correct semantic patterns
await $.user.create.account({ email, password })
await $.email.send.message({ to, subject, body })
await $.db.products.find.byCategory({ category: 'electronics' })
await $.ai.generate.text({ prompt, context })
// ❌ Incorrect - not semantic
await $.createUser({ email, password })
await $.sendEmail({ to, subject, body })
await $.findProducts({ category: 'electronics' })Related Documentation
- MDX - MDX ecosystem and capabilities
- Functions - Function types and composition
- SDK - .do SDK reference
- API - API development and deployment