This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm run dev # Start development server (http://localhost:3000)
npm run build # Build for production
npm run lint # Run ESLint
npm run prettier # Check code formatting
npm run prettier:fix # Fix code formattingParamail is a Next.js AI email assistant that helps users analyze, translate, and compose emails. The app is primarily targeted at Korean users who need to handle English emails.
src/pages/- Next.js pages and API routes (uses.page.ts/.page.tsxextension convention)api/generate/- OpenAI GPT-3.5 email analysis and generationapi/translate.page.ts- Google Translate API wrapper (EN→KO)api/credits/- Credit management (consume, charge via Stripe)api/webhooks/stripe.page.ts- Stripe payment webhooksapp/- Protected app pages (main dashboard, settings)auth/- Authentication pages (login/signup)
src/components/- Shared UI componentssrc/hooks/- Custom React hooks for state and API logicsrc/lib/- External service clients (Supabase, Stripe)src/utils/- Utility functions
useAnalysis- Email analysis with debouncing, parses AI response using_^delimitersuseEmailCreation- Email generation (reply or new), handles credit consumptionuseTranslation- Google Translate wrapper for EN→KO translationuseUser- Global user context with real-time Supabase subscription for credit updates
- User input → Custom hook → API route → External service (OpenAI/Google/Supabase)
- Response → Hook state → Component render
- Auto-triggered:
/api/credits/consume+/api/usage-log
- Reply Flow (
ReplyFlow.tsx): Multi-step wizard - input English email → translate → analyze (summary, actions, suggested replies) → generate English reply - New Email Flow (
NewMailFlow.tsx): Two-step - input Korean brief → generate English email
- Supabase: Auth (email/password, OAuth), database (
profilestable), real-time subscriptions - OpenAI: GPT-3.5-turbo for email analysis and generation (prompts in
api/generate/promptData.ts) - Google Cloud Translate: EN→KO translation
- Stripe: Credit package purchases (100 or 500 credits)
- 1 credit per translation+analysis, 1 credit per email generation
- Stored in Supabase
profiles.creditcolumn - Real-time sync via Supabase subscriptions
- Page extensions: Custom
.page.ts/.page.tsxconvention (configured innext.config.js) - Path alias:
@/*maps to./src/* - SVG imports: Handled as React components via @svgr/webpack
- Environment: Uses
isDevEnvutility; dev vs production Stripe/OpenAI keys
Prompts in /api/generate/promptData.ts use few-shot learning with structured output:
- Analysis returns summary, action points, and answer suggestions separated by
_^delimiters - Low temperature (0.1) for consistent outputs