Project Structure
Learn about Motia's project structure, file organization, and automatic step discovery system for building scalable workflow applications.
Project Structure
Understanding how to organize your Motia project is crucial for building maintainable and scalable workflow applications. This guide covers the directory structure, file naming conventions, and Motia's automatic step discovery system.
Basic Project Structure
Here's what a typical Motia project looks like:
File Descriptions
| File | Purpose | Type | Auto-Generated |
|---|---|---|---|
01-api-gateway.step.ts | TypeScript API endpoint | User Code | - |
02-data-processor_step.py | Python data processing | User Code | - |
03-send-notification.step.js | JavaScript automation | User Code | - |
send-notification.tsx | Optional UI override component | User Code | - |
package.json | Node.js dependencies (if using JS/TS) | Config | - |
requirements.txt | Python dependencies (if using Python) | Config | - |
tsconfig.json | TypeScript config (if using TypeScript) | Config | - |
types.d.ts | Type definitions for your project | Generated | ✅ By TypeScript |
motia-workbench.json | 🤖 Visual workflow positioning | Generated | ✅ By Motia |
config.yml | Optional Motia configuration | Config | - |
Flexible Step Discovery
Motia automatically discovers and registers steps from both steps/ and src/ directories. You're not required to use a specific directory structure - organize your code however makes sense for your project!
- Both
steps/andsrc/directories are supported - use whichever fits your team's conventions - Use one or both directories - mix and match based on your preferences
- Recursive discovery - nest steps in subfolders as deeply as you need (e.g.,
steps/api/v1/users.step.ts,src/services/email/send_step.py) - No hierarchy or priority - both directories are treated equally
- Organize freely - structure by feature, language, team, or any pattern that works for you
This means existing projects using steps/ continue to work, while new projects can use src/ or both directories together.
Automatic Step Discovery
Key Concept: Automatic Discovery
Motia automatically discovers and registers any file that follows the .step. naming pattern as a workflow step, regardless of where it's located in your steps/ or src/ directories. No manual registration required - just create a file with the right naming pattern and Motia will find it.
Discovery Rules
Motia scans your project and automatically registers files as steps based on these simple rules:
- File must contain
.step.or_step.in the filename (e.g.,my-task.step.ts,my_task_step.py) - File must export a
configobject defining the step configuration - File must export a
handlerfunction containing the step logic - File extension determines the runtime (
.ts= TypeScript,.py= Python,.js= JavaScript)
When you run motia dev, Motia will:
- Recursively scan both
steps/andsrc/directories (if they exist) - Find all files matching
*.step.*or*_step.*patterns in either directory - Parse their
configexports to understand step types and connections - Register them in the workflow engine
- Make them available in the Workbench
No directory requirement - Steps are discoverable from anywhere within steps/ or src/, regardless of folder depth or organization pattern. Both directories are treated equally with no preference or priority.
File Naming Convention
Motia uses this specific pattern for automatic step discovery:
The .step. part in the filename is required - this is how Motia identifies which files are workflow steps during automatic discovery.
Supported Languages & Extensions
| Language | Extension | Example Step File | Runtime |
|---|---|---|---|
| TypeScript | .ts | user-registration.step.ts | Node.js with TypeScript |
| Python | .py | data-analysis_step.py | Python interpreter |
| JavaScript | .js | send-notification.step.js | Node.js |
Naming Examples by Step Type
| Step Type | TypeScript | Python | JavaScript |
|---|---|---|---|
| API Endpoint | 01-auth-api.step.ts | 01-auth-api_step.py or auth_api_step.py | 01-auth-api.step.js |
| Event Handler | process-order.step.ts | process-order_step.py or process_order_step.py | process-order.step.js |
| Cron Job | daily-report.step.ts | daily-report_step.py or daily_report_step.py | daily-report.step.js |
| Data Processing | transform-data.step.ts | ml-analysis_step.py or ml_analysis_step.py | data-cleanup.step.js |
Step Organization Patterns
All examples below can use either steps/ or src/ as the root directory - choose what works best for your team!
Sequential Flow Organization
Perfect for linear workflows where order matters:
| Step | Language | Purpose |
|---|---|---|
01-api-start.step.ts | TypeScript | API endpoint |
02-validate-data_step.py | Python | Data validation |
03-process-payment.step.js | JavaScript | Payment processing |
04-send-confirmation.step.ts | TypeScript | Email service |
05-cleanup_step.py | Python | Cleanup tasks |
Language-Specific Configuration
TypeScript/JavaScript Projects
For Node.js-based steps, you'll need:
Python Projects
For Python-based steps:
Step Discovery Examples
Let's see how Motia discovers different step types:
Example 1: TypeScript API Step
Example 2: Python Event Step
Example 3: JavaScript Automation Step
Auto-Generated Files
Some files in your Motia project are automatically generated:
types.d.ts- TypeScript generates this for type definitionsmotia-workbench.json- Motia manages visual node positions in the Workbench
Discovery Troubleshooting
If Motia isn't discovering your steps:
Common Issues
Missing .step. (or _step for Python) in filename
❌ Won't be discovered:
✅ Will be discovered:
Discovery Verification
Check if your steps are discovered:
Next Steps
Now that you understand how Motia discovers and organizes steps:
- Learn about Core Concepts to understand how steps work together
- Explore Defining Steps for detailed step creation
- Check out Triggers for API, Event, and Cron steps