Skip to content

Priyansh7999/Chat-Application-React-Native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

    git clone https://github.com/Priyansh7999/Chat-Application-React-Native.git
    cd Chat-Application-React-Native
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Firebase Configuration

    • Create a Firebase project at Firebase Console
    • Enable Authentication (Email/Password provider)
    • Enable Firestore Database
    • Create a firebaseConfig.js file in your project root:
    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

    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

// 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

# Run tests
npm test

# Run with coverage
npm run test:coverage

πŸ“¦ Building for Production

Android (APK/AAB)

# Build APK
npx eas build --platform android --profile production --local

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

iOS (IPA)

# Build for App Store
npx eas build --platform ios --profile production

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

Web

# 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 file for details.

πŸ‘₯ Authors

πŸ™ 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.

⭐ Star this repo if you find it helpful!

Built with ❀️ by Priyansh Saxena using React Native Expo and Firebase

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors