|
| 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