An open API service indexing awesome lists of open source software.

https://github.com/priyansh7999/chat-application-react-native

A modern, real-time chat application built with React Native and Firebase, featuring seamless communication and social connectivity.
https://github.com/priyansh7999/chat-application-react-native

chat-application expo firebase react-native

Last synced: 3 months ago
JSON representation

A modern, real-time chat application built with React Native and Firebase, featuring seamless communication and social connectivity.

Awesome Lists containing this project

README

          

# Chatter ๐Ÿ’ฌ

A modern, real-time chat application built with React Native and Firebase, featuring seamless communication and social connectivity.

## ๐Ÿš€ Features

### Core Functionality
- **Real-time Messaging**: Instant messaging with live updates using Firebase Firestore
- **Email Authentication**: Secure user registration and login with email/password
- **Email Verification**: First-time users must verify their email before accessing the app
- **Unique Username System**: Each user gets a unique username for easy discovery
- **User Discovery**: Search and find other users by their unique username in explore tab
- **Friend Invitations**: Send and receive friend requests for one-on-one communication
- **Stories Feature**: Share 24-hour temporary image stories visible to your friends
- **Profile Management**: Comprehensive user profiles with bio, location, and profile images

### Advanced Features
- **Read Receipts**: Track message delivery and read status
- **Real-time Chat Previews**: Live updates of latest messages and timestamps
- **Typing Indicators**: See when friends are typing
- **Online Status**: Track user's last seen and online presence
- **Story Interactions**: Like friends' stories
- **Profile Customization**: Update bio, location (city/state), and profile pictures
- **Friend Management**: Organized friend lists and invitation system

### Security & Privacy
- Secure authentication with Firebase Auth
- Email verification for enhanced security
- Private messaging between connected users only
- Controlled friend connections through invitation system
- User blocking functionality
- Data validation and error handling

## ๐Ÿ› ๏ธ Tech Stack

- **Frontend**: React Native with Expo Router
- **Backend**: Firebase
- **Database**: Cloud Firestore (NoSQL)
- **Authentication**: Firebase Auth (Email/Password)
- **Real-time Updates**: Firestore real-time listeners
- **Development**: Expo CLI
- **State Management**: React Context API (AuthContext)
- **Navigation**: Expo Router with tab-based navigation

## ๐Ÿ“ฑ Screenshots

## ๐Ÿ”ง Installation & Setup

### Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- Expo CLI (`npm install -g @expo/cli`)
- Firebase project setup

### Installation Steps

1. **Clone the repository**
```bash
git clone https://github.com/Priyansh7999/Chat-Application-React-Native.git
cd Chat-Application-React-Native
```

2. **Install dependencies**
```bash
npm install
# or
yarn install
```

