diff --git a/docs/content/docs/learn/concepts/orchestration-drivers.mdx b/docs/content/docs/learn/concepts/orchestration-drivers.mdx index 737fd69..0f6254f 100644 --- a/docs/content/docs/learn/concepts/orchestration-drivers.mdx +++ b/docs/content/docs/learn/concepts/orchestration-drivers.mdx @@ -12,6 +12,20 @@ The same workflow code works across all drivers. Only the client initialization ## Available Drivers +### Inngest Driver + +Production-grade orchestration on the Inngest platform. Handles event-driven triggers, observability, retries, and deployment at scale. **Recommended for production.** + +```typescript +import { InngestClient } from "@stepkit/inngest"; + +const client = new InngestClient({ id: "my-app" }); +``` + +**Use for:** Production deployments, event-driven workflows, team collaboration + +[Inngest Driver Guide →](/docs/learn/driver-guides/inngest-driver) + ### In-Memory Driver Runs workflows entirely in memory with no persistence. Perfect for **testing and development** when you need fast iteration without files or databases. @@ -40,24 +54,10 @@ const client = new FileSystemClient({ baseDir: "./.stepkit" }); [Filesystem Driver Guide →](/docs/learn/driver-guides/filesystem-driver) -### Inngest Driver - -Production-grade orchestration on the Inngest platform. Handles event-driven triggers, observability, retries, and deployment at scale. **Recommended for production.** - -```typescript -import { Client } from "@stepkit/inngest"; - -const client = new Client({ id: "my-app" }); -``` - -**Use for:** Production deployments, event-driven workflows, team collaboration - -[Inngest Driver Guide →](/docs/learn/driver-guides/inngest-driver) - ## Choosing a driver -- **Building and testing?** Start with In-Memory or Filesystem -- **Deploying to production?** Use Inngest +- **Getting started?** Use Inngest for the best development experience and production deployment +- **Building and testing?** In-Memory or Filesystem work great for local iteration - **Need event triggers or long-running workflows?** Use Inngest The driver is just infrastructure. Your workflow code stays the same. \ No newline at end of file diff --git a/docs/content/docs/learn/driver-guides/file-system-driver.mdx b/docs/content/docs/learn/driver-guides/file-system-driver.mdx index 36e75a8..336fbc7 100644 --- a/docs/content/docs/learn/driver-guides/file-system-driver.mdx +++ b/docs/content/docs/learn/driver-guides/file-system-driver.mdx @@ -80,6 +80,5 @@ client.stop(); ## Related -- [In-Memory Driver](/docs/learn/driver-guides/in-memory-driver) - For testing without persistence -- [Inngest Driver](/docs/learn/driver-guides/inngest-driver) - For production deployments - +- [Inngest Driver](/docs/learn/driver-guides/inngest-driver) - For local development with observability and production deployments +- [In-Memory Driver](/docs/learn/driver-guides/in-memory-driver) - For CLI tools and automated testing \ No newline at end of file diff --git a/docs/content/docs/learn/driver-guides/in-memory-driver.mdx b/docs/content/docs/learn/driver-guides/in-memory-driver.mdx index 7585363..b8f706e 100644 --- a/docs/content/docs/learn/driver-guides/in-memory-driver.mdx +++ b/docs/content/docs/learn/driver-guides/in-memory-driver.mdx @@ -4,7 +4,7 @@ title: In-Memory Driver The In-Memory driver runs workflows in memory. No persistence. When the process stops, workflow state disappears. -Best for: Testing, development, and rapid prototyping. +Best for: CLI tools, automated testing, and environments where you don't need observability or a UI. ## Installation diff --git a/docs/content/docs/learn/quick-start.mdx b/docs/content/docs/learn/quick-start.mdx index 14dd71d..88356da 100644 --- a/docs/content/docs/learn/quick-start.mdx +++ b/docs/content/docs/learn/quick-start.mdx @@ -11,22 +11,22 @@ This guide will walk you through getting started with StepKit to build and deplo ## Installation -Install StepKit's core package along with a driver. For this guide, we'll use the [in-memory driver](/docs/learn/driver-guides/in-memory-driver), which is perfect for development and testing. +Install the StepKit Inngest driver. The Inngest driver gives you the best local development experience with built-in observability through the Inngest Dev Server. ```bash tab="npm" -npm install @stepkit/core @stepkit/local +npm install @stepkit/inngest inngest ``` ```bash tab="pnpm" -pnpm add @stepkit/core @stepkit/local +pnpm add @stepkit/inngest inngest ``` ```bash tab="bun" -bun add @stepkit/core @stepkit/local +bun add @stepkit/inngest inngest ``` ```bash tab="yarn" -yarn add @stepkit/core @stepkit/local +yarn add @stepkit/inngest inngest ``` --- @@ -36,9 +36,11 @@ yarn add @stepkit/core @stepkit/local Create a file to initialize your StepKit client, which will be used to create workflows. ```typescript title="client.ts" -import { InMemoryClient } from "@stepkit/local"; +import { InngestClient } from "@stepkit/inngest"; -export const client = new InMemoryClient(); +export const client = new InngestClient({ + id: "my-app", +}); ``` --- @@ -72,47 +74,47 @@ export const processOrder = client.workflow( async ({ input }, step) => { // Step 1: Reserve inventory const inventory = await step.run("reserve-inventory", async () => { - console.log(`Reserving items: ${ctx.input.items.join(", ")}`); + console.log(`Reserving items: ${input.data.items.join(", ")}`); // Simulate inventory check - const available = ctx.input.items.every(() => Math.random() > 0.1); + const available = input.data.items.every(() => Math.random() > 0.1); if (!available) { throw new Error("Item out of stock - will retry"); } - return { reserved: true, items: ctx.input.items }; + return { reserved: true, items: input.data.items }; }); // Step 2: Process payment const payment = await step.run("process-payment", async () => { - console.log(`Processing payment of $${ctx.input.amount}`); + console.log(`Processing payment of $${input.data.amount}`); // Simulate payment processing const paymentId = crypto.randomUUID(); return { id: paymentId, - amount: ctx.input.amount, + amount: input.data.amount, status: "completed", }; }); // Step 3: Wait 30 seconds before confirmation // This doesn't consume any resources while waiting! - await step.sleep("wait-before-confirm", 30000); + await step.sleep("wait-before-confirm", 7000); // Step 4: Send confirmation email await step.run("send-confirmation", async () => { - console.log(`Sending order confirmation to ${ctx.input.email}`); - console.log(`Order ${ctx.input.orderId} completed!`); + console.log(`Sending order confirmation to ${input.data.email}`); + console.log(`Order ${input.data.orderId} completed!`); return { emailSent: true }; }); // Return the final result return { - orderId: ctx.input.orderId, + orderId: input.data.orderId, paymentId: payment.id, status: "completed", items: inventory.items, @@ -140,76 +142,87 @@ export const processOrder = client.workflow( Now let's invoke the workflow. Create a file to test it: ```typescript title="main.ts" +import express from "express"; +import { serve } from "inngest/express"; +import { inngestify } from "@stepkit/inngest"; import { client } from "./client"; import { processOrder } from "./workflows/process-order"; -async function main() { - console.log("Starting order processing workflow...\n"); +const app = express(); +app.use(express.json()); - const result = await client.startWorkflow(processOrder, { - orderId: "ORDER-123", - items: ["laptop", "mouse", "keyboard"], - email: "customer@example.com", - amount: 1299.99, - }); +// Mount Inngest endpoint +app.use("/api/inngest", serve(inngestify(client, [processOrder]))); - console.log("\nāœ… Workflow completed!"); - console.log("Result:", result); -} +const PORT = 3000; -void main(); +app.listen(PORT, () => { + console.log(`šŸš€ Server running on http://localhost:${PORT}`); + console.log(`šŸ” Inngest endpoint at http://localhost:${PORT}/api/inngest`); +}); ``` -Run it with: +--- + +## Run the Inngest Dev Server + +The Inngest Dev Server provides a local UI for testing, debugging, and observing your workflows. + +In one terminal, start your server: ```bash npx tsx main.ts -# or if using Node.js directly -node --loader ts-node/esm main.ts ``` -You'll see each step execute in sequence, with a 30-second pause before the confirmation step. +In a second terminal, start the Inngest Dev Server by running: ---- +```bash +npx inngest-cli@latest dev -u http://localhost:3000/api/inngest +``` -## Using in Your Application +Open [http://localhost:8288](http://localhost:8288) to see the Dev Server UI. -StepKit workflows can also be integrated into your application's back-end (ex: API): +--- -### API Endpoint (Express) +## Testing with the Inngest Dev Server -```typescript title="routes/orders.ts" -import express from "express"; -import { client } from "./client"; -import { processOrder } from "./workflows/process-order"; +