A modern journaling application with AI-powered reflection capabilities. Built with Next.js, TypeScript, and OpenAI integration to provide users with meaningful insights into their journal entries.
- AI-Powered Journaling - Get automated reflections, pattern detection, and actionable suggestions
- Journal Entry Input - Enhanced textarea with auto-resize, validation, and character counting
- Real-time Feedback - Instant validation and feedback on journal entries
- Responsive Design - Optimized experience across all devices and screen sizes
- Dark/Light Mode - Full theme support with system preference detection
- Next.js 15 with App Router
- OpenAI Integration - GPT-4 Turbo with GPT-3.5 Turbo fallback
- TypeScript for type safety
- Tailwind CSS v4 with CSS variables for theming
- shadcn/ui for beautiful, accessible UI components
- Rate Limiting & Caching - Optimized AI API usage with cost reduction
- Comprehensive Testing - Unit tests with Vitest + E2E tests with Playwright
- Code Quality - ESLint, Prettier, Husky pre-commit hooks
- Path aliases (@/*) configured
- Vercel deployment ready
This application follows a simplified, standard-first approach:
- Standard HTML elements for accessibility (no over-engineered custom focus management)
- Component simplicity over complex abstractions
- Testing reliability with standard patterns
- Maintainability through clear, readable code
Note: A comprehensive custom focus management system was removed in September 2025 to reduce complexity and improve maintainability.
This project uses pnpm for faster, more efficient dependency management.
- Node.js 18+ and pnpm
- OpenAI API key (required for AI features)
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env.local
# Add your OpenAI API key to .env.local
echo "OPENAI_API_KEY=your_openai_api_key_here" >> .env.local
# Start development server
pnpm devThe application requires several environment variables for full functionality:
Required:
OPENAI_API_KEY=your_openai_api_key_hereOptional (with defaults):
# AI Model Configuration
OPENAI_MODEL=gpt-4-1106-preview
OPENAI_FALLBACK_MODEL=gpt-3.5-turbo-1106
OPENAI_MAX_TOKENS=500
OPENAI_TEMPERATURE=0.7
# Rate Limiting
AI_RATE_LIMIT_RPM=10
# Caching
AI_CACHE_TTL=3600Get your OpenAI API key from: https://platform.openai.com/api-keys
# Development
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
# Code Quality
pnpm lint # Run ESLint
pnpm format # Format code with Prettier
pnpm format:check # Check code formatting
# Testing
pnpm test # Run unit tests
pnpm test:ui # Run tests with UI
pnpm test:coverage # Run tests with coverage
pnpm test:e2e # Run e2e tests
pnpm test:e2e:ui # Run e2e tests with UI
pnpm test:e2e:debug # Debug e2e tests- Vitest for fast unit testing
- @testing-library/react for React component testing
- jsdom environment for DOM testing
- Test files:
**/__tests__/**/*.test.{ts,tsx}
- Playwright for end-to-end testing
- Tests across Chrome, Firefox, and Safari
- Test files:
e2e/**/*.spec.ts
This application includes custom and shadcn/ui components:
- JournalEntryInput - Enhanced textarea for journal writing with auto-resize, validation, and character counting
- LoadingSpinner - Animated loading indicators with size/color variants
- ErrorMessage - Accessible error display with icons and variants
- Feedback - Thumbs up/down rating component for user feedback
- ThemeToggle - Light/dark/system mode switching
- Button, Card, Input, Label, Textarea, Dialog
Add more shadcn/ui components with:
pnpm dlx shadcn@latest add [component-name]src/
βββ app/
β βββ api/
β β βββ reflect/ # AI processing endpoint
β β βββ page.tsx # Main application page
βββ components/
β βββ ui/ # UI components (buttons, inputs, etc.)
β βββ __tests__/ # Component unit tests
βββ lib/
β βββ openai.ts # OpenAI service utilities
β βββ ai-client.ts # Client-side AI utilities
β βββ utils.ts # General utilities
βββ types/
β βββ ai.ts # AI service type definitions
βββ test/ # Test setup and utilities
e2e/ # Playwright end-to-end tests
.taskmaster/ # Project task management
- ESLint: Extends Next.js config
- Prettier: Includes Tailwind plugin for class sorting
- Tailwind: v4 with CSS variables for theming
- TypeScript: Strict mode enabled
- Path Aliases:
@/*maps tosrc/*
The app uses OpenAI's API to provide intelligent reflections on journal entries:
- POST
/api/reflect- Process journal entries with AI
- Dual Model Support - GPT-4 Turbo primary, GPT-3.5 Turbo fallback
- Rate Limiting - 10 requests/minute per IP (configurable)
- Caching - Reduces API costs for similar entries
- Error Handling - Comprehensive error types and recovery
- Response Format - Summary, pattern detection, actionable suggestions
import { aiClient } from '@/lib/ai-client'
const response = await aiClient.processEntry({
content: 'Your journal entry here...',
})
console.log(response.summary) // Brief summary
console.log(response.pattern) // Detected pattern/theme
console.log(response.suggestion) // Actionable suggestion- Push to GitHub
- Import project in Vercel
- Add environment variables:
OPENAI_API_KEY(required)- Other optional AI configuration variables
- Deploy automatically
Works on any platform supporting Next.js. Ensure environment variables are configured properly.
- Pre-commit hooks with Husky
- Lint-staged for staged file linting
- ESLint + Prettier integration
- TypeScript strict mode
- Next.js 15 performance optimizations
- Static generation where possible
- Optimal bundle splitting
- Image optimization built-in
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
MIT License - see LICENSE file for details.