ProjectsCROP Frontend
CROP Frontend Roadmap
Phase 1: Core Foundation - x Next.js 16 setup with App Router - x TypeScript strict mode - x Tailwind CSS v4 - x Biome linting/formatting - x Parts catalog...
CROP Frontend Roadmap
Completed Phases
Phase 1: Core Foundation
- Next.js 16 setup with App Router
- TypeScript strict mode
- Tailwind CSS v4
- Biome linting/formatting
- Parts catalog with search
- Product detail pages
- Equipment fitment display
Phase 2: SEO & Accessibility
- Lighthouse audit fixes
- JSON-LD structured data
- Custom 404 page
- Recent searches persistence
- WCAG AA compliance
- Meta descriptions
- robots.txt configuration
Phase 3: Shopping Cart (MVP)
- Zustand cart store with localStorage persistence
- Add to cart from product pages
- Cart page with item management
- Header cart badge with hydration safety
- Quantity selector
- Remove item / clear cart
Phase 3 Extensions (Future)
Checkout Flow
- Checkout page with address form
- Payment integration (Stripe/Square)
- Order confirmation page
- Email notifications
User Account
- Account dashboard (
/account) - Order history (
/orders) - Address management
- Saved payment methods
Cart Enhancements
- Wishlist / saved items
- Quote request workflow
- Stock notification system
- Cart sync across devices (requires backend)
- Guest checkout
Phase 4: Performance (Completed)
Bundle Optimization
- Bundle analysis (
bun run analyze) - largest chunk: 520KB - Remove unused recharts library (-330KB potential)
- Remove unused chart.tsx component
- Tree shaking verification (lucide-react optimized)
- MongoDB type-only imports verified (no runtime)
- Dynamic imports for heavy components (Clerk blocked - needs provider at root)
Image Optimization
- Next.js Image quality config (75, 90 supported)
- AVIF/WebP formats enabled
- Home page grid images - added responsive
sizes - Hero section images - priority + sizes verified
- 360° viewer images - sizes attribute verified
- Placeholder blur images (future)
Core Web Vitals
- LCP optimization
- FID/INP improvements
- CLS reduction
- TTFB analysis
Caching Strategy
- Autocomplete API caching (max-age=30, stale-while-revalidate=60)
- Equipment API caching (s-maxage=300, stale-while-revalidate=600)
- Categories API caching (s-maxage=3600, stale-while-revalidate=7200)
- Static generation where possible
- Service worker optimization
Results
- Largest chunk: 520KB → 376KB (-27% reduction)
- Removed ~330KB of unused recharts library
Known Blockers & Upstream Issues
1. Next.js cacheComponents + Clerk Incompatibility
| Field | Value |
|---|---|
| Issue | vercel/next.js#85490 |
| Status | Open - waiting for Clerk update |
| Fix PR | clerk/javascript#7119 |
| Workaround | cacheComponents disabled in next.config.ts:19-22 |
| Impact | RSC caching disabled, slightly slower page loads |
| Action | Re-enable after Clerk releases Next.js 16 compatibility update |
2. Clerk Dynamic Import (Not a Bug)
| Field | Value |
|---|---|
| Status | Architectural constraint - not fixable |
| Reason | ClerkProvider must wrap entire app for auth context |
| Impact | ~376KB Clerk SDK in initial bundle |
| Note | Same limitation applies to NextAuth, Auth0, etc. |
How to Check for Updates
# Check Clerk version
bun list @clerk/nextjs
# Check for updates
bun update @clerk/nextjs
# After updating, try re-enabling in next.config.ts:
# cacheComponents: truePhase 5: Testing & Quality (90% Complete)
Unit Tests (Vitest)
- Cart store tests (25 tests) -
lib/stores/cart-store.test.ts - Search service client tests (9 tests)
- Search service adapters tests (57 tests)
- View model tests (8 tests)
- Query classifier tests (4 tests)
- Suggestion helpers tests (5 tests)
- Inline completion tests (4 tests)
- Manufacturer config tests (2 tests)
- usePartImage hook tests (4 tests)
- fetchPartById tests (5 tests)
- Checkout action tests (21 tests) -
app/actions/checkout.test.ts - Parts slug utilities tests (14 tests) -
app/parts/[id]/utils.test.ts - Component tests with Testing Library
Total: 158 unit tests passing
E2E Tests (Playwright)
- Playwright setup with chromium
- Search autocomplete tests (5 tests)
- Search filters tests (5 tests)
- Cart flow tests (9 tests) -
tests/e2e/cart-flow.spec.ts - Admin API tests (exists)
- Mobile responsiveness tests
Test Infrastructure
- Vitest config with happy-dom environment
- localStorage mock for zustand persist middleware
- server-only mock for SSR components
- Path aliases resolution (@/)
Visual Regression
- Storybook component library (setup exists)
- Chromatic integration
Architecture Plan Status (Amazon-style Store)
1. Frontend Routes (Next.js)
| Route | Description | Status | Notes |
|---|---|---|---|
/ | Home / promo | ✅ Done | app/home/page.tsx |
/parts | Catalog with filters & search | ✅ Done | app/parts/(catalog)/page.tsx |
/parts?q=... | Search results | ✅ Done | Query params handled |
/parts/[id] | Product detail by ID | ✅ Done | app/parts/[id]/page.tsx |
/parts/[sku] | Product by SKU | ⚠️ Partial | Uses [id] route, SKU lookup in place |
/parts/[slug] | SEO-friendly URL | ✅ Done | Redirects to canonical SKU |
/parts/cart | Shopping cart | ✅ Done | app/parts/cart/page.tsx |
/checkout/* | Checkout flow | ⚠️ Partial | Success/cancel pages exist |
/sign-in, /sign-up | Auth | ✅ Done | Clerk integration |
| Header search | Search in header | ✅ Done | features/search-bar/ |
2. Domain Plan
| Domain | Purpose | Status | Notes |
|---|---|---|---|
crop-dev.app | Frontend (Vercel) | ✅ Done | Cloudflare proxied |
api-dev.crop-dev.app | API Gateway | ⚠️ Partial | Search service exists |
| Admin domain | Separate admin app | 🔜 Out of scope | Not in this repo |
3. Backend Chain: Cloudflare → API Gateway → Cloud Run
| Component | Status | Notes |
|---|---|---|
| Cloudflare DNS/proxy | ✅ Done | TLS, WAF enabled |
| Cloudflare caching | ✅ Done | Cache headers set |
| GCP API Gateway | ✅ Done | crop-gateway-2u6j9u5d.ue.gateway.dev |
| Cloud Run services | ⚠️ Partial | Search + Payment deployed |
| Hono microservices | 🔜 Pending | Cart service planned |
4. API Endpoints
| Endpoint | Type | Status | Notes |
|---|---|---|---|
GET /public/parts | Public | ✅ Done | Via search-service |
GET /public/parts/sku/{sku} | Public | ✅ Done | fetchPartById |
GET /public/parts/slug/{slug} | Public | ❌ Not done | Planned |
GET /customer/cart | Auth | ⚠️ Client Ready | lib/cart-service/client.ts |
PUT /customer/cart/sync | Auth | ⚠️ Client Ready | app/actions/cart.ts |
DELETE /customer/cart/items/{id} | Auth | ⚠️ Partial | Local only |
GET /customer/orders | Auth | ❌ Not done | Planned |
POST /customer/checkout | Auth | ⚠️ Partial | Stripe intent exists |
5. Authentication (Clerk)
| Item | Status | Notes |
|---|---|---|
| ClerkProvider in layout | ✅ Done | app/layout.tsx |
| Sign-in/Sign-up pages | ✅ Done | app/sign-in/, app/sign-up/ |
| JWT template for API | ✅ Done | gcp-api template configured |
getToken() for backend calls | ✅ Done | All API clients updated |
| API Gateway JWT validation | ⚠️ Documented | See docs/GCP_API_GATEWAY_PLAN.md |
Hono authenticateRequest() | ❌ Not done | Phase 1 of auth plan |
6. Summary
| Category | Progress |
|---|---|
| Frontend Routes | 90% |
| Search & Catalog | 95% |
| Shopping Cart (local) | 100% |
| Cart Backend Sync | 30% |
| Checkout Flow | 30% |
| Auth Integration | 70% |
| API Gateway | 40% |
| Cloud Run Services | 30% |
Next Steps (Prioritized)
| Priority | Task | Phase | Complexity | Status |
|---|---|---|---|---|
| 1 | Component tests with Testing Library | Phase 5 | Medium | Pending |
| 2 | Mobile responsiveness E2E tests | Phase 5 | Medium | Pending |
| 3 | Checkout page with address form | Phase 3 Ext | High | Pending |
| 4 | Payment integration (Stripe) | Phase 3 Ext | High | Pending |
| 5 | Core Web Vitals optimization | Phase 4 | Medium | Pending |
| 6 | Filters persistence in URL | Phase 6 | Low | Pending |
| 7 | /parts/[slug] SEO route | Architecture | Low | ✅ Done |
| 8 | Cart backend sync (Cloud Run) | Architecture | High | ⚠️ Client Ready |
| 9 | GCP API Gateway OpenAPI spec | Architecture | Medium | ✅ Deployed |
| 10 | Clerk JWT template for GCP | Architecture | Low | ✅ Done |
Phase 6: Advanced Features
Search Enhancements
- Filters persistence in URL
- Search analytics
- Autocomplete improvements
- Category navigation
Product Features
- Related products
- Recently viewed
- Compare products
- Product reviews
Admin Features
- Inventory management
- Order management
- Analytics dashboard