Skip to content

Commit 275e6ba

Browse files
authored
feat: create multi language starter (#1011)
1 parent f5be430 commit 275e6ba

File tree

23 files changed

+337
-45
lines changed

23 files changed

+337
-45
lines changed

packages/docs/content/docs/api-reference.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,11 +1346,12 @@ npx motia create --template motia-tutorial-python my-python-app
13461346

13471347
| Template | Description | Use Case |
13481348
|----------|-------------|----------|
1349-
| `starter-typescript` | Starter (TypeScript) | Minimal TypeScript project with basic examples |
1350-
| `starter-javascript` | Starter (JavaScript) | Minimal JavaScript project with basic examples |
1351-
| `starter-python` | Starter (Python) | Minimal Python project with basic examples |
1352-
| `motia-tutorial-typescript` | Tutorial (TypeScript) | Interactive tutorial project in TypeScript |
1353-
| `motia-tutorial-python` | Tutorial (Python) | Interactive tutorial project in Python |
1349+
| `motia-tutorial-typescript` | Tutorial (TypeScript only) | Interactive tutorial project in TypeScript |
1350+
| `motia-tutorial-python` | Tutorial (Python only) | Interactive tutorial project in Python |
1351+
| `starter-multilang` | Starter (All languages; TS/JS + Python) | Polyglot project with TypeScript API, Python event processing, and JavaScript logging |
1352+
| `starter-typescript` | Starter (TypeScript only) | Minimal TypeScript project with basic examples |
1353+
| `starter-javascript` | Starter (JavaScript only) | Minimal JavaScript project with basic examples |
1354+
| `starter-python` | Starter (Python only) | Minimal Python project with basic examples |
13541355

13551356
- `-c, --cursor` - Add Cursor IDE rules
13561357

packages/docs/content/docs/development-guide/cli.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ Motia provides several project templates to help you get started quickly:
3838

3939
| Template | Description | Use Case |
4040
|----------|-------------|----------|
41-
| `starter-typescript` | Starter (TypeScript) | Minimal TypeScript project with basic examples |
42-
| `starter-javascript` | Starter (JavaScript) | Minimal JavaScript project with basic examples |
43-
| `starter-python` | Starter (Python) | Minimal Python project with basic examples |
44-
| `motia-tutorial-typescript` | Tutorial (TypeScript) | Interactive tutorial project in TypeScript |
45-
| `motia-tutorial-python` | Tutorial (Python) | Interactive tutorial project in Python |
41+
| `motia-tutorial-typescript` | Tutorial (TypeScript only) | Interactive tutorial project in TypeScript |
42+
| `motia-tutorial-python` | Tutorial (Python only) | Interactive tutorial project in Python |
43+
| `starter-multilang` | Starter (All languages; TS/JS + Python) | Polyglot project with TypeScript API, Python event processing, and JavaScript logging |
44+
| `starter-typescript` | Starter (TypeScript only) | Minimal TypeScript project with basic examples |
45+
| `starter-javascript` | Starter (JavaScript only) | Minimal JavaScript project with basic examples |
46+
| `starter-python` | Starter (Python only) | Minimal Python project with basic examples |
4647

4748
**Examples:**
4849

packages/docs/content/docs/getting-started/quick-start.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ The installer will guide you through a few questions to set up your project, inc
2121
If you already know which template you want, you can skip the interactive prompts:
2222

2323
```bash
24-
# TypeScript starter
24+
# All languages (TypeScript/JavaScript + Python)
25+
npx motia@latest create my-app --template starter-multilang
26+
27+
# TypeScript only
2528
npx motia@latest create my-app --template starter-typescript
2629

27-
# JavaScript starter
30+
# JavaScript only
2831
npx motia@latest create my-app --template starter-javascript
2932

30-
# Python starter
33+
# Python only
3134
npx motia@latest create my-app --template starter-python
3235
```
3336

packages/snap/src/create/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export const create = async ({ projectName, template, cursorEnabled, context }:
226226
if (!isPluginTemplate) {
227227
packageManager = await installNodeDependencies(rootDir, context)
228228

229-
if (template.includes('python')) {
229+
if (template.includes('python') || template.includes('multilang')) {
230230
await pythonInstall({ baseDir: rootDir })
231231
}
232232

packages/snap/src/create/interactive.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ interface InteractiveAnswers {
99
}
1010

1111
const choices: Record<string, string> = {
12-
'motia-tutorial-typescript': 'Tutorial (TypeScript)',
13-
'motia-tutorial-python': 'Tutorial (Python)',
14-
'starter-typescript': 'Starter (TypeScript)',
15-
'starter-javascript': 'Starter (JavaScript)',
16-
'starter-python': 'Starter (Python)',
12+
'motia-tutorial-typescript': 'Tutorial (TypeScript only)',
13+
'motia-tutorial-python': 'Tutorial (Python only)',
14+
'starter-multilang': 'Starter (All languages; TS/JS + Python)',
15+
'starter-typescript': 'Starter (TypeScript only)',
16+
'starter-javascript': 'Starter (JavaScript only)',
17+
'starter-python': 'Starter (Python only)',
1718
}
1819

1920
interface CreateInteractiveArgs {

packages/snap/src/create/templates/hello/README.md.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,4 @@ Steps are auto-discovered from your `steps/` or `src/` directories - no manual r
8080
- [Documentation](https://motia.dev/docs) - Complete guides and API reference
8181
- [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
8282
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
83-
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
84-
83+
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers

packages/snap/src/create/templates/hello_js/README.md.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,4 @@ Steps are auto-discovered from your `steps/` or `src/` directories - no manual r
8080
- [Documentation](https://motia.dev/docs) - Complete guides and API reference
8181
- [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
8282
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
83-
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
84-
83+
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers

packages/snap/src/create/templates/hello_js/steps/hello/hello-api.step.js.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { z } = require('zod');
1+
import { z } from 'zod';
22

3-
const config = {
3+
export const config = {
44
name: 'HelloAPI',
55
type: 'api',
66
path: '/hello',
@@ -17,7 +17,7 @@ const config = {
1717
}
1818
};
1919

20-
const handler = async (_, { emit, logger }) => {
20+
export const handler = async (_, { emit, logger }) => {
2121
const appName = process.env.APP_NAME || 'Motia App';
2222
const timestamp = new Date().toISOString();
2323

@@ -43,5 +43,3 @@ const handler = async (_, { emit, logger }) => {
4343
}
4444
};
4545
};
46-
47-
module.exports = { config, handler };

packages/snap/src/create/templates/hello_js/steps/hello/process-greeting.step.js.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { z } = require('zod');
1+
import { z } from 'zod';
22

33
const inputSchema = z.object({
44
timestamp: z.string(),
@@ -7,7 +7,7 @@ const inputSchema = z.object({
77
requestId: z.string()
88
});
99

10-
const config = {
10+
export const config = {
1111
name: 'ProcessGreeting',
1212
type: 'event',
1313
description: 'Processes greeting in the background',
@@ -17,7 +17,7 @@ const config = {
1717
input: inputSchema
1818
};
1919

20-
const handler = async (input, { logger, state }) => {
20+
export const handler = async (input, { logger, state }) => {
2121
const { timestamp, appName, greetingPrefix, requestId } = input;
2222

2323
logger.info('Processing greeting', { requestId, appName });
@@ -38,5 +38,3 @@ const handler = async (input, { logger, state }) => {
3838
storedInState: true
3939
});
4040
};
41-
42-
module.exports = { config, handler };
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# {{PROJECT_NAME}}
2+
3+
A Motia project created with the **multi-language** starter template (TypeScript + Python).
4+
5+
## What is Motia?
6+
7+
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
8+
9+
## Polyglot Architecture
10+
11+
This template demonstrates Motia's polyglot capabilities by combining:
12+
13+
- **TypeScript**: API endpoint (`hello-api.step.ts`) - handles HTTP requests
14+
- **Python**: Event processor (`process_greeting_step.py`) - handles background processing
15+
- **JavaScript**: Logger (`log-greeting.step.js`) - handles workflow completion
16+
17+
This shows how you can use the best language for each task while keeping everything in a single unified system.
18+
19+
## Quick Start
20+
21+
```bash
22+
# Start the development server
23+
npm run dev
24+
# or
25+
yarn dev
26+
# or
27+
pnpm dev
28+
```
29+
30+
This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
31+
32+
```bash
33+
# Test your first endpoint
34+
curl http://localhost:3000/hello
35+
```
36+
37+
## How It Works
38+
39+
1. **TypeScript API Step** receives the HTTP request at `/hello`
40+
2. It emits a `process-greeting` event with the request data
41+
3. **Python Event Step** picks up the event, processes it, and stores the result in state
42+
4. Python emits a `greeting-processed` event
43+
5. **JavaScript Event Step** logs the completed workflow
44+
45+
## Step Types
46+
47+
Every Step has a `type` that defines how it triggers:
48+
49+
| Type | When it runs | Use case |
50+
|------|--------------|----------|
51+
| **`api`** | HTTP request | REST APIs, webhooks |
52+
| **`event`** | Event emitted | Background jobs, workflows |
53+
| **`cron`** | Schedule | Cleanup, reports, reminders |
54+
55+
## Development Commands
56+
57+
```bash
58+
# Start Workbench and development server
59+
npm run dev
60+
# or
61+
yarn dev
62+
# or
63+
pnpm dev
64+
65+
# Start production server (without hot reload)
66+
npm run start
67+
# or
68+
yarn start
69+
# or
70+
pnpm start
71+
72+
# Generate TypeScript types from Step configs
73+
npm run generate-types
74+
# or
75+
yarn generate-types
76+
# or
77+
pnpm generate-types
78+
79+
# Build project for deployment
80+
npm run build
81+
# or
82+
yarn build
83+
# or
84+
pnpm build
85+
```
86+
87+
## Project Structure
88+
89+
```
90+
steps/ # Your Step definitions
91+
├── hello/
92+
│ ├── hello-api.step.ts # TypeScript API endpoint
93+
│ ├── process_greeting_step.py # Python event processor
94+
│ └── log-greeting.step.js # JavaScript logger
95+
motia.config.ts # Motia configuration
96+
requirements.txt # Python dependencies
97+
```
98+
99+
Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
100+
101+
## Learn More
102+
103+
- [Documentation](https://motia.dev/docs) - Complete guides and API reference
104+
- [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
105+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
106+
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers

0 commit comments

Comments
 (0)