Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ก Bluetooth Chat Web โ€” Secure Wireless Messaging Platform

React Vite PWA TypeScript Bluetooth AES

Revolutionary Peer-to-Peer Messaging via Web Bluetooth API

Secure, private, and lightning-fast communication without internet connectivity


Live Demo Documentation Install PWA

๐ŸŒŸ Revolutionary Communication Platform

๐ŸŽฏ What Makes It Extraordinary

Bluetooth Chat Web revolutionizes wireless communication by enabling secure, peer-to-peer messaging directly through your browser. No servers, no internet requiredโ€”just pure device-to-device connectivity powered by cutting-edge Web Bluetooth technology.

graph LR
    A[๐Ÿ“ฑ Device A] -->|๐Ÿ”ต Bluetooth LE| B[๐Ÿ” AES Encryption]
    B --> C[๐Ÿ“ก Web Bluetooth API]
    C --> D[๐Ÿ’ฌ Real-time Chat]
    D --> E[๐Ÿ”“ Decryption]
    E --> F[๐Ÿ“ฑ Device B]
    
    G[๐ŸŒ PWA Service Worker] --> D
    H[๐Ÿ”’ HTTPS Security] --> C
    
    style A fill:#e1f5fe
    style D fill:#f3e5f5
    style F fill:#e8f5e8
Loading

โœจ Core Capabilities Matrix

Feature Technology Benefit
๐Ÿ“ก Bluetooth Messaging Web Bluetooth API Direct device communication without internet
๐Ÿ” Military-Grade Encryption AES-256 Encryption End-to-end message security
๐Ÿ“ฑ Progressive Web App Service Workers + Manifest Install as native mobile app
โšก Lightning Performance Vite Build System Sub-second load times
๐ŸŒ Secure Communication HTTPS/TLS Protocol Protected data transmission
๐Ÿ’ฌ Real-time Interface React 18 Features Smooth, responsive chat experience

๐Ÿš€ Comprehensive Features

๐Ÿ“ก Advanced Bluetooth Communication

Web Bluetooth API Integration

  • Device Discovery: Automatic scanning for nearby Bluetooth devices
  • GATT Protocol: Generic Attribute Profile for device communication
  • Service UUID Management: Custom Bluetooth service identifiers
  • Characteristic Handling: Read/write operations for data transfer
  • Connection Monitoring: Real-time connection status tracking

Smart Connection Management

// Advanced Bluetooth connection with error handling
async function connectToDevice() {
  try {
    const device = await navigator.bluetooth.requestDevice({
      acceptAllDevices: true,
      optionalServices: ['battery_service', 'custom_chat_service']
    });
    
    const server = await device.gatt.connect();
    return server;
  } catch (error) {
    console.error('Bluetooth connection failed:', error);
  }
}

๐Ÿ” Enterprise-Grade Security

AES-256 Encryption System

  • Optional Encryption: Toggle encryption on/off based on privacy needs
  • Key Exchange: Secure key sharing between devices
  • Message Integrity: Cryptographic hash verification
  • Forward Secrecy: New keys for each session

Security Architecture

// AES encryption implementation
import CryptoJS from 'crypto-js';

function encryptMessage(message, secretKey) {
  return CryptoJS.AES.encrypt(message, secretKey).toString();
}

function decryptMessage(ciphertext, secretKey) {
  const bytes = CryptoJS.AES.decrypt(ciphertext, secretKey);
  return bytes.toString(CryptoJS.enc.Utf8);
}

๐Ÿ“ฑ Progressive Web App Excellence

PWA Features

  • Offline Functionality: Works without internet connection
  • Install Prompt: Add to home screen capability
  • Background Sync: Message queue for offline messages
  • Push Notifications: Alert users of new messages
  • App Icons: Custom icons for all device types

Service Worker Configuration

// Advanced service worker for offline support
self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open('bluetooth-chat-v1').then((cache) => {
      return cache.addAll([
        '/',
        '/index.html',
        '/assets/main.js',
        '/assets/styles.css'
      ]);
    })
  );
});

๐Ÿ’ฌ Real-Time Chat Interface

