Deploying Chitchatter
Chitchatter is a decentralized peer-to-peer chat application designed for private, secure conversations without relying on central servers. Built with end-to-end encryption and using WebRTC for direct peer communication, Chitchatter provides a modern alternative to traditional chat platforms. With support for multiple chat rooms, file sharing, screen sharing capabilities, and built-in privacy controls, Chitchatter is ideal for teams, communities, and individuals who prioritize privacy and security in their communications.
This guide will walk you through deploying Chitchatter on Klutch.sh, a modern cloud platform that simplifies containerized application deployment. By the end of this guide, you’ll have a fully functional peer-to-peer chat platform ready for secure team communication.
Why Deploy Chitchatter on Klutch.sh?
Klutch.sh provides an excellent platform for hosting Chitchatter:
- Docker-native deployment - Klutch.sh automatically detects and deploys Dockerized applications
- Low latency communication - Optimized infrastructure for real-time peer-to-peer connections
- Custom domains - Use your own domain for branded chat services
- Environment configuration - Manage secrets and settings through the dashboard
- Built-in HTTPS - Secure WebRTC signaling with automatic SSL certificates
- Scalable infrastructure - Handle multiple concurrent connections effortlessly
- Privacy-focused - Keep your chat infrastructure under your control
Prerequisites
Before deploying Chitchatter on Klutch.sh, you’ll need:
- A Klutch.sh account (sign up for free)
- Access to the Klutch.sh dashboard
- A GitHub repository to store your Chitchatter deployment configuration
- A custom domain (recommended for signaling server)
- Basic understanding of Docker and containerization
- Familiarity with WebRTC and peer-to-peer networking concepts
Deployment Steps
Create a Dockerfile
Create a
Dockerfilein the root of your repository to containerize Chitchatter:FROM node:20-alpine# Install system dependenciesRUN apk add --no-cache \build-base \python3 \git \curl# Set working directoryWORKDIR /app# Clone Chitchatter repositoryRUN git clone https://github.com/jeremyckahn/chitchatter.git . && \git checkout main# Install dependenciesRUN npm install# Build the applicationRUN npm run build# Expose portEXPOSE 3000# Health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \CMD curl -f http://localhost:3000/ || exit 1# Start the applicationCMD ["npm", "start"]Create Environment Configuration File
Create a
.env.examplefile to document required environment variables:# Chitchatter Environment Configuration# Application SettingsNODE_ENV=productionPORT=3000HOST=0.0.0.0# Application Base URLBASE_URL=https://example-app.klutch.shREACT_APP_API_BASE_URL=https://example-app.klutch.sh# WebRTC Signaling ServerSIGNALING_SERVER_URL=wss://example-app.klutch.shSTUN_SERVERS=stun:stun.l.google.com:19302,stun:stun1.l.google.com:19302,stun:stun2.l.google.com:19302TURN_SERVER_URL=TURN_SERVER_USERNAME=TURN_SERVER_PASSWORD=# Security SettingsSECURE_COOKIES=trueSAME_SITE_COOKIES=strictCORS_ORIGIN=https://example-app.klutch.sh# Chat ConfigurationMAX_MESSAGE_LENGTH=5000MAX_USERNAME_LENGTH=50MAX_ROOM_NAME_LENGTH=100# User SettingsALLOW_ANONYMOUS_USERS=trueREQUIRE_ROOM_PASSWORD=falseDEFAULT_ROOM_PASSWORD_LENGTH=8# File SharingENABLE_FILE_SHARING=trueMAX_FILE_SIZE=52428800MAX_FILES_PER_SESSION=10ALLOWED_FILE_TYPES=image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.zip# Rate LimitingRATE_LIMIT_ENABLED=trueRATE_LIMIT_WINDOW=900000RATE_LIMIT_MAX_REQUESTS=100# LoggingLOG_LEVEL=infoLOG_FORMAT=json# Feature FlagsENABLE_SCREEN_SHARING=trueENABLE_FILE_SHARING=trueENABLE_ROOM_PERSISTENCE=falseENABLE_USAGE_ANALYTICS=true# Privacy SettingsSEND_ANALYTICS=falseTRACK_USER_ACTIVITY=falseCOLLECT_USAGE_STATISTICS=false# PerformanceSESSION_TIMEOUT=3600IDLE_TIMEOUT=1800MAX_CONNECTIONS_PER_USER=5Create Application Configuration File
Create a
config.jsfile for application-specific settings:module.exports = {app: {name: 'Chitchatter',version: '1.0.0',environment: process.env.NODE_ENV || 'production',port: process.env.PORT || 3000,host: process.env.HOST || '0.0.0.0',baseUrl: process.env.BASE_URL || 'http://localhost:3000'},webrtc: {signalingServerUrl: process.env.SIGNALING_SERVER_URL,stunServers: (process.env.STUN_SERVERS || '').split(',').filter(Boolean),turnServer: {url: process.env.TURN_SERVER_URL,username: process.env.TURN_SERVER_USERNAME,password: process.env.TURN_SERVER_PASSWORD},iceGatheringTimeout: 5000,iceConnectionTimeout: 10000},security: {secureCookies: process.env.SECURE_COOKIES === 'true',sameSiteCookies: process.env.SAME_SITE_COOKIES || 'strict',corsOrigin: process.env.CORS_ORIGIN || 'http://localhost:3000'},chat: {maxMessageLength: parseInt(process.env.MAX_MESSAGE_LENGTH) || 5000,maxUsernameLength: parseInt(process.env.MAX_USERNAME_LENGTH) || 50,maxRoomNameLength: parseInt(process.env.MAX_ROOM_NAME_LENGTH) || 100,allowAnonymousUsers: process.env.ALLOW_ANONYMOUS_USERS === 'true',requireRoomPassword: process.env.REQUIRE_ROOM_PASSWORD === 'true'},fileSharing: {enabled: process.env.ENABLE_FILE_SHARING === 'true',maxFileSize: parseInt(process.env.MAX_FILE_SIZE) || 52428800,maxFilesPerSession: parseInt(process.env.MAX_FILES_PER_SESSION) || 10,allowedFileTypes: (process.env.ALLOWED_FILE_TYPES || '').split(',')},features: {screenSharing: process.env.ENABLE_SCREEN_SHARING === 'true',fileSharing: process.env.ENABLE_FILE_SHARING === 'true',roomPersistence: process.env.ENABLE_ROOM_PERSISTENCE === 'true',usageAnalytics: process.env.ENABLE_USAGE_ANALYTICS === 'true'},privacy: {sendAnalytics: process.env.SEND_ANALYTICS === 'true',trackUserActivity: process.env.TRACK_USER_ACTIVITY === 'true',collectUsageStatistics: process.env.COLLECT_USAGE_STATISTICS === 'true'},rateLimit: {enabled: process.env.RATE_LIMIT_ENABLED === 'true',window: parseInt(process.env.RATE_LIMIT_WINDOW) || 900000,maxRequests: parseInt(process.env.RATE_LIMIT_MAX_REQUESTS) || 100},session: {timeout: parseInt(process.env.SESSION_TIMEOUT) || 3600,idleTimeout: parseInt(process.env.IDLE_TIMEOUT) || 1800,maxConnectionsPerUser: parseInt(process.env.MAX_CONNECTIONS_PER_USER) || 5},logging: {level: process.env.LOG_LEVEL || 'info',format: process.env.LOG_FORMAT || 'json'}};Create Docker Compose for Local Development
Create a
docker-compose.ymlfile for local development and testing (not used for Klutch.sh deployment):version: '3.8'services:chitchatter:build: .container_name: chitchatter-devports:- "3000:3000"environment:- NODE_ENV=development- BASE_URL=http://localhost:3000- REACT_APP_API_BASE_URL=http://localhost:3000- SIGNALING_SERVER_URL=ws://localhost:3000- ALLOW_ANONYMOUS_USERS=true- ENABLE_FILE_SHARING=true- ENABLE_SCREEN_SHARING=true- SEND_ANALYTICS=falsevolumes:- ./src:/app/src- ./public:/app/publicnetworks:- chitchatter-networknetworks:chitchatter-network:driver: bridgeTo run locally:
Terminal window docker-compose upThen visit
http://localhost:3000in your browser.Create .gitignore File
Create a
.gitignorefile to exclude sensitive data from version control:# Environment files.env.env.local.env.*.local# Node.jsnode_modules/npm-debug.logyarn-error.logpackage-lock.jsonyarn.lock# Build artifactsdist/build/.next/out/# React.react/.cache/# Logslogs/*.log# IDE.vscode/.idea/*.swp*.swo*~.DS_Store# Cache.cache/.turbo/# Operating System.DS_StoreThumbs.db# Temporary filestemp/tmp/.tmp/Push Configuration to GitHub
Push your repository to GitHub with all configuration files:
Terminal window git add Dockerfile .env.example config.js \docker-compose.yml .gitignoregit commit -m "Initial Chitchatter deployment configuration for Klutch.sh"git push origin mainDeploy on Klutch.sh
- Navigate to klutch.sh/app and log in to your dashboard
- Click Create New App
- Connect your GitHub repository containing the Chitchatter deployment files (the Dockerfile will be automatically detected)
- Configure your application settings:
- Set your preferred app name
- Review the detected Dockerfile configuration
- Select a region for deployment
- Click Deploy to start the deployment process
- Monitor the deployment progress in the dashboard
- Wait for the deployment to complete and your chat application to become active
Configure Environment Variables
- In your app dashboard, navigate to Environment Variables section
- Add all required variables from your
.env.examplefile:BASE_URL: Set tohttps://example-app.klutch.sh(or your custom domain)REACT_APP_API_BASE_URL: Set tohttps://example-app.klutch.shSIGNALING_SERVER_URL: Set towss://example-app.klutch.shALLOW_ANONYMOUS_USERS: Set totrue(orfalseto require registration)ENABLE_FILE_SHARING: Set totrueto enable file sharingENABLE_SCREEN_SHARING: Set totrueto enable screen sharingSEND_ANALYTICS: Set tofalsefor privacyTRACK_USER_ACTIVITY: Set tofalsefor privacyRATE_LIMIT_ENABLED: Set totruefor security- Optional TURN server credentials if behind restrictive NAT
- Click Save to apply the environment variables
- Your application will automatically restart with the new configuration
Configure Traffic Routes
- In your app dashboard, navigate to Traffic settings
- Select HTTP as the traffic type
- Set the internal port to 3000 (Chitchatter Node.js server default)
- Configure any custom domain settings if you have a domain
- Ensure WebSocket support is enabled (typically automatic with HTTP)
- Save your traffic configuration
Test Your Deployment
Once deployment is complete:
- Navigate to
https://example-app.klutch.shin your browser - You’ll see the Chitchatter interface
- Click Create New Room to start a chat room
- Share the generated room link with others
- Test messaging, file sharing, and screen sharing features
- Verify that peer-to-peer connections are working properly
- Navigate to
Using Chitchatter
Creating and Joining Chat Rooms
To create a new chat room:
- Navigate to your Chitchatter instance
- Enter a username (or leave blank for anonymous)
- Enter a room name
- Click Create Room
- Share the generated room link with participants
To join an existing room:
- Use the link provided by the room creator
- Enter a username
- Click Join Room
- Start communicating
Chat Room Features
Basic Messaging:
- Send text messages to all participants
- View message history during the session
- See when users are typing
- Get notifications for new messages
File Sharing:
- Share files directly with room participants
- Drag and drop files into the chat
- Download files shared by others
- No file size limits (respecting browser memory)
Screen Sharing:
- Share your screen with all participants
- See others’ shared screens
- Keyboard and mouse control options
- Stop sharing at any time
User Management:
- View active participants in the room
- See user connection status
- Real-time user list updates
- Anonymous or named participation
Privacy and Security
Chitchatter provides several privacy and security features:
- End-to-End Encryption: All communications are encrypted between peers
- No Central Storage: Messages are not stored on servers
- Peer-to-Peer Communication: Direct connection between participants
- Session-Based: Rooms disappear when all participants leave
- Optional Passwords: Protect rooms with password access
- Privacy Controls: Disable analytics and tracking
Deployment Best Practices
Security Measures
- Keep Chitchatter updated to the latest version
- Use HTTPS/WSS for all connections (automatic with Klutch.sh)
- Enable optional TURN servers for NAT traversal if needed
- Implement rate limiting to prevent abuse
- Disable user tracking and analytics for privacy
- Monitor WebRTC connections for unusual patterns
- Consider IP whitelisting for enterprise use
Monitoring and Maintenance
- Monitor CPU and memory usage during peak times
- Review logs for connection errors
- Test peer-to-peer connectivity regularly
- Monitor WebSocket connections for stability
- Track deployment performance
- Set up alerts for connection failures
- Schedule updates during low-traffic periods
Performance Optimization
- Monitor concurrent connection limits
- Optimize for low-latency signaling
- Test with various network conditions
- Configure appropriate STUN/TURN servers
- Monitor ICE candidate gathering
- Test file transfer speeds
- Optimize screen sharing quality
Scaling Considerations
As your chat service grows:
- Monitor server resource usage
- Adjust session timeout values if needed
- Consider additional STUN/TURN servers
- Implement load balancing if needed
- Monitor signaling server performance
- Plan for increasing concurrent users
Accessing Chitchatter
Once deployment is complete:
- Users access Chitchatter at your configured domain or
example-app.klutch.sh - Users can create or join chat rooms instantly
- Users can share files and screens with participants
- All communication is encrypted and peer-to-peer
- Rooms are ephemeral and disappear when empty
- No registration or authentication required (unless configured)
Troubleshooting Deployment Issues
Application Won’t Start
Check the following:
- Verify all required environment variables are set
- Check Node.js version compatibility
- Review application logs in the dashboard
- Ensure Dockerfile is building correctly
- Verify npm build process completes
WebRTC Connection Issues
Steps to resolve:
- Verify STUN servers are accessible
- Check firewall rules allow WebRTC
- Test with different networks
- Review browser console for connection errors
- Consider enabling TURN servers
- Check SIGNALING_SERVER_URL is correct
Peer-to-Peer Not Working
Possible solutions:
- Verify both users can access the signaling server
- Check firewall allows UDP traffic
- Ensure STUN/TURN servers are configured
- Test with users on same network first
- Review WebRTC connection logs
- Try different network interfaces
Performance Issues
Optimization steps:
- Monitor application resource usage
- Increase server memory allocation if needed
- Enable compression for signaling messages
- Optimize file transfer speeds
- Reduce screen sharing quality if needed
- Monitor database/persistence if enabled
Advanced Configuration
TURN Server Setup
For users behind restrictive firewalls or NAT:
TURN_SERVER_URL=turns:your-turn-server.com:443TURN_SERVER_USERNAME=usernameTURN_SERVER_PASSWORD=passwordCustom STUN Servers
Configure additional STUN servers:
STUN_SERVERS=stun:stun1.example.com:3478,stun:stun2.example.com:3478Room Password Protection
Require passwords for room access:
REQUIRE_ROOM_PASSWORD=trueDEFAULT_ROOM_PASSWORD_LENGTH=12Custom Domain Setup
To use a custom domain with your Chitchatter instance:
- In your Klutch.sh dashboard, navigate to Domains
- Add your custom domain
- Follow the DNS configuration instructions
- Update your environment variables:
BASE_URL=https://your-domain.comREACT_APP_API_BASE_URL=https://your-domain.comSIGNALING_SERVER_URL=wss://your-domain.com
- Save and redeploy your application
Feature Configuration
Control which features are available:
ENABLE_SCREEN_SHARING=trueENABLE_FILE_SHARING=trueALLOW_ANONYMOUS_USERS=trueENABLE_USAGE_ANALYTICS=trueSession Management
Configure session behavior:
SESSION_TIMEOUT=3600IDLE_TIMEOUT=1800MAX_CONNECTIONS_PER_USER=5Additional Resources
Learn more about Chitchatter and WebRTC:
- Chitchatter GitHub Repository - Source code and documentation
- Chitchatter Official Website - Live demo and information
- WebRTC API Documentation - Complete WebRTC guide
- TURN Server Setup Guide - Configure TURN for NAT traversal
- Klutch.sh Official Website - Learn more about the deployment platform
- Klutch.sh Documentation - Platform guides and API reference
Conclusion
You now have a fully functional Chitchatter instance running on Klutch.sh! Your decentralized peer-to-peer chat platform is ready for secure team communication.
With the privacy-focused design of Chitchatter and the robust infrastructure of Klutch.sh, you have everything needed to run a secure, decentralized communication platform. Remember to:
- Keep Chitchatter updated to the latest version
- Monitor peer-to-peer connection quality
- Maintain security best practices
- Test connectivity with various network configurations
- Configure TURN servers for users behind firewalls
For additional support or questions about deploying Chitchatter on Klutch.sh, refer to the documentation and community resources linked above.