maheshsingh20/ChatFlix

โ˜… 1Forks 0JavaScriptGitHub โ†—Compare

README

๐Ÿ’ฌ ChatFlix V2.0

A modern, full-featured real-time chat application built with React Native (Expo) and Node.js.

Version React Native Node.js Socket.io

๐ŸŒŸ Features

Authentication & User Management

  • โœ… Email/password authentication with JWT
  • โœ… User registration and login
  • โœ… Secure password hashing with bcrypt
  • โœ… Persistent sessions
  • โœ… User profiles with display names and avatars

Messaging

  • โœ… Real-time one-to-one private chats
  • โœ… Group chat support (backend ready)
  • โœ… Message delivery status (sent โœ“ / delivered โœ“โœ“ / read โœ“โœ“)
  • โœ… Typing indicators with animations
  • โœ… Emoji support
  • โœ… Message timestamps
  • โœ… Chat history with pagination
  • โœ… Auto-scroll to latest messages

User Experience

  • โœ… Dark/Light theme toggle with iOS-style colors
  • โœ… Color-coded user avatars
  • โœ… Online/offline status indicators
  • โœ… User search by username or email
  • โœ… Contact list management
  • โœ… Pull-to-refresh chat list
  • โœ… Unread message badges
  • โœ… Smooth animations and transitions
  • โœ… Loading states and error handling

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MongoDB Atlas account (or local MongoDB)
  • Expo CLI for mobile app development
  • Android Studio (for Android) or Xcode (for iOS)

Backend Setup

cd backend
npm install

# Create .env file with your credentials
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secret

# Start server
npm start

Backend will run on http://localhost:3000

Frontend Setup

cd frontend
npm install

# Start Expo development server
npm start

# Run on specific platform
npm run android  # Android
npm run ios      # iOS

๐Ÿ“ฑ Live Deployment

๐Ÿ—๏ธ Architecture

Tech Stack

Frontend:

  • React Native 0.72.6 with Expo SDK 49
  • React Navigation v6 for routing
  • Socket.io-client v4.6 for real-time communication
  • Axios for REST API calls
  • AsyncStorage for local data persistence
  • Moment.js for date/time formatting

Backend:

  • Node.js with Express.js
  • Socket.io v4 for WebSocket connections
  • MongoDB with Mongoose ODM
  • JWT for authentication
  • bcryptjs for password hashing
  • CORS enabled for cross-origin requests

Project Structure

ChatFlix/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ database.js           # MongoDB connection
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ authController.js     # Authentication logic
โ”‚   โ”‚   โ”œโ”€โ”€ userController.js     # User management
โ”‚   โ”‚   โ”œโ”€โ”€ chatController.js     # Chat room management
โ”‚   โ”‚   โ””โ”€โ”€ messageController.js  # Message handling (V1)
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ auth.js               # JWT verification
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.js               # User schema (V1)
โ”‚   โ”‚   โ”œโ”€โ”€ EnhancedUser.js       # User schema with auth (V2)
โ”‚   โ”‚   โ”œโ”€โ”€ ChatRoom.js           # Chat room schema
โ”‚   โ”‚   โ”œโ”€โ”€ Message.js            # Message schema (V1)
โ”‚   โ”‚   โ””โ”€โ”€ EnhancedMessage.js    # Message with status (V2)
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ authRoutes.js         # Auth endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ userRoutes.js         # User endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ chatRoutes.js         # Chat endpoints
โ”‚   โ”‚   โ””โ”€โ”€ messageRoutes.js      # Message endpoints (V1)
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ””โ”€โ”€ socketHandler.js      # Socket.io event handlers
โ”‚   โ”œโ”€โ”€ .env                      # Environment variables
โ”‚   โ”œโ”€โ”€ server.js                 # Application entry point
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ EnhancedMessageBubble.js  # Message display with status
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ TypingIndicator.js        # Typing animation
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ UserAvatar.js             # Color-coded avatars
โ”‚   โ”‚   โ”œโ”€โ”€ screens/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AuthScreen.js             # Login/Signup
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ChatListScreen.js         # Conversation list
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ChatRoomScreen.js         # Chat interface
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ContactsScreen.js         # User search & contacts
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ apiService.js             # REST API integration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ socketService.js          # Socket.io client
โ”‚   โ”‚   โ””โ”€โ”€ utils/
โ”‚   โ”‚       โ”œโ”€โ”€ config.js                 # App configuration
โ”‚   โ”‚       โ””โ”€โ”€ theme.js                  # Dark/Light themes
โ”‚   โ”œโ”€โ”€ assets/                           # Images and icons
โ”‚   โ”œโ”€โ”€ App.js                            # Root component
โ”‚   โ”œโ”€โ”€ app.json                          # Expo configuration
โ”‚   โ”œโ”€โ”€ eas.json                          # EAS Build configuration
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ DEPLOY_NOW.md                         # Deployment guide
โ””โ”€โ”€ README.md                             # This file