Modern UI Components

  • Message Bubbles: Styled sender/receiver differentiation
  • Typing Indicators: Real-time typing status
  • Read Receipts: Message delivery confirmation
  • Emoji Support: Rich text formatting
  • File Sharing: Bluetooth file transfer capability

โš™๏ธ Advanced Technology Stack

Frontend Architecture

Component Technology Purpose
Framework React 18+ Modern UI with concurrent features
Build Tool Vite 5.0+ Lightning-fast HMR and builds
Language TypeScript Type-safe development
Styling Tailwind CSS Utility-first responsive design
State Management Zustand/Redux Predictable state updates

Core Technologies

Component Technology Purpose
Communication Web Bluetooth API Device-to-device connectivity
Encryption CryptoJS (AES-256) Secure message encryption
PWA Workbox + Vite PWA Plugin Progressive web app features
Security HTTPS/TLS Secure communication protocol

๐Ÿ—๏ธ Project Architecture

๐Ÿ“‚ Clean Code Structure

bluetooth-chat-web/
โ”œโ”€โ”€ ๐Ÿ“ public/                          # Static assets
โ”‚   โ”œโ”€โ”€ manifest.json                   # PWA manifest
โ”‚   โ”œโ”€โ”€ icons/                          # App icons (multiple sizes)
โ”‚   โ””โ”€โ”€ service-worker.js               # Custom service worker
โ”œโ”€โ”€ ๐Ÿ“ src/                             # Source code
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ components/                  # React components
โ”‚   โ”‚   โ”œโ”€โ”€ BluetoothScanner.tsx        # Device discovery
โ”‚   โ”‚   โ”œโ”€โ”€ ChatInterface.tsx           # Main chat UI
โ”‚   โ”‚   โ”œโ”€โ”€ MessageBubble.tsx           # Message display
โ”‚   โ”‚   โ”œโ”€โ”€ ConnectionStatus.tsx        # Connection indicator
โ”‚   โ”‚   โ””โ”€โ”€ EncryptionToggle.tsx        # Security controls
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ hooks/                       # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useBluetoothConnection.ts   # Bluetooth management
โ”‚   โ”‚   โ”œโ”€โ”€ useEncryption.ts            # Encryption utilities
โ”‚   โ”‚   โ””โ”€โ”€ usePWA.ts                   # PWA features
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ utils/                       # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ bluetooth.ts                # Bluetooth helpers
โ”‚   โ”‚   โ”œโ”€โ”€ encryption.ts               # Crypto functions
โ”‚   โ”‚   โ””โ”€โ”€ storage.ts                  # Local storage helpers
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ types/                       # TypeScript definitions
โ”‚   โ”‚   โ”œโ”€โ”€ bluetooth.d.ts              # Bluetooth types
โ”‚   โ”‚   โ””โ”€โ”€ message.d.ts                # Message types
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ styles/                      # Stylesheets
โ”‚   โ”‚   โ””โ”€โ”€ global.css                  # Global styles
โ”‚   โ”œโ”€โ”€ App.tsx                         # Main application
โ”‚   โ””โ”€โ”€ main.tsx                        # Entry point
โ”œโ”€โ”€ ๐Ÿ“ cert/                            # SSL certificates (development)
โ”‚   โ”œโ”€โ”€ key.pem                         # Private key
โ”‚   โ””โ”€โ”€ cert.pem                        # Certificate
โ”œโ”€โ”€ vite.config.ts                      # Vite configuration
โ”œโ”€โ”€ tsconfig.json                       # TypeScript config
โ”œโ”€โ”€ tailwind.config.js                  # Tailwind config
โ”œโ”€โ”€ package.json                        # Dependencies
โ””โ”€โ”€ README.md                           # Documentation

โšก Lightning-Fast Setup

๐Ÿ”ง Prerequisites

Requirement Version Purpose
Node.js 18.0+ Runtime environment
npm/yarn Latest Package management
OpenSSL 1.1.1+ SSL certificate generation
Chrome/Edge Latest Web Bluetooth support

๐Ÿš€ Quick Installation

1. Clone & Install

# Clone the repository
git clone https://github.com/your-username/bluetooth-chat-web.git
cd bluetooth-chat-web

# Install dependencies
npm install

# Or using yarn
yarn install

2. SSL Certificate Setup (Local Development)

