Skip to content
mihsanalamPublic

About

Syntonic | Real-time chat application built with Socket.IO, React Native, Node.js and MongoDB

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Syntonic Chat App

Syntonic is a premium, real-time mobile chat application built with React Native (Expo) and Node.js (Express). It leverages Socket.io for instant messaging, MongoDB for secure data storage, and Cloudinary for cloud-based media management.


📱 Features

  • Real-Time Communication: Zero-delay instant messaging powered by WebSockets via Socket.io.
  • Group & Direct Chats: Create channels and converse with multiple users simultaneously.
  • Secure Authentication: User registration and login utilizing JWT tokens and Bcrypt password hashing.
  • Media Uploads: Cloudinary integration for smooth profile pictures and image uploads.
  • Cross-Platform: Operates seamlessly on Android, iOS, and Web.
  • Offline Resiliency: Structured local storage using AsyncStorage for persistent auth states.

📷 Screenshots (Preview)

Here are some screenshots to give a visual overview of the application:

Welcome Signup Login
Profile DirectChatList GroupChatList

🛠️ Tech Stack

Layer Technologies Description
Frontend React Native, Expo (SDK 54), Expo Router Modern navigation and native component rendering
Real-Time Socket.io Client WebSocket wrapper for live event-driven communication
Backend Node.js, Express Fast, unopinionated, minimalist web framework
Database MongoDB, Mongoose NoSQL Document database with schema-based modeling
Authentication JWT, Bcrypt.js Stateless authorization and secure credential hashing
Media Cloudinary Cloud-based image storage and optimization

📂 Project Structure

syntonic/
├── backend/          # Node.js API & Socket.io Server
│   ├── config/       # Database configuration
│   ├── controllers/  # Auth & Message logic controllers
│   ├── modals/       # Mongoose schemas (User, Message, etc.)
│   ├── routes/       # Express route handlers
│   └── index.js      # Server entry point
│
├── frontend/         # React Native Expo Mobile App
│   ├── app/          # Expo Router (routes, layouts)
│   ├── assets/       # Static images and icons
│   ├── components/   # Reusable UI components
│   ├── constants/    # Theme styling and configuration
│   ├── context/      # Authentication & socket contexts
│   └── services/     # API request services (Axios)
│
└── screenshots/      # Application previews

🚀 Local Setup & Installation

1. Prerequisites

  • Node.js (v18 or higher recommended)
  • Git
  • Android Studio / Xcode (for running emulators)

2. Backend Setup

  1. Open a terminal and navigate to the backend folder:
    cd backend
  2. Install dependencies:
    npm install
  3. Create a .env file in the backend/ directory:
    MONGO_URL=your_mongodb_connection_string
    JWT_SECRET=your_jwt_secret_key
    PORT=3000
  4. Start the backend server in development mode:
    npm run dev

3. Frontend Setup

  1. Open a new terminal and navigate to the frontend folder:
    cd frontend
  2. Install dependencies:
    npm install
  3. Create a .env file in the frontend/ directory:
    # Set this to your local IP address for emulator testing, or the Render URL for production
    EXPO_PUBLIC_API_URL=http://localhost:3000
    
    EXPO_PUBLIC_CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    EXPO_PUBLIC_CLOUDINARY_UPLOAD_PRESET=your_upload_preset
  4. Run the development server:
    npm run start
  5. Press a (Android) or i (iOS) to launch the app in an emulator.

📡 Real-Time Socket.io API

The communication between the mobile frontend and backend is driven by real-time events. Below are the key socket events supported:

Event Name Type Payload Description
getConversations Emit/Listen {} / { success, data: [] } Fetches all conversations the logged-in user is a participant of.
newConversation Emit/Listen { type, participants, name, avatar } Creates a new direct (direct) or group (group) conversation.
newMessage Emit/Listen { conversationId, sender: { id, name, avatar }, content, attachment } Broadcasts a new chat message to all connected conversation participants.
getMessages Emit/Listen { conversationId } Fetches the full message history for a specific conversation.
updateProfile Emit/Listen { name, avatar } Updates a user's name or avatar, saves it to MongoDB, and returns a new JWT token.
getContacts Emit/Listen {} Retrieves all other registered users in the database to start a conversation.

🗄️ Database Schemas

User

{
  email: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  name: { type: String, required: true },
  avatar: { type: String, default: "" },
  created: { type: Date, default: Date.now }
}

Conversation

{
  type: { type: String, enum: ['direct', 'group'], required: true },
  name: String,
  participants: [{ type: Schema.Types.ObjectId, ref: 'User' }],
  lastMessage: { type: Schema.Types.ObjectId, ref: 'Message' },
  createdBy: { type: Schema.Types.ObjectId, ref: 'User' },
  avatar: { type: String, default: "" },
  createdAt: { type: Date, default: Date.now },
  updatedAt: { type: Date, default: Date.now }
}

Message

{
  conversationId: { type: Schema.Types.ObjectId, ref: 'Conversation', required: true },
  senderId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
  content: String,
  attachment: String,
  createdAt: Date,  // Managed by mongoose timestamps
  updatedAt: Date   // Managed by mongoose timestamps
}

🔄 Architecture & Data Flow

graph TD
    A[React Native / Expo App] -->|HTTPS REST API| B(Express Router)
    A -->|WebSocket Connection| C(Socket.io Gateway)
    B -->|Mongoose ODM| D[MongoDB Atlas]
    C -->|Mongoose ODM| D
    A -->|Image Uploads| E[Cloudinary CDN]
    E -->|Secure URLs| A
Loading

About

Syntonic | Real-time chat application built with Socket.IO, React Native, Node.js and MongoDB

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages