A powerful, user-friendly AI chat application built with Node.js and DeepSeek API, featuring custom AI personalities, conversation management, and a beautiful modern interface.
- 6 Pre-built Personalities: Helpful Assistant, Creative Writer, Code Mentor, Business Advisor, Learning Coach, and Philosopher
- Custom Personalities: Create your own AI personalities with custom system prompts
- Easy Switching: Switch between personalities seamlessly during conversations
- Real-time Streaming: Get responses as they're generated (optional)
- Conversation History: All chats are automatically saved and organized
- Session Management: Resume conversations from where you left off
- Message Export: Export conversations to text files
- Character Counter: Track message length with visual feedback
- Responsive Design: Works perfectly on desktop, tablet, and mobile
- Dark/Light Mode: Toggle between themes for comfortable viewing
- Intuitive Sidebar: Easy navigation between conversations and personalities
- Professional Styling: Clean, modern design with smooth animations
- Accessibility: Full keyboard navigation and screen reader support
- Temperature Control: Adjust AI creativity/randomness (0.0 - 1.0)
- Response Length: Configure maximum response length
- Auto-scroll: Automatically scroll to new messages
- Streaming Toggle: Enable/disable real-time response streaming
- Persistent Storage: Conversations saved to JSON files with auto-backup
- Error Handling: Comprehensive error handling with user-friendly messages
- Rate Limiting Ready: Built-in support for rate limiting (configurable)
- Environment Configuration: Easy setup with environment variables
- Modular Architecture: Clean, maintainable code structure
- Node.js (v14 or higher)
- NPM or Yarn
- DeepSeek API key
-
Clone or download the project
cd your-project-directory -
Install dependencies
npm install
-
Configure environment
cp .env.example .env
Edit
.envfile and add your DeepSeek API key:DEEPSEEK_API_KEY=your_api_key_here PORT=3000
-
Start the application
# Development mode (with auto-restart) npm run dev # Production mode npm start
-
Open your browser Navigate to
http://localhost:3000
changli/
βββ app.js # Main application server
βββ package.json # Dependencies and scripts
βββ .env.example # Environment configuration template
βββ routes/
β βββ chat.js # Enhanced chat API routes
βββ src/
β βββ config/
β β βββ database.js # Conversation storage manager
β βββ services/
β βββ chatService.js # AI chat service
β βββ systemPrompts.js # AI personalities manager
βββ public/ # Frontend files
β βββ index.html # Main HTML interface
β βββ styles.css # Modern CSS styling
β βββ app.js # Frontend JavaScript application
βββ data/ # Auto-created for conversation storage
βββ conversations.json
POST /api/chat/message- Send a message to AIPOST /api/chat/stream- Send a streaming message (real-time)POST /api/chat/conversation/new- Start a new conversation
GET /api/chat/conversations- Get all conversationsGET /api/chat/conversation/:sessionId- Get specific conversationPUT /api/chat/conversation/:sessionId/title- Update conversation titleDELETE /api/chat/conversation/:sessionId- Delete conversation
GET /api/chat/prompts- Get available AI personalitiesPOST /api/chat/prompts/custom- Create custom personality
GET /api/health- Health check endpoint
- π€ Helpful Assistant - General-purpose helpful AI
- βοΈ Creative Writer - Stories, poems, creative content
- π» Code Mentor - Programming help and code reviews
- π Business Advisor - Business strategy and analysis
- π Learning Coach - Educational support and tutoring
- π€ Philosopher - Deep discussions about life and ethics
- Click the "Create Custom" button in the personalities section
- Fill in the personality details:
- ID: Unique identifier (e.g., "my-custom-ai")
- Name: Display name (e.g., "My Custom AI")
- Description: Brief description of the personality
- Icon: Emoji to represent the personality
- System Prompt: Detailed instructions for the AI's behavior
Example custom prompt:
You are a fitness and nutrition expert with 10+ years of experience. You provide evidence-based advice on exercise routines, meal planning, and healthy lifestyle choices. You're motivational, encouraging, and always prioritize safety in your recommendations.
# Required
DEEPSEEK_API_KEY=your_deepseek_api_key_here
# Optional
PORT=3000 # Server port (default: 3000)
NODE_ENV=development # Environment mode
CORS_ORIGIN=* # CORS allowed originsAccess the settings panel by clicking the "Settings" button in the sidebar:
- Response Creativity (0.0-1.0): Controls randomness in AI responses
- Max Response Length (100-4000): Maximum tokens in AI responses
- Dark Mode: Toggle between light and dark themes
- Auto-scroll: Automatically scroll to new messages
- Real-time Streaming: Enable/disable streaming responses
- Starting Conversations: Select an AI personality first, then start chatting
- Switching Personalities: Click on a different personality to start a new conversation with that AI
- Managing Conversations: Use the sidebar to switch between past conversations
- Exporting Chats: Click the export button to save conversations as text files
- Keyboard Shortcuts:
Enterto send messageShift + Enterfor new line in messageCtrl/Cmd + /to focus message input
- Backend: Add new routes in
routes/chat.jsor create new route files - Frontend: Extend the
ChatAppclass inpublic/app.js - Styling: Add styles to
public/styles.cssusing CSS variables for theming
# Run tests (when implemented)
npm test
# Lint code (when configured)
npm run lint# Install production dependencies only
npm ci --only=production
# Start with PM2 (recommended)
pm2 start app.js --name "deepseek-chat"The application is fully responsive and works great on:
- π± Mobile phones (iOS/Android)
- π± Tablets (iPad, Android tablets)
- π» Desktop computers
- π₯οΈ Large screens
- API keys are stored securely in environment variables
- All user inputs are properly sanitized
- CORS is configured for security
- Rate limiting can be easily implemented
- No sensitive data is stored in frontend JavaScript
- Local Server:
npm start - Heroku: Ready for Heroku deployment
- Vercel: Frontend-ready for Vercel
- Railway: Easy Railway deployment
- DigitalOcean: App Platform ready
NODE_ENV=production
DEEPSEEK_API_KEY=your_production_api_key
PORT=8080
CORS_ORIGIN=https://yourdomain.comThis is a complete, production-ready application. To extend it:
- Fork the repository
- Create a feature branch
- Add your enhancements
- Test thoroughly
- Submit a pull request
If you need help:
- Check the troubleshooting section below
- Review the API documentation
- Check browser console for errors
- Ensure your DeepSeek API key is valid and has credits
"Failed to process chat message"
- Check your DeepSeek API key in
.env - Ensure you have API credits remaining
- Check internet connection
"Conversation not found"
- The conversation may have been deleted
- Check if
data/conversations.jsonexists and is readable
UI not loading
- Clear browser cache
- Check browser console for JavaScript errors
- Ensure all files are properly served
Streaming not working
- Disable ad blockers that might block server-sent events
- Check if your browser supports EventSource
- Try switching to regular (non-streaming) mode
Set NODE_ENV=development in your .env file for detailed error messages.
- Lightweight: Minimal dependencies, fast loading
- Efficient: Smart conversation context management
- Scalable: Ready for multiple concurrent users
- Optimized: Lazy loading and efficient rendering
You now have a powerful, professional-grade AI chat application that rivals commercial solutions! The app includes:
β Advanced AI conversation management β Multiple AI personalities β Beautiful, responsive interface β Real-time streaming responses β Persistent conversation history β Custom personality creation β Export functionality β Dark/light mode β Mobile-friendly design β Production-ready architecture
Enjoy chatting with your enhanced AI assistant! π