Why HTTPS is Required:

  • Web Bluetooth API requires secure context (HTTPS)
  • PWA features need HTTPS for service workers
  • Browser security policies mandate secure connections

Generate Self-Signed Certificate:

# Generate SSL certificate and private key
openssl req -x509 -newkey rsa:2048 -nodes \
  -keyout key.pem -out cert.pem -days 365 \
  -subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"

# Create cert directory and move files
mkdir -p cert
mv key.pem cert/
mv cert.pem cert/

# Verify certificate generation
ls -la cert/

3. Development Server

# Start development server with HTTPS
npm run dev

# Server will start at:
# https://localhost:5173

Access the Application:

https://localhost:5173

Trust the Certificate:

  • Chrome: Click "Advanced" โ†’ "Proceed to localhost"
  • Edge: Click "Advanced" โ†’ "Continue to localhost"
  • Firefox: Add security exception

๐Ÿ”ง Vite Configuration

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { VitePWA } from 'vite-plugin-pwa';
import fs from 'fs';

export default defineConfig({
  plugins: [
    react(),
    VitePWA({
      registerType: 'autoUpdate',
      includeAssets: ['favicon.ico', 'robots.txt', 'icons/*.png'],
      manifest: {
        name: 'Bluetooth Chat Web',
        short_name: 'BT Chat',
        description: 'Secure Bluetooth messaging platform',
        theme_color: '#0082FC',
        background_color: '#ffffff',
        display: 'standalone',
        orientation: 'portrait',
        icons: [
          {
            src: '/icons/icon-192.png',
            sizes: '192x192',
            type: 'image/png'
          },
          {
            src: '/icons/icon-512.png',
            sizes: '512x512',
            type: 'image/png',
            purpose: 'any maskable'
          }
        ]
      },
      workbox: {
        globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
        runtimeCaching: [
          {
            urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
            handler: 'CacheFirst',
            options: {
              cacheName: 'google-fonts-cache',
              expiration: {
                maxEntries: 10,
                maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
              }
            }
          }
        ]
      }
    })
  ],
  server: {
    https: {
      key: fs.readFileSync('./cert/key.pem'),
      cert: fs.readFileSync('./cert/cert.pem')
    },
    port: 5173,
    host: true
  }
});

๐ŸŒ Production Deployment

โ˜๏ธ Cloud Platform Deployment

Vercel Deployment

# Install Vercel CLI
npm install -g vercel

# Build production version
npm run build

# Deploy to Vercel
vercel --prod

# Custom domain configuration
vercel domains add your-domain.com

Vercel Configuration (vercel.json):

{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/static-build",
      "config": {
        "distDir": "dist"
      }
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "/index.html"
    }
  ],
  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-Frame-Options",
          "value": "DENY"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        }
      ]
    }
  ]
}

Netlify Deployment

# Install Netlify CLI
npm install -g netlify-cli

# Build application
npm run build

# Deploy to Netlify
netlify deploy --prod --dir=dist

# Custom domain
netlify domains:add your-domain.com

Netlify Configuration (netlify.toml):

[build]
  command = "npm run build"
  publish = "dist"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

[[headers]]
  for = "/*"
  [headers.values]
    X-Frame-Options = "DENY"
    X-Content-Type-Options = "nosniff"
    X-XSS-Protection = "1; mode=block"
    Referrer-Policy = "strict-origin-when-cross-origin"

GitHub Pages Deployment

# Install gh-pages
npm install --save-dev gh-pages

# Add to package.json scripts
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"

# Deploy
npm run deploy

๐Ÿ”’ Production Security Checklist

  • โœ… HTTPS enabled with valid SSL certificate
  • โœ… Security headers configured
  • โœ… Content Security Policy implemented
  • โœ… CORS properly configured
  • โœ… Environment variables secured
  • โœ… API keys not exposed in client code

๐Ÿ“ฑ Mobile Installation Guide

๐Ÿค– Android Installation

Step-by-Step Installation Process

Step 1: Open Browser

Open Chrome or Edge on Android device

Step 2: Visit Site

Navigate to the HTTPS URL

Step 3: Install

Tap the install icon in browser menu

๐Ÿ“ฑ Installation Options

