.cursorrules 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # Cursor Rules for Watch Finished Turbo
  2. ## Repository Overview
  3. This is a Turborepo monorepo containing a full-stack video processing system with automatic file watching, HandBrake integration, and a web interface for management.
  4. ## Project Structure
  5. ### Apps (`/apps`)
  6. - **`web/`**: Next.js 14 application with TypeScript, Tailwind CSS
  7. - Real-time dashboard for monitoring video processing
  8. - WebSocket integration for live updates
  9. - Located at `apps/web/`
  10. - **`service/`**: NestJS API server with TypeScript
  11. - REST API endpoints for file management
  12. - WebSocket gateway for real-time events
  13. - SQLite database integration
  14. - Located at `apps/service/`
  15. - **`cli/`**: Node.js command-line interface
  16. - Interactive CLI for system management
  17. - Direct command execution capabilities
  18. - Located at `apps/cli/`
  19. ### Packages (`/packages`)
  20. - **`eslint-config/`**: Shared ESLint configurations
  21. - Base config, Next.js config, React internal config
  22. - Used across all TypeScript projects
  23. - **`typescript-config/`**: Shared TypeScript configurations
  24. - Base config, Next.js config, React library config
  25. - Extended by all TypeScript packages
  26. - **`ui/`**: Shared React components (currently a stub)
  27. - Future shared UI components
  28. - Tailwind CSS integration
  29. ### Data (`/data`)
  30. - SQLite database files
  31. - Schema documentation in `data/README.md`
  32. - Contains processed video metadata, tasks, and settings
  33. ### Documentation (`/docs`)
  34. - `DEVELOPMENT_NOTES.md`: Setup and development guide
  35. - Architecture documentation
  36. - Additional technical documentation
  37. ### Scripts (`/scripts`)
  38. - Build and deployment scripts
  39. - Automation tools
  40. ## Technology Stack
  41. ### Frontend (Web App)
  42. - **Framework**: Next.js 14 with App Router
  43. - **Language**: TypeScript
  44. - **Styling**: Tailwind CSS
  45. - **State Management**: React hooks + WebSocket
  46. - **Testing**: Jest + Playwright
  47. ### Backend (Service)
  48. - **Framework**: NestJS
  49. - **Language**: TypeScript
  50. - **Database**: SQLite with custom service layer
  51. - **WebSocket**: Socket.IO integration
  52. - **Testing**: Jest
  53. ### CLI
  54. - **Runtime**: Node.js
  55. - **Language**: TypeScript
  56. - **Interface**: Commander.js or similar
  57. ### Build & Development
  58. - **Monorepo**: Turborepo
  59. - **Package Manager**: pnpm
  60. - **Linting**: ESLint (shared configs)
  61. - **Type Checking**: TypeScript (shared configs)
  62. - **Container**: Docker + Docker Compose
  63. ## Development Workflow
  64. ### Getting Started
  65. ```bash
  66. pnpm install
  67. pnpm run dev # Starts all services
  68. ```
  69. ### Individual Services
  70. ```bash
  71. pnpm run web # Next.js on :3000
  72. pnpm run service # NestJS on :3001
  73. pnpm run cli # Interactive CLI
  74. ```
  75. ### Key Scripts
  76. - `pnpm run build` - Build all apps
  77. - `pnpm run lint` - Run ESLint
  78. - `pnpm run test` - Run tests
  79. ## Code Organization Principles
  80. ### File Naming
  81. - Use kebab-case for directories (e.g., `file-watcher.service.ts`)
  82. - Use PascalCase for classes and components
  83. - Use camelCase for variables and functions
  84. - Use kebab-case for file names (e.g., `app.controller.ts`)
  85. ### Import Structure
  86. - Relative imports for same-package files
  87. - Absolute imports for cross-package dependencies
  88. - Group imports: Node.js built-ins, external packages, internal packages
  89. ### Database Schema
  90. - SQLite with tables: files, tasks, settings
  91. - Custom service layer for data access
  92. - Migration system for schema updates
  93. ## Architecture Patterns
  94. ### Service Layer Pattern
  95. - Controllers handle HTTP/WebSocket requests
  96. - Services contain business logic
  97. - Database operations abstracted through services
  98. ### Event-Driven Architecture
  99. - WebSocket events for real-time updates
  100. - File system watching triggers processing
  101. - Background task queue for video processing
  102. ### Configuration Management
  103. - Environment-based configuration
  104. - Database-stored settings for datasets
  105. - Shared config packages for consistency
  106. ## Common Development Tasks
  107. ### Adding a New API Endpoint
  108. 1. Add route in controller (`apps/service/src/app.controller.ts`)
  109. 2. Implement business logic in service
  110. 3. Update WebSocket events if needed
  111. 4. Update API documentation
  112. ### Adding a New Web Page
  113. 1. Create page in `apps/web/src/app/`
  114. 2. Add components in appropriate directories
  115. 3. Connect to API endpoints
  116. 4. Update navigation if needed
  117. ### Adding Shared Components
  118. 1. Add to `packages/ui/src/`
  119. 2. Export from `packages/ui/src/index.ts`
  120. 3. Import in consuming apps
  121. ## Testing Strategy
  122. ### Unit Tests
  123. - Service methods and utilities
  124. - Component logic (where applicable)
  125. - Database operations
  126. ### Integration Tests
  127. - API endpoints
  128. - WebSocket connections
  129. - CLI commands
  130. ### E2E Tests
  131. - Full user workflows
  132. - Critical path testing
  133. - Playwright for web interface
  134. ## Deployment
  135. ### Docker
  136. - Multi-stage builds for optimization
  137. - Separate containers for web, service, and database
  138. - Docker Compose for local development
  139. ### Production Considerations
  140. - Environment variable management
  141. - Database backups and migrations
  142. - Monitoring and logging
  143. - CDN for static assets
  144. ## Contributing Guidelines
  145. 1. Follow existing code patterns and naming conventions
  146. 2. Add tests for new functionality
  147. 3. Update documentation for API changes
  148. 4. Use conventional commits
  149. 5. Run full test suite before submitting PRs
  150. ## Troubleshooting
  151. ### Common Issues
  152. - Port conflicts: Check if services are already running
  153. - Database errors: Verify SQLite file permissions
  154. - Build failures: Clear node_modules and reinstall
  155. - WebSocket issues: Check CORS and firewall settings
  156. ### Debug Commands
  157. ```bash
  158. # Check service status
  159. pnpm run service:status
  160. # View logs
  161. pnpm run logs
  162. # Reset database
  163. pnpm run db:reset
  164. ```