A feature-rich, real-time chat application built with React, TypeScript, Material-UI, and Firebase. This application supports one-to-one and group chats with media sharing capabilities.
- One-to-One Chat: Direct messaging between two users
- Group Chat: Multi-user group conversations
- Real-time Messaging: Instant message delivery using Firebase
- Message Types: Support for text, images, audio, voice notes, and documents
- Unread Message Counts: Track unread messages per chat
- Message Timestamps: See when messages were sent
- Image Sharing: Upload and share images (JPEG, PNG, GIF, WebP)
- Audio Files: Share audio files (MP3, WAV, OGG, M4A)
- Documents: Share PDFs, Word documents, and text files
- Voice Notes: Record and send voice messages
- File Preview: Preview images and file information
- Modern UI: Beautiful Material-UI design with responsive layout
- User Authentication: Secure login/signup with Firebase Auth
- User Profiles: Display names, avatars, and online status
- Chat Search: Find conversations quickly
- Responsive Design: Works on desktop and mobile devices
- Dark/Light Theme: Customizable theme support
- TypeScript: Full type safety and better development experience
- Firebase Integration: Real-time database, authentication, and storage
- Context API: Efficient state management
- Real-time Updates: Live chat updates using Firebase listeners
- File Upload: Drag & drop file sharing
- Voice Recording: Browser-based audio recording
- Frontend: React 18, TypeScript
- UI Framework: Material-UI (MUI) 5
- Backend: Firebase (Firestore, Auth, Storage)
- Build Tool: Vite
- Styling: Emotion (CSS-in-JS)
- Icons: Material Icons
- File Handling: React Dropzone
- Date Formatting: date-fns
Before running this application, you need:
- Node.js (version 16 or higher)
- npm or pnpm package manager
- Firebase Project with Firestore and Storage enabled
-
Clone the repository
git clone <repository-url> cd yii-chat
-
Install dependencies
pnpm install # or npm install
-
Firebase Setup
- Go to Firebase Console
- Create a new project or select existing one
- Enable Authentication (Email/Password)
- Enable Firestore Database
- Enable Storage
- Get your Firebase config
-
Configure Firebase
- Open
src/config/firebase.ts
- Replace the placeholder config with your Firebase project details:
const firebaseConfig = { apiKey: "your-api-key", authDomain: "your-project.firebaseapp.com", projectId: "your-project-id", storageBucket: "your-project.appspot.com", messagingSenderId: "123456789", appId: "your-app-id" };
- Open
-
Firestore Rules Set up the following Firestore security rules:
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { // Users can read/write their own data match /users/{userId} { allow read, write: if request.auth != null && request.auth.uid == userId; } // Chat rooms - users can read/write if they're participants match /chatRooms/{chatId} { allow read, write: if request.auth != null && request.auth.uid in resource.data.participants; } // Messages - users can read/write if they're in the chat match /messages/{messageId} { allow read, write: if request.auth != null && request.auth.uid in get(/databases/$(database)/documents/chatRooms/$(resource.data.chatId)).data.participants; } } }
-
Storage Rules Set up Firebase Storage rules:
rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow read, write: if request.auth != null; } } }
-
Development Mode
pnpm dev # or npm run dev
-
Build for Production
pnpm build # or npm run build
-
Preview Production Build
pnpm preview # or npm run preview
- Sign Up: Create a new account with email and password
- Sign In: Log in with your credentials
- Create Chat: Start a new one-to-one or group chat
- Send Messages: Type text or share media files
- Voice Notes: Record and send voice messages
- Text Messages: Type and send text messages
- Media Sharing: Drag & drop files or use the attachment button
- Voice Recording: Click the microphone button to record voice notes
- File Types: Support for images, audio, documents, and voice notes
- Real-time Updates: See messages as they arrive
- Profile: View and edit your profile information
- Status: Set your online/offline status
- Logout: Securely sign out of the application
src/
βββ components/
β βββ auth/ # Authentication components
β βββ chat/ # Chat-related components
β βββ Dashboard.tsx # Main dashboard
βββ contexts/ # React contexts
βββ config/ # Configuration files
βββ types/ # TypeScript type definitions
βββ App.tsx # Main application component
βββ main.tsx # Application entry point
- Authentication: Firebase Auth with email/password
- Authorization: Users can only access their own chats
- Data Validation: TypeScript types ensure data integrity
- Secure Rules: Firestore and Storage security rules
- Push Notifications: Real-time push notifications
- Video Calls: WebRTC integration
- Message Encryption: End-to-end encryption
- File Compression: Automatic image compression
- Message Reactions: Like, love, laugh reactions
- Message Threading: Reply to specific messages
- User Status: Custom status messages
- Chat Backup: Export chat history
- Multi-language: Internationalization support
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
If you encounter any issues:
- Check the Firebase configuration
- Verify Firestore and Storage rules
- Check browser console for errors
- Ensure all dependencies are installed
- Create an issue in the repository
- Material-UI for the beautiful component library
- Firebase for the robust backend services
- React team for the amazing framework
- Vite for the fast build tool
Happy Chatting! π