This file provides guidance for AI assistants working with the Sink project.
Sink is a URL shortening service built with Nuxt 3 and Cloudflare Workers. It provides analytics, real-time tracking, and a modern web interface.
- Frontend: Nuxt 3, Vue 3, TypeScript, Tailwind CSS, shadcn/ui
- Backend: Cloudflare Workers, H3 (Nitro)
- Database: Cloudflare KV
- Analytics: Cloudflare Analytics Engine
- Deployment: Cloudflare Pages/Workers
Sink/
├── app/ # Nuxt 3 application
│ ├── components/ # Vue components
│ ├── pages/ # File-based routing
│ ├── layouts/ # Layout components
│ ├── utils/ # Utility functions
│ └── middleware/ # Route middleware
├── server/ # Server-side API
│ ├── api/ # API endpoints
│ ├── middleware/ # Server middleware
│ └── utils/ # Server utilities
├── public/ # Static assets
├── schemas/ # TypeScript schemas
├── tests/ # Test files
└── docs/ # Documentationpnpm dev- Start development serverpnpm build- Build for productionpnpm preview- Preview production buildpnpm test- Run testspnpm lint- Run ESLint
- Use TypeScript for all new code
- Follow Vue 3 Composition API patterns
- Use PascalCase for component names
- Use camelCase for variables and functions
- Use kebab-case for CSS classes
- RESTful endpoints in
/server/api/ - Use Zod for schema validation in
/schemas/ - Implement proper error handling
- Use Cloudflare environment variables for configuration
- Use Cloudflare KV
- Use Vitest for unit tests
- Test files should be co-located with source files
- Use the existing test utilities in
/tests/utils.ts
Key environment variables to be aware of:
NUXT_CF_ACCOUNT_ID- Cloudflare account IDNUXT_CF_API_TOKEN- Cloudflare API tokenNUXT_DATASET- Analytics engine IDNUXT_SITE_TOKEN- Site token for management
- Create file in
/server/api/with appropriate HTTP method - Add Zod schema validation in
/schemas/ - Add tests in
/tests/api/ - Update documentation if needed
- Use existing UI components from
/app/components/ui/ - Follow the established component patterns
- Add TypeScript interfaces for props
- Consider adding to storybook if applicable
- Never commit secrets or API keys
- Use environment variables for sensitive configuration
- Validate all user input with Zod schemas
- Implement rate limiting on API endpoints
- Follow OWASP guidelines for web security
- Use Cloudflare's edge caching where appropriate
- Minimize bundle size by using dynamic imports
- Optimize images and assets
- Use the existing analytics for monitoring
- Check Cloudflare dashboard for worker logs
- Use
wrangler tailfor real-time logs - Verify environment variables are properly set
- Staging: Automatic on push to
mainbranch - Production: Manual trigger via Cloudflare dashboard
- Use
wrangler deployfor manual deployments