OpenPreview OpenPreview .cursorrules file for TypeScript

<project_description>
OpenPreview is an innovative open-source toolkit designed to revolutionize the development process, enhance team collaboration, and streamline project management. Our platform offers a comprehensive suite of features that cater to developers, designers, and project managers alike.

Key Features:

1. Collaborative Comments: Leave contextual feedback directly on the website, fostering seamless communication among team members.
2. Centralized Dashboard: Manage all your projects, comments, and changes from a single, intuitive interface.
3. Streamlined Development Workflow: Easily request and implement changes, accelerating the development process.

OpenPreview is built with cutting-edge technologies, including TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI, and Tailwind CSS. This ensures a robust, scalable, and user-friendly experience for all our users.

Whether you're a solo developer or part of a large team, OpenPreview provides the tools you need to collaborate effectively, manage projects efficiently, and deliver high-quality results. Join us in shaping the future of web development and project management.

</project_description>

You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind.

Code Style and Structure:

- Write concise, technical TypeScript code with accurate examples
- Use functional and declarative programming patterns; avoid classes
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
- Structure files: exported component, subcomponents, helpers, static content, types

Naming Conventions:

- Use lowercase with dashes for directories (e.g., components/auth-wizard)
- Favor named exports for components

TypeScript Usage:

- Use TypeScript for all code; prefer interfaces over types
- Avoid enums; use maps instead
- Use functional components with TypeScript interfaces

Syntax and Formatting:

- Use the "function" keyword for pure functions
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
- Use declarative JSX

Error Handling and Validation:

- Prioritize error handling: handle errors and edge cases early
- Use early returns and guard clauses
- Implement proper error logging and user-friendly messages
- Use Zod for form validation
- Model expected errors as return values in Server Actions
- Use error boundaries for unexpected errors

UI and Styling:

- Use Shadcn UI, Radix, and Tailwind for components and styling
- Implement responsive design with Tailwind CSS; use a mobile-first approach

Performance Optimization:

- Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC)
- Wrap client components in Suspense with fallback
- Use dynamic loading for non-critical components
- Optimize images: use WebP format, include size data, implement lazy loading

Key Conventions:

- Use 'nuqs' for URL search parameter state management
- Optimize Web Vitals (LCP, CLS, FID)
- Limit 'use client':
  - Favor server components and Next.js SSR
  - Use only for Web API access in small components
  - Avoid for data fetching or state management

Follow Next.js docs for Data Fetching, Rendering, and Routing


add all the rls policies, some seem to be missing

1. Owner:
Can perform all operations on the organization they own
Can create, read, update, and delete projects in their organization
Can create, read, update, and delete comments in their organization's projects
Can create, read, update, and delete allowed domains for their organization's projects
Can create, read, update, and delete organization invitations
Can read user information of all members in their organization
2. Admin:
Can read and update the organization
Can create, read, update, and delete projects in their organization
Can create, read, update, and delete comments in their organization's projects
Can create, read, update, and delete allowed domains for their organization's projects
Can create, read, update, and delete organization invitations
Can read user information of all members in their organization
Member:
Can read the organization
Can read projects in their organization
Can create, read, update (own), and delete (own) comments in their organization's projects
Can read allowed domains for their organization's projects
Can read user information of all members in their organization
Viewer:
Can read the organization
Can read projects in their organization
Can read comments in their organization's projects
Can read allowed domains for their organization's projects
Can read user information of all members in their organization
Authenticated users (not in the organization):
Can create new organizations
Cannot access any data of organizations they're not a member of
Unauthenticated users:
No access to any data
These policies ensure that:
Only organization members can access organization data
Only admins and owners can make significant changes to the organization and its projects
Members can contribute by adding comments, but can't make structural changes
Viewers have read-only access to all organization data
Users can always manage their own data (update their user profile, manage their own comments)
css
html
javascript
less
mdx
next.js
plpgsql
radix-ui
+4 more

First Time Repository

TypeScript

Languages:

CSS: 2.1KB
HTML: 2.4KB
JavaScript: 279.8KB
MDX: 0.0KB
PLpgSQL: 32.9KB
TypeScript: 494.7KB
Created: 9/27/2024
Updated: 11/6/2024

All Repositories (1)