A modern web-based chat application enhanced with advanced artificial intelligence features to provide a smarter, more engaging chat experience. This application uses MongoDB for data storage, providing improved performance, scalability, and reliability, all wrapped in an intuitive web interface.
- Responsive design that works on desktop and mobile devices
- Real-time message updates without page refreshes
- Interactive UI with modals, tooltips, and dynamic content
- Visualizations for sentiment analysis and user interests
- Clean, intuitive navigation and user experience
- Create and join password-protected chat rooms with descriptions and tags
- Send and receive messages in real-time with timestamp tracking
- View chat history with enhanced formatting
- User authentication via room passwords
- Room categorization and metadata management
- Search and filtering capabilities
- Real-time analysis of message sentiment with compound scoring
- Visual sentiment indicators for messages
- Interactive sentiment reports with charts and graphs
- Emotional tone detection and tracking
- Identification of most positive and negative messages
- User sentiment statistics and visualization
- Personalized room recommendations using multiple algorithms:
- Content-based filtering using TF-IDF vectorization
- Collaborative filtering based on user behavior
- Topic modeling using Latent Dirichlet Allocation (LDA)
- Hybrid recommendations combining multiple approaches
- Explanation of why rooms are recommended
- Similar room discovery
- Trending topics identification across all chat rooms
- Recommendation history tracking and analysis
- Intelligent chatbot that can participate in conversations
- Command-based interaction system
- Conversation summarization
- Knowledge base for common questions
- Learning capabilities from user interactions
- Smart text completion as you type
- Personalized suggestions based on your writing style
- Context-aware word predictions
- Learning system that improves over time
- Automatic interest extraction from messages
- Interactive interest visualization with charts
- Personalized user profiles
- Activity tracking and statistics
- Flask web framework for backend
- Bootstrap 5 for responsive frontend design
- JavaScript for interactive features
- RESTful API for client-server communication
- WebSockets for real-time updates
- Document-based NoSQL database for flexible schema
- Collections for users, rooms, messages, and AI data
- Efficient indexing for improved query performance
- Structured data model with relationships
- Automatic backup and restore capabilities
- Advanced search and filtering functionality
- Seamless migration from previous file-based storage
- Natural Language Processing (NLP) for sentiment analysis and interest extraction
- Multiple recommendation algorithms (content-based, collaborative, topic modeling)
- TF-IDF and Count vectorization for text processing
- Latent Dirichlet Allocation (LDA) for topic modeling
- N-gram models for predictive text
- Rule-based and retrieval-based chatbot system
- Interactive data visualization with Chart.js
- Python 3.6 or higher
- MongoDB (local installation or MongoDB Atlas)
- Required packages:
- Flask
- pymongo
- dnspython
- python-dotenv
- nltk
- scikit-learn
- matplotlib
- numpy
- pandas
- Clone the repository
- Install required packages:
pip install -r requirements.txt - Configure MongoDB:
- Create a
.envfile in the project root with the following content:MONGO_URI=mongodb://localhost:27017/ DB_NAME=ai_chat_app SECRET_KEY=your_secret_key_here - For MongoDB Atlas, use the connection string provided by Atlas:
MONGO_URI=mongodb+srv://<username>:<password>@<cluster>.mongodb.net/
- Create a
- Run the web application:
python app.py- On first run, the application will automatically migrate data from the old file-based storage to MongoDB
- Open your browser and navigate to:
http://localhost:5000
- Login: Enter a username to identify yourself in the chat
- Browse Rooms: View available chat rooms with descriptions and tags
- Create Room: Create a new room with password, description, and tags
- Join Room: Enter an existing room using its password
- Chat: Send and receive messages in real-time
- AI Features: Access sentiment analysis, recommendations, and more through the web interface
- Sentiment Analysis: View sentiment reports with interactive charts
- Recommendations: Get personalized room suggestions
- Predictive Text: See word suggestions as you type
- AI Assistant: Chat with the AI bot using @AIBot mentions
- User Stats: View your activity and interest profile
app.py- Flask web application with routes and API endpointsmongodb_connector.py- MongoDB database connector with data modelssentiment_analyzer.py- Sentiment analysis module with visualizationrecommendation_system.py- Multi-algorithm recommendation systemchatbot_assistant.py- AI chatbot implementation with learning capabilitiespredictive_text.py- Predictive text system with personalizationrequirements.txt- Package dependencies.env- Environment variables for MongoDB connection
templates/- HTML templates for web pagesbase.html- Base template with common elementsindex.html- Home pagelogin.html- User login pagerooms.html- Room listing pagecreate_room.html- Room creation formjoin_room.html- Room joining formchat_room.html- Main chat interface
static/- Static assetscss/style.css- Custom stylesjs/main.js- JavaScript for interactive featuresimages/- Images and illustrations
The application uses MongoDB for data storage with the following collections:
users- Stores user profiles, interests, and activityrooms- Stores room information, metadata, and settingsmessages- Stores all chat messages with timestamps and sentimentai_data- Stores AI-related data like chatbot knowledge base
The application will automatically migrate data from the old file-based storage to MongoDB on first run. Backups are stored in the backups/ directory.
The application provides a RESTful API for client-server communication:
GET /api/messages/<room_name>- Get messages from a roomPOST /api/messages/<room_name>- Send a message to a roomGET /api/sentiment/<room_name>- Get sentiment analysis for a roomGET /api/recommendations/<username>- Get room recommendationsGET /api/trending- Get trending topicsGET /api/user/<username>- Get user statisticsGET /api/predict- Get word predictions
- Secure user registration and login with email and password
- Password hashing with bcrypt
- Session management with MongoDB and Redis
- User profile management
- Password reset functionality
- Document-based NoSQL database for flexible schema
- Collections for users, rooms, messages, and AI data
- Advanced queries with MongoDB's aggregation framework
- Efficient indexing for improved query performance
- Automatic data migration from file-based storage
- High-performance in-memory caching
- Cached room messages for faster loading
- User data caching to reduce database load
- Analytics caching for expensive computations
- Session storage for improved authentication performance
- Rate limiting implementation
- Real-time message delivery without page refreshes
- User presence indicators (online/offline status)
- Typing indicators
- Join/leave notifications
- Room-based communication channels
- Docker containerization for consistent environments
- Docker Compose for local development
- Deployment guides for Heroku, AWS, and Azure
- Environment configuration for different platforms
- Scaling considerations for high traffic
- Integration with external AI APIs (OpenAI, Hugging Face)
- Advanced NLP with transformer models
- Image generation from text descriptions
- Voice message transcription
- Mobile application with React Native
- User authentication with OAuth
- End-to-end encryption for messages
This project is licensed under the MIT License - see the LICENSE file for details.
- Flask for the web framework
- MongoDB for the database system
- PyMongo for MongoDB integration
- Bootstrap for responsive design
- Chart.js for interactive visualizations
- NLTK for natural language processing
- Scikit-learn for machine learning components
- Matplotlib and Pandas for data visualization
- NumPy for numerical operations