Browser Menu Method:

  1. Open site in Chrome/Edge
  2. Tap the three-dot menu (โ‹ฎ) in top-right corner
  3. Select "Add to Home Screen" or "Install App"
  4. Confirm installation
  5. App icon appears on home screen

Automatic Prompt Method:

  • Visit the site on HTTPS
  • Wait for install banner to appear
  • Tap "Install" button
  • App installs automatically

๐ŸŽ iOS Considerations

Limited Support on iOS:

  • Web Bluetooth API not fully supported on iOS Safari
  • PWA installation works, but Bluetooth features limited
  • Recommend Android devices for full functionality

iOS Installation (PWA Only):

  1. Open Safari browser
  2. Tap share button (โ–กโ†‘)
  3. Select "Add to Home Screen"
  4. Confirm and install

๐Ÿงช Testing & Development

๐Ÿ”ฌ Local Testing Workflow

# Run development server
npm run dev

# Run with custom port
npm run dev -- --port 3000

# Build for production testing
npm run build
npm run preview

# Run tests
npm run test

# Type checking
npm run type-check

# Lint code
npm run lint

๐Ÿ“ฑ Mobile Testing Guide

Testing on Android:

# Get your local IP address
# Linux/Mac:
ifconfig | grep "inet "

# Windows:
ipconfig

# Access from mobile using:
https://YOUR-IP-ADDRESS:5173

Testing Checklist:

  • โœ… Bluetooth device discovery works
  • โœ… Messages send and receive correctly
  • โœ… Encryption toggles properly
  • โœ… PWA installs successfully
  • โœ… Offline functionality works
  • โœ… UI is responsive on mobile

๐Ÿšจ Troubleshooting Guide

Common Issues & Solutions

๐Ÿ”ต Bluetooth Connection Issues

# Issue: Bluetooth devices not found
# Solution: Check browser compatibility
navigator.bluetooth.getAvailability()
  .then(isAvailable => {
    console.log('Bluetooth available:', isAvailable);
  });

# Ensure HTTPS is enabled
# Verify permissions are granted

๐Ÿ” SSL Certificate Problems

# Issue: Certificate errors in development
# Solution: Trust the self-signed certificate

# Chrome: Navigate to chrome://flags/#allow-insecure-localhost
# Enable "Allow invalid certificates for resources loaded from localhost"

# Or regenerate certificate with proper CN:
openssl req -x509 -newkey rsa:2048 -nodes \
  -keyout key.pem -out cert.pem -days 365 \
  -subj "/CN=localhost"

๐Ÿ“ฑ PWA Installation Issues

// Check PWA compatibility
if ('serviceWorker' in navigator) {
  console.log('Service Worker supported');
}

// Debug manifest issues
// Check: https://your-site.com/manifest.json
// Validate with: https://manifest-validator.appspot.com/

๐Ÿ”ง Optimization Techniques

// Code splitting for better performance
import { lazy, Suspense } from 'react';

const ChatInterface = lazy(() => import('./components/ChatInterface'));
const BluetoothScanner = lazy(() => import('./components/BluetoothScanner'));

function App() {
  return (
    <Suspense fallback={<Loading />}>
      <ChatInterface />
      <BluetoothScanner />
    </Suspense>
  );
}

๐Ÿ”ฎ Future Roadmap

๐Ÿš€ Planned Features

  • ๐ŸŽฅ Video/Voice Calls: Bluetooth audio streaming
  • ๐Ÿ“ File Transfer: Enhanced file sharing capabilities
  • ๐Ÿ‘ฅ Group Chat: Multi-device Bluetooth mesh networking
  • ๐ŸŒ Multi-Language: Internationalization support
  • ๐ŸŽจ Themes: Customizable UI themes
  • ๐Ÿ“Š Analytics: Usage statistics and insights

๐Ÿš€ Start Your Bluetooth Journey Today!

Get Started Documentation GitHub


๐Ÿ“ก Experience the Future of Wireless Communication!

Built with โค๏ธ using React, Vite, Web Bluetooth API, and Modern Web Standards

๐ŸŒŸ Star this repo if you love wireless communication! ๐Ÿ› Report issues ๐Ÿ’ก Suggest features

Made with React + Vite + Web Bluetooth

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages