Development guide for a Next.js 15 legal letter generation platform with AI, subscription management, role-based access, and Supabase backend.
Development guide for working with the Talk-To-My-Lawyer codebase - a Next.js 15 application for generating professional legal letters with AI.
Talk-To-My-Lawyer is a Next.js 15 application featuring:
Core tables:
1. **Authentication & Authorization**
- Check `middleware.ts` for route protection
- Review `lib/auth.ts` for role-based access logic
- Use server-side client (`lib/supabase/server.ts`) for protected routes
2. **Database Operations**
- Use type-safe queries with `lib/types/database.ts`
- Run `npm run db:gen-types` after schema changes
- Push schema changes with `npm run db:push`
3. **Supabase Integration**
- Client-side: Use singleton from `lib/supabase/client.ts`
- Server-side: Use `lib/supabase/server.ts`
- Never expose service role key client-side
4. **Development Commands**
```bash
npm run dev # Start dev server (localhost:3000)
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run typecheck # TypeScript type checking
npm run db:push # Push schema to Supabase
npm run db:gen-types # Generate DB types
```
5. **Environment Variables**
Required variables:
- `NEXT_PUBLIC_SUPABASE_URL` - Supabase project URL
- `NEXT_PUBLIC_SUPABASE_ANON_KEY` - Supabase anon key
- `OPENAI_API_KEY` - OpenAI API key
6. **Key Features Implementation**
- AI letter generation: Check `app/api/` routes
- PDF generation: Uses pdf-lib library
- Subscription quotas: Enforced in letter creation logic
- Commission tracking: Updated on referral conversions
7. **Deployment**
- Primary: Netlify with `@netlify/plugin-nextjs`
- Alternative: Vercel
- Database: Supabase hosted
**Adding a new protected route:**
1. Create route in `app/` directory
2. Add route protection in `middleware.ts` if needed
3. Use appropriate Supabase client (server for SSR)
4. Implement role checks using `lib/auth.ts`
**Modifying database schema:**
1. Update schema in Supabase dashboard or migrations
2. Run `npm run db:gen-types` to update TypeScript types
3. Run `npm run db:push` to apply changes
4. Update affected queries and components
**Adding new AI features:**
1. Create API route in `app/api/`
2. Integrate OpenAI client
3. Implement proper error handling
4. Add rate limiting/quota checks
5. Update UI components
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/talk-to-my-lawyer-project-guide/raw