A full-stack Next.js 14 application for creating and chatting with personalized AI companions using Claude AI.
- 🔐 User Authentication - Secure signup/login with NextAuth.js
- 👥 Companion Creation - Choose between AI girlfriends or boyfriends
- ✨ Full Customization - Personalize appearance, personality traits, and conversation style
- 💬 Real-time Chat - Natural conversations powered by Claude AI (Anthropic API)
- 🎨 Beautiful UI - Modern, responsive design with smooth animations
- 📱 Fully Responsive - Works perfectly on desktop, tablet, and mobile
- Framework: Next.js 14 (App Router, Server-Side Rendering)
- Language: TypeScript
- Authentication: NextAuth.js with JWT
- AI: Anthropic Claude API
- Styling: Tailwind CSS with custom design system
- Animations: Framer Motion
- Database: In-memory storage (easily replaceable with PostgreSQL, MongoDB, etc.)
- Node.js 18+ and npm
- An Anthropic API account (if deploying outside of Claude.ai artifacts)
- Clone the repository:
git clone <your-repo-url>
cd ai-companion-app- Install dependencies:
npm install- Set up environment variables:
cp .env.local.example .env.localEdit .env.local and add:
NEXTAUTH_SECRET=your-super-secret-key-here
NEXTAUTH_URL=http://localhost:3000- Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
src/
├── app/
│ ├── api/ # API routes
│ │ ├── auth/ # Authentication endpoints
│ │ ├── companions/ # Companion CRUD operations
│ │ └── chat/ # Chat API with Claude
│ ├── login/ # Login page
│ ├── signup/ # Signup page
│ ├── dashboard/ # User dashboard
│ └── companion/ # Companion routes
│ ├── create/ # Companion creation
│ └── [id]/ # Chat interface
├── components/ # React components
│ ├── DashboardClient.tsx
│ ├── CompanionCreator.tsx
│ └── ChatInterface.tsx
├── lib/ # Utilities
│ ├── db.ts # Database operations
│ ├── auth.ts # NextAuth configuration
│ └── presets.ts # Companion presets
└── types/ # TypeScript types
- Secure password hashing with bcrypt
- JWT-based sessions with NextAuth.js
- Protected routes with server-side session checks
- Pre-built personality presets for quick start
- Full customization of:
- Name and age
- Personality traits (up to 5)
- Physical appearance (hair, eyes, style)
- Custom descriptions
- Gender selection (girlfriend/boyfriend)
- Integration with Claude Sonnet 4 via Anthropic API
- Context-aware conversations (maintains last 20 messages)
- Custom system prompts based on companion configuration
- Real-time message streaming
Currently uses in-memory storage for simplicity. To use a real database:
- Install your database client (e.g.,
prismafor PostgreSQL) - Update
src/lib/db.tswith your database logic - Keep the same interface for minimal code changes
Example with Prisma:
// Replace the Map-based storage with:
const user = await prisma.user.findUnique({ where: { email } });- Edit
src/app/globals.cssfor global styles - Modify CSS variables in
:rootfor color scheme - Update
tailwind.config.jsfor theme customization
- Add/modify presets in
src/lib/presets.ts - Customize personality traits, appearance options
- Create new companion templates
- Adjust system prompts in
src/app/api/companions/route.ts - Modify conversation context window size in
src/app/api/chat/route.ts - Tune Claude model parameters (temperature, max_tokens)
- Push your code to GitHub
- Import your repository on Vercel
- Add environment variables in Vercel dashboard
- Deploy!
Works with any platform supporting Next.js 14:
- Netlify
- Railway
- AWS Amplify
- Self-hosted with Docker
# Required
NEXTAUTH_SECRET=your-secret-key-here
NEXTAUTH_URL=your-deployment-url
# Optional (if not using Claude.ai artifacts)
ANTHROPIC_API_KEY=your-api-keyPOST /api/auth/signup- Create new userPOST /api/auth/[...nextauth]- NextAuth handlersGET /api/companions- Get user's companionsPOST /api/companions- Create new companionDELETE /api/companions?id=...- Delete companionPOST /api/chat- Send message and get AI responseGET /api/chat?companionId=...- Get chat history
- Passwords are hashed with bcrypt before storage
- JWT tokens are signed and verified
- All API routes check user authentication
- Users can only access their own companions and chats
- CSRF protection via NextAuth.js
- Voice chat support
- Image generation for companions
- Message reactions and favorites
- Multiple companion conversations
- Export chat history
- Companion memory and context learning
- Social features (share companions, public gallery)
- Mobile apps (React Native)
- Advanced AI fine-tuning options
Contributions are welcome! Please open an issue or submit a pull request.
MIT License - feel free to use this project for personal or commercial purposes.
For issues or questions:
- Open a GitHub issue
- Check the documentation
- Review the code comments
- Built with Next.js
- AI powered by Anthropic Claude
- Design inspired by modern dating and social apps