---
description:
globs:
alwaysApply: true
---
# 2. Project Conventions and Rules
This document outlines the specific conventions, file structures, and general rules for this Wasp project.
## Quick Reference
### Common Patterns
- Define app structure in the Wasp config file: [main.wasp](mdc:main.wasp) or `main.wasp.ts`.
- Define data models ("entities") in [schema.prisma](mdc:schema.prisma).
- Group feature code in `src/{featureName}` directories.
- Group feature config definitions (e.g. routes, pages, operations, etc.) into sections within the Wasp config file ([main.wasp](mdc:main.wasp)) using the `//#region` directive:
```wasp
// Example in @main.wasp
// #region {FeatureName}
// ... feature-specific declarations ...
// #endregion
```
- Use Wasp operations (queries/actions) for client-server communication (See [database-operations.mdc](mdc:template/app/.cursor/rules/database-operations.mdc)).
- **Wasp Imports:** Import from `wasp/...` not `@wasp/...` in `.ts`/`.tsx` files.
### Common Issues & Import Rules
- **Wasp Imports in `.ts`/`.tsx`:** Always use the `wasp/...` prefix.
- ✅ `import { Task } from 'wasp/entities'`
- ✅ `import type { GetTasks } from 'wasp/server/operations'`
- ✅ `import { getTasks, useQuery } from 'wasp/client/operations'`
- ❌ `import { ... } from '@wasp/...'`
- ❌ `import { ... } from '@src/featureName/...'` (Use relative paths for non-Wasp imports within `src`)
- If you see "Cannot find module 'wasp/...'": Double-check the import path prefix.
- **Wasp Config Imports in [main.wasp](mdc:main.wasp) :** Imports of your code *must* start with `@src/`.
- ✅ `component: import { LoginPage } from "@src/auth/LoginPage.tsx"`
- ❌ `component: import { LoginPage } from "../src/auth/LoginPage.tsx"`
- ❌ `component: import { LoginPage } from "client/pages/auth/LoginPage.tsx"`
- **General Imports in `.ts`/`.tsx`:** Use relative paths for imports within the `src/` directory. Avoid using the `@src/` alias directly in `.ts`/`.tsx` files.
- If you see "Cannot find module '@src/...'": Use a relative path instead.
- **Prisma Enum *Value* Imports:** Import directly from `@prisma/client`. See [database-operations.mdc](mdc:template/app/.cursor/rules/database-operations.mdc).
- **Wasp Actions Client-Side:** Call actions directly using `async/await`. DO NOT USE the `useAction` hook unless optimistic updates are needed. See [database-operations.mdc](mdc:template/app/.cursor/rules/database-operations.mdc).
- ✅ `import { deleteTask } from 'wasp/client/operations'; await deleteTask({ taskId });`
- Root Component (`src/App.tsx` or similar):
- Ensure the root component defined in @main.wasp (usually via `app.client.rootComponent`) renders the `