A modern, real-time chat application built with Flutter, WebSocket, and GetX for state management. This project demonstrates advanced Flutter development skills perfect for job interviews.
- Real-time messaging via WebSocket connection
- User authentication with username-based login
- Live user presence - see who's online/offline
- Message status tracking (pending, sent, delivered, read)
- Responsive design that works on all screen sizes
- Connection management with automatic reconnection
- GetX state management for reactive UI updates
- WebSocket service with heartbeat and reconnection logic
- Clean architecture with separation of concerns
- Local storage for user session persistence
- Error handling and connection recovery
- Type-safe models with JSON serialization
- Clean, modern login interface
- Username validation with real-time feedback
- Clear instructions for users
- Real-time message display with bubble UI
- Online users panel with avatars
- Connection status indicator
- Message input with send button
lib/
βββ core/
β βββ constants/ # App constants and configuration
β βββ services/ # Business logic services
β βββ utils/ # Utility functions
βββ models/ # Data models
β βββ user.dart # User model
β βββ chat_message.dart # Message model
βββ controllers/ # GetX controllers
β βββ auth_controller.dart # Authentication logic
β βββ chat_controller.dart # Chat functionality
βββ views/
β βββ screens/ # UI screens
β β βββ login_screen.dart
β β βββ chat_screen.dart
β βββ widgets/ # Reusable UI components
β βββ message_bubble.dart
β βββ user_list_item.dart
βββ bindings/ # Dependency injection
β βββ app_bindings.dart
βββ routes/ # Navigation configuration
βββ app_routes.dart
- GetX for reactive state management
- Rx observables for real-time updates
- Bindings for dependency injection
- Controllers for business logic separation
- Connection management with automatic reconnection
- Heartbeat mechanism to keep connections alive
- Message queuing for offline scenarios
- Error handling and connection recovery
- Flutter 3.10+ - UI framework
- Dart 3.0+ - Programming language
- GetX 4.6+ - State management and navigation
- WebSocket Channel - Real-time communication
- Shared Preferences - Local storage
- Dio - HTTP client
- Node.js - Server runtime
- ws - WebSocket library
- HTTP - Server framework
- Flutter SDK (3.10 or higher)
- Dart SDK (3.0 or higher)
- Node.js (14 or higher)
- npm or yarn
-
Clone and navigate to project
cd chati -
Install dependencies
flutter pub get
-
Run the app
flutter run
-
Install Node.js dependencies
npm install
-
Start the WebSocket server
npm start
Or for development with auto-restart:
npm run dev
-
Server will start on
- WebSocket:
ws://localhost:8080 - HTTP:
http://localhost:8080
- WebSocket:
- Start the demo server (see above)
- Launch the Flutter app
- Enter a username (3-20 characters, letters/numbers/underscores)
- Click "Join Chat"
- Start messaging!
- Multiple Users: Open the app in multiple browser windows/devices
- Real-time Messages: Messages appear instantly across all clients
- User Presence: See who's online/offline in the users panel
- Connection Status: Monitor connection state in the app bar
- Message Status: See delivery status (pending β sent β delivered)
- Auto-reconnection: Test by stopping/starting the server
Update the WebSocket URL in lib/core/constants/app_constants.dart:
static const String websocketUrl = 'ws://localhost:8080'; // Change for production- Connection timeout: 10 seconds
- Heartbeat interval: 30 seconds
- Max message length: 1000 characters
- Username length: 3-20 characters
- Connection Test: Start server, launch app, verify connection
- Message Test: Send messages between multiple instances
- User Management: Test login/logout functionality
- Error Handling: Stop server, verify reconnection logic
- Persistence: Close app, reopen, verify user session
flutter test- Update WebSocket URL for production server
- Add authentication (JWT tokens, etc.)
- Database integration for message history
- SSL/TLS for secure connections
- Error reporting (Sentry, Crashlytics)
- Analytics for user behavior tracking
# Android
flutter build apk --release
# iOS
flutter build ios --release
# Web
flutter build web --releaseJoin Chat
{
"type": "join",
"username": "john_doe",
"timestamp": "2023-12-30T09:00:00.000Z"
}Send Message
{
"type": "message",
"id": "12345",
"content": "Hello world!",
"senderId": "user123",
"senderName": "john_doe",
"timestamp": "2023-12-30T09:00:00.000Z"
}Heartbeat
{
"type": "ping"
}User Joined
{
"type": "user_joined",
"user": {
"id": "user123",
"username": "john_doe",
"isOnline": true,
"lastSeen": "2023-12-30T09:00:00.000Z"
}
}Chat Message
{
"type": "message",
"id": "12345",
"content": "Hello world!",
"senderId": "user123",
"senderName": "john_doe",
"timestamp": "2023-12-30T09:00:00.000Z",
"status": "sent"
}User List
{
"type": "user_list",
"users": [...]
}This is a demo project for job interview purposes. However, suggestions and improvements are welcome!
- Follow Flutter best practices
- Use meaningful commit messages
- Write clean, documented code
- Test thoroughly before submitting
This project is created for educational and demonstration purposes.
- Flutter Development: Modern UI with Material Design
- State Management: GetX with reactive programming
- Real-time Communication: WebSocket implementation
- Architecture: Clean architecture with separation of concerns
- Error Handling: Comprehensive error management
- Performance: Efficient state updates and UI rendering
- Real-time messaging with WebSocket
- Responsive design for multiple screen sizes
- Connection management with auto-reconnection
- User authentication and session persistence
- Clean code architecture with proper abstractions
- Comprehensive error handling
- Production-ready code quality
- Database integration for message history
- Push notifications for new messages
- Message encryption for security
- File sharing capabilities
- Group chat functionality
- Message reactions and threading
- Dark mode support
- Accessibility improvements
For questions about this project or interview discussions, please reach out through your preferred channel.
Built with β€οΈ using Flutter and GetX
