Repository navigation
Expand file tree
/
Copy path.cursorrules
More file actions
196 lines (177 loc) · 8.08 KB
/
Copy path.cursorrules
File metadata and controls
196 lines (177 loc) · 8.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Cursor Rules
## Instructions
- Record fixes for mistakes or corrections to avoid repetition in the `Lessons` section.
- Organize thoughts and plan steps before starting a task in the `Scratchpad` section.
- Clear old tasks if necessary.
- Use todo markers for progress tracking:
- `[X]` Completed tasks
- `[ ]` Pending tasks
- Update Scratchpad after completing subtasks.
- Reflect and plan after milestones for better task management.
- Always refer to Scratchpad before planning the next step.
## Lessons
### Fixed TypeScript Errors in Authentication System (2024)
- Fixed TypeScript error in signin/signup pages where `err.errors[0]` could be undefined
- Solution: Use optional chaining `err.errors[0]?.message || "Validation error"`
- Fixed missing `role` property in auth.ts authorize function return value
- Solution: Added `role: user.role` to the returned user object
- Fixed JWT token property access using bracket notation for dynamic properties
- Solution: Used `token["id"]` instead of `token.id` for index signature properties
- Fixed profile page prerendering error during build
- Solution: Avoided destructuring `useSession()` directly, used intermediate variable instead
- Changed `const { data: session, status } = useSession()` to separate variable assignments
- Added missing NEXTAUTH_SECRET configuration for production security
- Solution: Added `secret: process.env["NEXTAUTH_SECRET"]` to NextAuth config
- Important: Generate a secure random string for production deployment
- Fixed Next.js 15 async params issue in dynamic routes
- Solution: Changed `params: { id: string }` to `params: Promise<{ id: string }>`
- Added `const { id } = await params` to handle async params properly
- Fixed avatar field type mismatch in product reviews
- Solution: Transformed `null` values to `undefined` with `review.user.avatar || undefined`
- Fixed array index access warning in TypeScript
- Solution: Added explicit bounds checking and non-null assertion `distribution[index]!++`
- Fixed useSearchParams Suspense boundary requirement in Next.js 15
- Solution: Wrapped components using `useSearchParams` in Suspense boundaries
- Created separate content components and main page components for proper structure
- Created root layout.tsx file to fix missing layout error
- Solution: Added root layout with HTML structure and SessionProvider
- Modified home layout to only handle page structure without HTML tags
- Fixed Prisma client browser environment error in client components
- Solution: Created API routes for database operations instead of direct imports
- Added `/api/products` and `/api/categories` endpoints
- Updated client components to use fetch() instead of direct lib/products imports
- Server components can still use lib/products directly
- Completed shopping cart implementation with Zustand (2024)
- Created cart page (`/cart`) with item management and checkout flow
- Built CartItem component with quantity controls and remove functionality
- Created CartSummary component with order totals and shipping calculations
- Added EmptyCart component with category links and value propositions
- Implemented AddToCartButton component for product grids and pages
- Created ProductCard component for consistent product display
- Cart persistence works automatically through Zustand middleware
- Real-time cart updates reflected in header badge
- Fixed product image and description mismatch (2024)
- Updated seed.ts to map products correctly to their actual images
- Converted mismatched smartphone/laptop products to clothing items (camo shirt, yellow pullover)
- Updated denim products to match jean images
- Fixed sneaker product to match white shoe images
- All product names, descriptions, and categories now properly align with their visual content
## Scratchpad
### Phase 1: Project Setup & Configuration
- [X] Initialize Next.js 15 project with TypeScript
- [X] Install and configure essential dependencies (Shadcn, Lucide, Zod, Zustand)
- [X] Set up Tailwind CSS and Shadcn UI components
- [X] Configure ESLint, Prettier, and TypeScript strict mode
- [X] Set up project folder structure (components, lib, types, etc.)
- [X] Create environment variables template
### Phase 2: Database & ORM Setup
- [X] Set up PostgreSQL database (local/cloud)
- [X] Install and configure Prisma ORM
- [X] Design database schema for ecommerce (users, products, orders, categories, etc.)
- [X] Create Prisma migrations
- [X] Set up database seeding scripts
- [X] Test database connection and basic queries
### Phase 3: Authentication System
- [X] Install and configure next-auth@beta
- [X] Set up authentication providers (Google, GitHub, email/password)
- [X] Create authentication pages (login, register, forgot password)
- [X] Implement user roles (customer, admin, vendor)
- [X] Create protected route middleware
- [X] Design user profile management
### Phase 4: Core UI Components & Layout
- [X] Home Layout:
- Create `(home)` folder in `app` directory
- Header with logo, search bar, and navigation
- Footer with links and social media
- [X] Homepage:
- banner carousel
- latest products
- [X] Products Catalog:
- Sidebar with categories and filters
- Search results
- Product grid
- Pagination
- [X] Product pages:
- Create product detail page layout
- Implement image gallery with thumbnails
- Add product information section:
- Title, price, description
- Stock status
- Add to cart button
- Reviews and ratings section:
- Display existing reviews
- Add review form for authenticated users
- Star rating component
- Related products section:
- Show products from same category
- Product card carousel
- [X] Shopping cart:
- Add/remove items
- Update quantities
- Cart persistence
- [] Checkout process:
- Shipping information
- Payment integration (Stripe)
- Order confirmation
- [] User dashboard:
- Order history
- Profile management
- Saved addresses
- Wishlist
### Phase 9: Admin Dashboard
- [ ] Create admin layout with sidebar navigation
- [ ] Build analytics dashboard with Recharts
- [ ] Implement product management (CRUD operations)
- [ ] Add order management interface
- [ ] Create user management system
- [ ] Design inventory tracking
- [ ] Add sales reports and analytics
- [ ] Implement bulk operations
### Phase 10: File Upload & Media Management
- [ ] Set up Uploadthing for image uploads
- [ ] Create image upload components
- [ ] Implement multiple image upload for products
- [ ] Add image optimization and resizing
- [ ] Create media library for admin
- [ ] Set up CDN integration
- [ ] Add file validation and security
## Phase 11: Email & Notifications
- [ ] Configure Resend for email services
- [ ] Create email templates (welcome, order confirmation, etc.)
- [ ] Implement order notification system
- [ ] Add password reset emails
- [ ] Set up promotional email system
- [ ] Create newsletter subscription
- [ ] Add real-time notifications
### Phase 12: Advanced Features
- [ ] Implement multi-vendor marketplace
- [ ] Add advanced search with Elasticsearch/Algolia
- [ ] Create mobile app API endpoints
- [ ] Add social media integration
- [ ] Implement affiliate program
- [ ] Add multi-language support
- [ ] Create SEO optimization
### Phase 13: Testing & Quality Assurance
- [ ] Set up unit testing with Jest
- [ ] Add integration tests for API routes
- [ ] Implement E2E testing with Playwright
- [ ] Add performance testing
- [ ] Security audit and penetration testing
- [ ] Cross-browser compatibility testing
- [ ] Mobile responsiveness testing
### Phase 14: Deployment & DevOps
- [ ] Set up CI/CD pipeline
- [ ] Configure production environment
- [ ] Set up monitoring and logging
- [ ] Implement error tracking (Sentry)
- [ ] Add performance monitoring
- [ ] Set up backup strategies
- [ ] Create deployment documentation
### Phase 15: Post-Launch & Optimization
- [ ] Monitor application performance
- [ ] Gather user feedback and analytics
- [ ] Implement A/B testing for key features
- [ ] Optimize database queries and caching
- [ ] Add progressive web app features
- [ ] Scale infrastructure as needed
- [ ] Plan feature updates and roadmap