A real-time chat application with LDAP/Active Directory authentication for enterprise use.
- LDAP/Active Directory Authentication - Seamless integration with domain controllers
- Real-time Messaging - Powered by WebSocket for instant message delivery
- Public & Private Channels - Create channels for teams and departments
- Direct Messages - One-on-one conversations with colleagues
- Typing Indicators - See when others are typing
- User Presence - Online/offline/away status
- Message History - Persistent message storage with PostgreSQL
- Responsive UI - Modern React-based interface
- Secure - JWT authentication, HTTPS support, input validation
- Python 3.11+
- FastAPI
- WebSocket
- PostgreSQL
- SQLAlchemy ORM
- LDAP3 Authentication
- React 18
- Native WebSocket Client
- Axios
- CSS3
- Clone the repository:
git clone <repository-url>
cd cblchat- Create environment file:
cp backend/.env.example .env- Edit
.envwith your configuration:
nano .env- Deploy with Docker:
chmod +x deploy.sh
./deploy.shThe application will be available at http://localhost
- Run the installation script:
chmod +x install.sh
sudo ./install.sh- Configure environment variables:
nano backend/.env- Run database migrations:
cd backend
npm run migrate
npm run seed
cd ..- Start the application:
pm2 start ecosystem.config.js
pm2 save# Server
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=cblchat
DB_USER=postgres
DB_PASSWORD=your_password
# JWT
JWT_SECRET=your_secret_key_change_this
JWT_EXPIRES_IN=24h
# LDAP/Active Directory
LDAP_URL=ldap://your-dc.local:389
LDAP_BIND_DN=cn=admin,dc=example,dc=com
LDAP_BIND_PASSWORD=your_ldap_password
LDAP_SEARCH_BASE=dc=example,dc=com
LDAP_SEARCH_FILTER=(uid={{username}})
# For Active Directory use: (sAMAccountName={{username}})
# CORS
CORS_ORIGIN=http://localhostFor Active Directory:
LDAP_URL=ldap://dc.company.local:389
LDAP_BIND_DN=cn=ServiceAccount,ou=Users,dc=company,dc=local
LDAP_SEARCH_BASE=dc=company,dc=local
LDAP_SEARCH_FILTER=(sAMAccountName={{username}})For OpenLDAP:
LDAP_URL=ldap://ldap.company.local:389
LDAP_BIND_DN=cn=admin,dc=company,dc=local
LDAP_SEARCH_BASE=ou=users,dc=company,dc=local
LDAP_SEARCH_FILTER=(uid={{username}})For production, configure SSL in nginx.conf:
server {
listen 443 ssl http2;
server_name chat.company.local;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
# ... rest of configuration
}With Docker:
docker-compose up -dWith PM2:
pm2 start ecosystem.config.jsDevelopment mode:
# Backend
cd backend
npm run dev
# Frontend (in another terminal)
cd frontend
npm startView logs:
docker-compose logs -f # Docker
pm2 logs # PM2Restart:
docker-compose restart # Docker
pm2 restart all # PM2Stop:
docker-compose down # Docker
pm2 stop all # PM2POST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current userPUT /api/auth/profile- Update profile
GET /api/rooms- Get user's roomsPOST /api/rooms- Create roomPOST /api/rooms/direct- Create direct messageGET /api/rooms/:id- Get room detailsPUT /api/rooms/:id- Update roomDELETE /api/rooms/:id- Delete room
GET /api/messages/room/:roomId- Get room messagesPOST /api/messages/room/:roomId- Send messagePUT /api/messages/:id- Edit messageDELETE /api/messages/:id- Delete messageGET /api/messages/search- Search messages
GET /api/users- Get all usersGET /api/users/:id- Get user by ID
join_rooms- Join multiple roomssend_message- Send a messagetyping- User is typingstop_typing- User stopped typingstatus_change- Change user status
new_message- New message receiveduser_typing- User is typinguser_stop_typing- User stopped typingmessage_edited- Message was editedmessage_deleted- Message was deleteduser_status_change- User status changed
- id, username, displayName, email, department, status, lastSeen, avatarUrl
- id, name, description, roomType (public/private/direct), createdBy
- id, senderId, roomId, recipientId, content, messageType, fileUrl, fileName
- id, roomId, userId, role (admin/member), lastReadMessageId, joinedAt
- SSL/TLS - Always use HTTPS in production
- JWT Secret - Use a strong, random JWT secret
- LDAP over SSL - Enable LDAPS for production
- Rate Limiting - Configured to prevent abuse
- Input Validation - All inputs are validated
- CSRF Protection - Enabled for all endpoints
- Helmet.js - Security headers configured
# Test LDAP connection
ldapsearch -x -H ldap://your-dc.local:389 -D "cn=admin,dc=example,dc=com" -W -b "dc=example,dc=com"# Test PostgreSQL connection
psql -h localhost -U cblchat -d cblchat# Find process using port 3000
sudo lsof -i :3000
# Kill the process
sudo kill -9 <PID>MIT
For issues and questions, please open an issue in the repository.