# Project Memory## Architecture- Using JWT tokens with 15min expiry- Refresh tokens stored in httpOnly cookies- Database: PostgreSQL via Prisma ORM- Migrations run with `pnpm db:migrate`## Code Style- Filenames: kebab-case (e.g. `auth-utils.ts`)- Error handling: errore-style (errors as values)- Imports: absolute imports via `@/` alias- Functions: object arguments for 2+ params## Preferences- User prefers concise git commit messages- Run tests before committing- Use pnpm (not npm or yarn)## Domain Knowledge- Payment flow: 1. User clicks "Subscribe" 2. Stripe checkout session created 3. Webhook confirms payment 4. Database updated with subscription- Email sending: - Transactional: Resend API - Marketing: ConvertKit - All templates in `emails/` directory## Recent Learnings- 2026-03-01: Added rate limiting to `/api/chat` (100 req/min per IP)- 2026-02-28: Migrated from Vercel to self-hosted on Railway
## Architecture- Decided to use Redis for session storage (faster than DB queries)- API rate limiting: 100 req/min per IP via upstash/ratelimit
Project patterns discovered
After understanding how the codebase works:
## Patterns- All API routes return `{ data, error }` objects- Database queries use errore.tryAsync for error handling- Test files are colocated with source (e.g. `auth.ts` + `auth.test.ts`)
User preferences expressed
When the user mentions preferences:
“I prefer functional components over classes”
## Preferences- React: functional components with hooks (no class components)
Important context before idle
After a 10+ minute gap, save key learnings:
## Recent Work- 2026-03-01: Refactored auth to support OAuth (Google, GitHub)- New env vars: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
Add new learnings without removing old ones (unless outdated):
## Recent Learnings- 2026-03-05: Added webhook retry logic (3 attempts with exponential backoff)- 2026-03-01: Migrated to Turso for database (was Supabase)- 2026-02-28: Switched to Bun from Node.js