A modern real-time chat application built with Flask-SocketIO featuring multiple message scheduling algorithms and a responsive UI.
- Features
- Project Structure
- Getting Started
- Technologies Used
- Message Scheduling Algorithms
- Usage Guide
- Configuration
- Requirements
- Key Features in Detail
- Contributing
- Troubleshooting
- Screenshots
- Future Enhancements
- License
- Real-time Communication: Instant messaging using WebSockets
- Multiple Scheduling Algorithms:
- First Come First Serve (FCFS)
- First In First Out (FIFO)
- Least Recently Used (LRU)
- Round Robin
- Priority Scheduling
- User Management: Automatic user numbering (user1, user2, etc.)
- Responsive Design: Modern UI with Tailwind CSS
- Message Alignment: Sender messages on right, receiver messages on left
- User List: Live display of connected users
- Visual Feedback: Different styling for sent vs received messages
- User Profile Display: Shows current logged-in user
- System Notifications: Join/leave chat notifications
- Username Validation: Ensures users enter a valid username
chat-app/
βββ app.py # Main application
βββ requirements.txt # Dependencies
βββ templates/
β βββ index.html # Chat interface
βββ static/
β βββ css/style.css # Styles
β βββ js/chat.js # JavaScript
β βββ images/ # Assets
βββ README.md
-
π₯ Clone the repository:
git clone https://github.com/miftah1299/chat-app.git cd chat-app -
π Create a virtual environment and install dependencies:
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate pip install -r requirements.txt
-
βΆοΈ Run the Flask application:python app.py
-
π Open your browser and navigate to:
http://127.0.0.1:5000 -
π¬ Start chatting:
- π€ Enter your username when prompted
- β¨οΈ Type messages and see them appear in real-time
- π Open multiple browser tabs to simulate multiple users
- Flask - Web framework
- Flask-SocketIO - Real-time communication
- Python collections (deque, OrderedDict) - Message queuing
- Eventlet - Asynchronous networking library
- Gunicorn - WSGI HTTP Server
- HTML5 - Structure
- Tailwind CSS - Modern utility-first CSS framework
- JavaScript - Client-side functionality
- Socket.IO - WebSocket client library
The application demonstrates various message processing algorithms:
-
FCFS (First Come First Serve):
- Messages processed in the order they arrive
- Simple queue-based implementation using
deque
-
FIFO (First In First Out):
- Similar to FCFS, processes messages sequentially
- Ensures fairness in message handling
-
LRU (Least Recently Used):
- Prioritizes least recently accessed messages
- Uses
OrderedDictfor timestamp tracking
-
Round Robin:
- Time-slice based message processing
- Gives each message equal processing time
-
Priority Scheduling:
- Messages processed based on priority levels
- Higher priority messages handled first
- Connection: When you connect, you'll be assigned a unique user ID (user1, user2, etc.)
- Profile: Your username is displayed at the top of the chat interface
- Messaging: Type messages in the input field and press "Send" or hit Enter
- Your Messages: Appear on the right side with blue styling
- Others' Messages: Appear on the left side with gray styling
- User List: Shows all currently connected users in real-time
- Notifications: System messages notify when users join or leave
- Port: Default port is 5000 (configurable in app.py)
- Host: Default host is 127.0.0.1 (configurable in app.py)
- CORS: Enabled for all origins (configurable in app.py)
- Algorithm: Change message processing algorithm in app.py
Flask==2.0.1
Flask-SocketIO==5.1.1
eventlet==0.38.2
gunicorn==23.0.0
- Instant message delivery using WebSocket technology
- No page refresh required
- Supports multiple concurrent users
- Clean and intuitive interface
- Responsive design works on all devices
- Visual distinctions between sent and received messages
- Smooth animations and transitions
- Automatic user identification and numbering
- Real-time user list updates
- Join/leave notifications
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Port already in use: Change the port in
app.py - Dependencies not installed: Run
pip install -r requirements.txt - Virtual environment issues: Recreate the virtual environment
- File sharing capabilities
- Dark/Light theme toggle
- User authentication and login
- Message history storage
- Message search functionality
This project is open source and available under the MIT License.
Made with β€οΈ using Flask-SocketIO and Tailwind CSS