A sophisticated AI chat platform built with Next.js 14, featuring real-time conversations with AI models, memory management, and dynamic chat interfaces.
- Real-time Chat: Seamless conversations with AI models
- Memory System: Context-aware conversations using Pinecone vector database
- Multiple AI Models: Support for various AI personalities
- Authentication: Secure user authentication via Kinde
- Responsive Design: Full mobile and desktop support
- Server-side rendering with Next.js 14 App Router
- Real-time updates using WebSocket connections
- PostgreSQL database with Prisma ORM
- TypeScript for type safety
- Tailwind CSS for styling
- shadcn/ui component library
- Vector embeddings for conversation memory
- Node.js 18.x or higher
- PostgreSQL database
- Pinecone account for vector storage
- Kinde account for authentication
Create a .env file in the root directory:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
# Authentication
KINDE_CLIENT_ID="your_kinde_client_id"
KINDE_CLIENT_SECRET="your_kinde_client_secret"
KINDE_ISSUER_URL="your_kinde_issuer_url"
KINDE_SITE_URL="your_site_url"
KINDE_POST_LOGOUT_REDIRECT_URL="your_logout_redirect"
KINDE_POST_LOGIN_REDIRECT_URL="your_login_redirect"
# Vector Database
PINECONE_API_KEY="your_pinecone_api_key"
PINECONE_ENVIRONMENT="your_pinecone_environment"- Clone the repository:
git clone https://github.com/yourusername/ai-chat-platform.git
cd ai-chat-platform- Install dependencies:
npm install- Set up the database:
npx prisma generate
npx prisma db push- Run the development server:
npm run devsrc/
βββ app/ # Next.js app router pages
β βββ api/ # API routes
β βββ chat/ # Chat interface pages
β βββ community/ # Community features
βββ components/ # React components
β βββ chat/ # Chat-related components
β βββ ui/ # UI components
β βββ layouts/ # Layout components
βββ lib/ # Utility functions
β βββ clients/ # External service clients
β βββ session/ # Authentication utilities
βββ types/ # TypeScript type definitions
βββ utils/ # Helper functions
# Development
npm run dev
# Build
npm run build
# Production
npm start
# Type checking
npm run type-check
# Linting
npm run lint
# Format code
npm run format# Generate Prisma client
npx prisma generate
# Push schema changes
npx prisma db push
# Open Prisma Studio
npx prisma studio- All API routes are protected with authentication
- Rate limiting on sensitive endpoints
- Input validation using Zod
- Secure session management
- XSS protection
- CORS configuration
# Run tests
npm test
# Run tests with coverage
npm run test:coverage- Set up environment variables on your hosting platform
- Configure database connection
- Build and deploy:
npm run build
npm start- Vercel (recommended)
- Railway
- Heroku
- Self-hosted
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
Please ensure your PR:
- Follows the existing code style
- Includes appropriate tests
- Updates documentation as needed
This project is private, commercial and not licensed. Access to the code is strictly confidential.
The application uses a distributed queue system for AI model generation:
- Main App (Vercel): Handles web requests and queues jobs in Redis
- Queue Worker (Railway): Separate service that processes AI generation jobs
- Repository: girlfriend-queue-worker
- Runs continuously on Railway
- Polls the Redis queue for new jobs
- Processes AI model generation requests
# Redis Queue (Upstash)
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=# API Access
WORKER_ENDPOINT=https://girlfriend.cx/api/ai-models/worker
WORKER_AUTH_TOKEN=your_auth_token
# Queue Configuration
QUEUE_POLL_INTERVAL=5000
QUEUE_RETRY_INTERVAL=10000
QUEUE_MAX_RETRIES=3
# Redis Queue (Upstash) - same as main app
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=- User requests AI model generation
- Main app creates pending model in database
- Job is added to Redis queue
- Worker picks up job and processes it
- Worker updates model status when complete
- Main app: Deployed on Vercel
- Queue worker: Deployed on Railway
- Redis queue: Hosted on Upstash