A modern AI-powered chat application built with Stream Chat, OpenAI, and web search capabilities. This full-stack application provides an intelligent writing assistant that can help with content creation, research, and real-time collaboration.
- Real-time Chat: Powered by GetStream.io for seamless messaging
- AI Writing Assistant: OpenAI GPT-4 integration for intelligent content generation
- Web Search: Live web search capabilities using Tavily API for current information
- Modern UI: Beautiful React interface with dark/light theme support
- Writing Prompts: Categorized writing prompts for business, content, communication, and creative tasks
- Agent Management: Dynamic AI agent lifecycle management
- Secure Authentication: JWT-based token authentication
- Responsive Design: Mobile-first design with Tailwind CSS
- Node.js/Express server
- Stream Chat server-side integration
- OpenAI API for AI responses
- Tavily API for web search functionality
- Agent management system with automatic cleanup
- React with TypeScript
- Stream Chat React components
- Tailwind CSS + shadcn/ui for modern styling
- Vite for fast development and building
- Node.js 20 or higher
- npm or yarn package manager
- GetStream.io account (free tier available)
- OpenAI API account
- Tavily API account (for web search)
git clone <your-repository-url>
cd chat-ai-appNavigate to the backend directory:
cd nodejs-ai-assistantInstall dependencies:
npm installCreate environment file by copying the example:
cp .env.example .envConfigure your .env file with the following keys:
# GetStream credentials - Get these from https://getstream.io/dashboard
STREAM_API_KEY=your_stream_api_key_here
STREAM_API_SECRET=your_stream_api_secret_here
# OpenAI API key - Get from https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here
# Tavily API key - Get from https://tavily.com
TAVILY_API_KEY=your_tavily_api_key_hereNavigate to the frontend directory:
cd ../react-stream-ai-assistantInstall dependencies:
npm installCreate environment file:
cp .env.example .envConfigure your .env file:
# Stream Chat Configuration
VITE_STREAM_API_KEY=your_stream_api_key_here
# Backend URL
VITE_BACKEND_URL=http://localhost:3000- Sign up at GetStream.io
- Create a new Chat application
- Copy your API Key and API Secret from the dashboard
- Use the same API Key in both backend and frontend
.envfiles
- Sign up at OpenAI Platform
- Navigate to API Keys section
- Create a new API key
- Add it to your backend
.envfile
- Sign up at Tavily
- Get your API key from the dashboard
- Add it to your backend
.envfile
cd nodejs-ai-assistant
npm run devThe backend will run on http://localhost:3000
cd react-stream-ai-assistant
npm run devThe frontend will run on http://localhost:8080
GetStream.io is a cloud-based API service that provides real-time chat functionality. Here's how it integrates with our app:
- Stream Chat Client: Handles all chat operations and real-time updates
- Channels: Individual chat rooms where messages are exchanged
- Users: Authenticated participants in the chat
- Messages: Text, files, reactions, and custom data
- Tokens: JWT-based authentication for secure access
graph TD
A[Frontend React App] --> B[Stream Chat React Components]
B --> C[Stream Chat API]
C --> D[Backend Node.js Server]
D --> E[OpenAI API]
D --> F[Tavily Web Search]
D --> G[AI Agent Management]
- Real-time Messaging: Instant message delivery and updates
- User Presence: Online/offline status indicators
- Channel Management: Create, join, and manage chat channels
- Message Threading: Support for threaded conversations
- File Uploads: Share images and documents
- Custom Fields: Extended message and user data
- Webhooks: Server-side event handling
The application features a sophisticated AI agent management system:
- Creation: AI agents are created per channel when requested
- Initialization: OpenAI assistant setup with web search capabilities
- Message Handling: Processes user messages and generates responses
- Web Search: Automatically searches the web for current information
- Cleanup: Automatic disposal after inactivity
- Content Writing: Various writing tasks from business to creative
- Web Research: Live search for current information and facts
- Context Awareness: Maintains conversation context
- Customizable Prompts: Specialized writing assistance
The frontend uses modern UI components built with:
- Radix UI: Accessible component primitives
- Tailwind CSS: Utility-first CSS framework
- shadcn/ui: Beautiful, customizable components
- Lucide React: Modern icon library
- Dark Mode Support: System preference detection
GET /- Health check and server statusPOST /start-ai-agent- Initialize AI agent for a channelPOST /stop-ai-agent- Stop and cleanup AI agentGET /agent-status- Check AI agent statusPOST /token- Generate user authentication tokens
- JWT Authentication: Secure token-based authentication
- Environment Variables: Sensitive data protection
- CORS Configuration: Cross-origin request security
- Token Expiration: Automatic token refresh system
- Input Validation: Server-side validation for all requests
- Set environment variables on your hosting platform
- Run
npm run startfor production - Ensure PORT is configured (defaults to 3000)
- Run
npm run buildto create production build - Deploy the
distfolder to your static hosting service - Configure environment variables for production
cd nodejs-ai-assistant
npm run dev # Starts with nodemon for auto-reloadcd react-stream-ai-assistant
npm run dev # Starts Vite dev server# Backend
cd nodejs-ai-assistant
npm run start
# Frontend
cd react-stream-ai-assistant
npm run build- Node.js - Runtime environment
- Express - Web framework
- Stream Chat - Real-time messaging
- OpenAI - AI language model
- Axios - HTTP client
- CORS - Cross-origin resource sharing
- TypeScript - Type safety
- React - UI library
- TypeScript - Type safety
- Vite - Build tool
- Stream Chat React - Chat UI components
- Tailwind CSS - Styling
- Radix UI - Accessible components
- React Hook Form - Form handling
- React Router - Navigation
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For support and questions:
- Check the GetStream.io Documentation
- Review OpenAI API Documentation
- Create an issue in this repository
Built with β€οΈ using GetStream.io, OpenAI, and modern web technologies.