3. **Firebase Configuration**
- Create a Firebase project at [Firebase Console](https://console.firebase.google.com/)
- Enable Authentication (Email/Password provider)
- Enable Firestore Database
- Create a `firebaseConfig.js` file in your project root:
```javascript
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { getFirestore } from 'firebase/firestore';

const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-auth-domain",
projectId: "your-project-id",
storageBucket: "your-storage-bucket",
messagingSenderId: "your-messaging-sender-id",
appId: "your-app-id"
};

const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);
```

4. **Start the development server**
```bash
npx expo start
```

5. **Run on device/simulator**
- Install Expo Go app on your mobile device
- Scan the QR code from the terminal
- Or press 'i' for iOS simulator, 'a' for Android emulator

## ๐Ÿ“‹ Firebase Setup

### Firestore Database Structure
```
users/
โ”œโ”€โ”€ {userId}/
โ”‚ โ”œโ”€โ”€ uid: string
โ”‚ โ”œโ”€โ”€ email: string
โ”‚ โ”œโ”€โ”€ name: string
โ”‚ โ”œโ”€โ”€ username: string (unique)
โ”‚ โ”œโ”€โ”€ phone: string
โ”‚ โ”œโ”€โ”€ bio: string
โ”‚ โ”œโ”€โ”€ location: object
โ”‚ โ”‚ โ”œโ”€โ”€ city: string
โ”‚ โ”‚ โ””โ”€โ”€ state: string
โ”‚ โ”œโ”€โ”€ profileImage: string (URL)
โ”‚ โ”œโ”€โ”€ emailVerified: boolean
โ”‚ โ”œโ”€โ”€ createdAt: string (ISO)
โ”‚ โ”œโ”€โ”€ lastSeen: string (ISO)
โ”‚ โ”œโ”€โ”€ isOnline: boolean
โ”‚ โ”œโ”€โ”€ friends: array
โ”‚ โ”œโ”€โ”€ invitesSend: array
โ”‚ โ”œโ”€โ”€ invitesReceived: array
โ”‚ โ””โ”€โ”€ blockedUsers: array

chats/
โ”œโ”€โ”€ {chatId}/
โ”‚ โ”œโ”€โ”€ participants: array [userId1, userId2]
โ”‚ โ”œโ”€โ”€ createdAt: timestamp
โ”‚ โ”œโ”€โ”€ lastMessage: object
โ”‚ โ”‚ โ”œโ”€โ”€ text: string
โ”‚ โ”‚ โ”œโ”€โ”€ senderId: string
โ”‚ โ”‚ โ”œโ”€โ”€ createdAt: timestamp
โ”‚ โ”‚ โ”œโ”€โ”€ imageUrl: string (optional)
โ”‚ โ”‚ โ””โ”€โ”€ readBy: array
โ”‚ โ”œโ”€โ”€ lastUpdated: timestamp
โ”‚ โ”œโ”€โ”€ messagesCount: number
โ”‚ โ””โ”€โ”€ typingStatus: object
โ”‚ โ”œโ”€โ”€ {userId1}: boolean
โ”‚ โ””โ”€โ”€ {userId2}: boolean

chats/{chatId}/messages/
โ”œโ”€โ”€ {messageId}/
โ”‚ โ”œโ”€โ”€ senderId: string
โ”‚ โ”œโ”€โ”€ text: string
โ”‚ โ”œโ”€โ”€ imageUrl: string (optional)
โ”‚ โ”œโ”€โ”€ createdAt: timestamp
โ”‚ โ””โ”€โ”€ readBy: array

stories/
โ”œโ”€โ”€ {storyId}/
โ”‚ โ”œโ”€โ”€ userId: string
โ”‚ โ”œโ”€โ”€ username: string
โ”‚ โ”œโ”€โ”€ image: string (base64 or URL)
โ”‚ โ”œโ”€โ”€ profileImage: string
โ”‚ โ”œโ”€โ”€ createdAt: timestamp
โ”‚ โ”œโ”€โ”€ expireAt: date (24 hours from creation)
โ”‚ โ””โ”€โ”€ likes: array (optional)
```

### Security Rules
```javascript
// Firestore Security Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users can read/write their own data and read others' basic info
match /users/{userId} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.uid == userId;
}

// Chat documents readable by participants
match /chats/{chatId} {
allow read, write: if request.auth != null &&
request.auth.uid in resource.data.participants;
}

// Messages readable by chat participants
match /chats/{chatId}/messages/{messageId} {
allow read, write: if request.auth != null;
}

// Stories readable by authenticated users (friends only logic in app)
match /stories/{storyId} {
allow read: if request.auth != null;
allow write: if request.auth != null &&
request.auth.uid == resource.data.userId;
}
}
}
```

## ๐Ÿ—๏ธ Project Structure

```
chatter/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ (tabs)/ # HOME SCREENS TAB NAVIGATION
โ”‚ โ”‚ โ”œโ”€โ”€ Chats.jsx # Chat previews screen
โ”‚ โ”‚ โ”œโ”€โ”€ explore.jsx # User search & discovery
โ”‚ โ”‚ โ””โ”€โ”€ profile.jsx # User profile management
โ”‚ โ”œโ”€โ”€ (others)/ # SCREENS for chat between users and profile of other users
โ”‚ โ”‚ โ”œโ”€โ”€ friendprofile.jsx # Friend's profile view
โ”‚ โ”‚ โ”œโ”€โ”€ notfriendprofile.jsx # Non-friend user profile
โ”‚ โ”‚ โ””โ”€โ”€ ChatsBetweenFriends.jsx # One-to-one chat screen
โ”‚ โ”œโ”€โ”€ _layout.jsx # App layout configuration
โ”‚ โ”œโ”€โ”€ layout.jsx # Main app layout
โ”‚ โ”œโ”€โ”€ index.jsx # Onboarding screen
โ”‚ โ”œโ”€โ”€ signup.jsx # User registration
โ”‚ โ””โ”€โ”€ signin.jsx # User login
โ”œโ”€โ”€ components/
โ”‚ โ””โ”€โ”€ [Reusable UI Components]
โ”œโ”€โ”€ context/
โ”‚ โ””โ”€โ”€ AuthContext.jsx # Authentication & Firebase logic
โ”œโ”€โ”€ assets/
โ”œโ”€โ”€ firebaseConfig.js
โ”œโ”€โ”€ app.json
โ””โ”€โ”€ package.json
```

## ๐ŸŽฏ Usage

### Getting Started
1. **Register**: Sign up using your email and password
2. **Verify Email**: Check your email and click the verification link
3. **Complete Profile**: Set your unique username, bio, and location details
4. **Explore Users**: Use the explore tab to search for other users by username
5. **Send Friend Requests**: Send invites to connect with other users
6. **Start Chatting**: Begin real-time conversations with accepted friends
7. **Share Stories**: Post images as stories visible to friends for 24 hours
8. **View Stories**: Browse through friends' stories and like them

### Key Features Usage
- **Real-time Chat**: Messages appear instantly with read receipts
- **User Search**: Find users by their unique username in the explore tab
- **Friend Management**: Manage friend requests through invites system
- **Story Sharing**: Share moments that automatically expire after 24 hours
- **Profile Customization**: Update bio, location, and profile image
- **Online Status**: See when friends were last active

### Core Functionality Flow

**Authentication Flow:**
- Email/Password registration โ†’ Email verification โ†’ Profile setup โ†’ Username selection

**Chat Flow:**
- Chat previews list โ†’ Select friend โ†’ Real-time messaging โ†’ Read receipts

**Social Flow:**
- Explore users โ†’ Send friend request โ†’ Accept invite โ†’ Start communication

**Stories Flow:**
- Capture/Select image โ†’ Post story โ†’ View friends' stories โ†’ Like stories

## ๐Ÿ”„ App Flow

1. **Authentication Flow**
- Email/Password registration โ†’ Email verification โ†’ Profile completion (username, bio, location)

2. **Main App Navigation**
- **Chats Tab**: View chat previews โ†’ Select conversation โ†’ Real-time messaging
- **Explore Tab**: Search users by username โ†’ View profiles โ†’ Send friend requests
- **Profile Tab**: Manage personal profile โ†’ Update details โ†’ View/manage stories

3. **Social Interaction Flow**
- Search users โ†’ View profile โ†’ Send invite โ†’ Accept/Decline โ†’ Start chatting
- Post story โ†’ Friends view stories โ†’ Like stories โ†’ Auto-expire after 24h

4. **Chat Features**
- Real-time messaging with read receipts
- Message timestamps and delivery status
- Sorted chat previews by latest activity

## ๐Ÿงช Testing

```bash
# Run tests
npm test

# Run with coverage
npm run test:coverage
```

## ๐Ÿ“ฆ Building for Production

### Android (APK/AAB)
```bash
# Build APK
npx eas build --platform android --profile production --local

# Build AAB for Play Store
npx eas build --platform android --profile production
```

### iOS (IPA)
```bash
# Build for App Store
npx eas build --platform ios --profile production

# Build for TestFlight
npx eas build --platform ios --profile preview
```

### Web
```bash
# Build for web deployment
npx expo export --platform web
```

**Note**: You'll need to set up EAS (Expo Application Services) for production builds. Run `npx eas build:configure` to set up build profiles.

## ๐Ÿค Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ‘ฅ Authors

- **Priyansh Saxena** - *Initial work* - [Priyansh7999](https://github.com/Priyansh7999)

## ๐Ÿ™ Acknowledgments

- Firebase for backend services
- Expo team for the amazing development platform
- React Native community for continuous support

## ๐Ÿ“ž Support

If you have any questions or run into issues, please open an issue on GitHub or contact [priyanshsaxena7999@gmail.com](mailto:priyanshsaxena7999@gmail.com).

โญ **Star this repo if you find it helpful!**

*Built with โค๏ธ by Priyansh Saxena using React Native Expo and Firebase*