๐Ÿ”Œ API Endpoints

Authentication

POST /api/auth/register    # Register new user
POST /api/auth/login       # Login user

Users

GET  /api/users/contacts          # Get user's contacts
GET  /api/users/search?query=     # Search users

Chat Rooms

GET  /api/chats/rooms                    # Get user's chat rooms
GET  /api/chats/rooms/private/:userId    # Get/create private room
POST /api/chats/rooms/group              # Create group room
GET  /api/chats/rooms/:roomId/messages   # Get room messages
POST /api/chats/rooms/:roomId/messages   # Send message (REST)

Health Check

GET  /health    # Server status

๐Ÿ”ง Socket.io Events

Client โ†’ Server

'join:room'         // Join a chat room
'leave:room'        // Leave a chat room
'message:send'      // Send a message
'typing:start'      // User started typing
'typing:stop'       // User stopped typing

Server โ†’ Client

'message:new'       // New message received
'typing:start'      // Someone is typing
'typing:stop'       // Typing stopped
'user:online'       // User came online
'user:offline'      // User went offline

๐ŸŽจ Themes

Light Mode

  • Clean white/blue design
  • High contrast for readability
  • iOS-inspired colors

Dark Mode

  • Pure black background (#000000)
  • iOS-style accent colors
  • Reduced eye strain
  • OLED-friendly

๐Ÿ” Environment Variables

Backend (.env)

PORT=3000
MONGODB_URI=mongodb+srv://username:[email protected]/chatapp
JWT_SECRET=your_super_secret_key_here
JWT_EXPIRE=30d
NODE_ENV=production

Frontend (.env - optional)

EXPO_PUBLIC_API_URL=https://chatflix-sjfr.onrender.com
EXPO_PUBLIC_SOCKET_URL=https://chatflix-sjfr.onrender.com

๐Ÿ“ฆ Building for Production

Android APK

cd frontend
npx eas-cli@latest build --platform android --profile preview

iOS IPA

cd frontend
npx eas-cli@latest build --platform ios --profile preview

Build takes 10-15 minutes. Download link will be provided upon completion.

๐Ÿงช Testing

Backend Testing

# Health check
curl https://chatflix-sjfr.onrender.com/health

# Register user
curl -X POST https://chatflix-sjfr.onrender.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"test","email":"[email protected]","password":"test123"}'

# Login
curl -X POST https://chatflix-sjfr.onrender.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"test123"}'

Frontend Testing

  1. Install APK on Android device
  2. Register a new account
  3. Login with credentials
  4. Search for other users
  5. Start a conversation
  6. Send messages and test real-time delivery
  7. Toggle dark/light mode
  8. Test typing indicators

๐Ÿšข Deployment

See DEPLOY_NOW.md for detailed deployment instructions.

Quick Deploy Steps:

  1. Backend on Render: Connect GitHub, add environment variables, deploy
  2. Frontend APK: Run EAS build command, wait 10-15 minutes
  3. Test: Install APK and verify all features

๐Ÿ› Troubleshooting

Backend Issues

  • Cannot connect to MongoDB: Check MONGODB_URI format and credentials
  • JWT errors: Ensure JWT_SECRET is set in environment variables
  • Port in use: Change PORT in .env or kill process using port 3000

Frontend Issues

  • Cannot connect to server: Verify API_URL in config.js
  • Build fails: Delete node_modules and package-lock.json, reinstall
  • Socket disconnects: Check CORS settings on backend
  • Dependencies conflict: Use exact versions specified in package.json

๐Ÿ“ Version History

V2.0.0 (Current) - Complete Rewrite

  • Full authentication system with JWT
  • Room-based architecture (private & group chats)
  • Enhanced UI with dark/light themes
  • Typing indicators and message status
  • User search and contacts
  • Improved security and scalability

V1.0.0 - Initial Release

  • Basic real-time chat
  • Simple username-based login
  • Global chat room
  • Message persistence

๐Ÿค Contributing

This is a personal project, but suggestions and feedback are welcome!

๐Ÿ“„ License

This project is open source and available for learning purposes.

๐Ÿ‘จโ€๐Ÿ’ป Author

Mahesh Singh

๐Ÿ™ Acknowledgments

  • Built with React Native and Expo
  • Real-time powered by Socket.io
  • Database: MongoDB Atlas
  • Deployed on Render

Status: โœ… Production Ready | Version: 2.0.0 | Last Updated: July 2026

Issues