Skip to content

Sliv3er/BattalaHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏰 Battala Hub

A production-grade Discord alternative featuring real-time chat, voice channels with WebRTC, file uploads, custom emojis, and more. Built with modern web technologies and fully containerized with Docker.

NestJS React TypeScript PostgreSQL Docker WebRTC

✨ Features

πŸ’¬ Real-Time Chat

  • Instant messaging with Socket.IO WebSockets
  • Edit and delete your own messages (inline editing)
  • Image/file attachments with preview before sending
  • Custom emoji system per server (:emoji_name: syntax)
  • Typing indicators
  • Message notifications with toggleable sounds

🎀 Voice Channels

  • WebRTC peer-to-peer voice communication
  • Mute / Deafen / Disconnect controls
  • Screen sharing with stream viewing
  • Connection quality indicator (ping, packet loss)
  • Join/leave/disconnect sound effects
  • Users visible under voice channels in sidebar

πŸ–₯️ Server Management

  • Create and manage multiple servers
  • Server settings (name, description, icon upload)
  • Create, edit, and delete text/voice channels
  • Invite system with shareable codes
  • Role-based membership
  • Join servers by name β€” search and join public servers

πŸ‘€ User Profiles

  • Profile settings with avatar upload
  • Discord-style member profile popovers
  • Online/offline status indicators
  • Display name customization

βš™οΈ App Settings

  • Audio: Microphone and headset selection, mic test with volume meter
  • Keybinds: Configurable shortcuts for mute, deafen, disconnect
  • Notifications: Toggle message notification sounds

🎨 Design

  • Dark theme inspired by Discord
  • Responsive layout with proper scrolling
  • Smooth animations and transitions
  • Custom scrollbars

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend   │────▢│   Backend    │────▢│ PostgreSQL  β”‚
β”‚  React+Vite  β”‚     β”‚   NestJS     β”‚     β”‚   (Prisma)  β”‚
β”‚  Port 3000   β”‚     β”‚  Port 4000   β”‚     β”‚  Port 5432  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚              β”‚
              β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
              β”‚   MinIO    β”‚ β”‚  Coturn   β”‚
              β”‚ S3 Storage β”‚ β”‚ TURN/STUN β”‚
              β”‚ Port 9000  β”‚ β”‚ Port 3478 β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Layer Technology
Frontend React 18, TypeScript, Vite, Tailwind CSS, Zustand
Backend NestJS, TypeScript, Prisma ORM, Socket.IO
Database PostgreSQL 15
Storage MinIO (S3-compatible)
Voice/Video WebRTC + Coturn TURN/STUN server
Deployment Docker Compose

πŸš€ Quick Start

Prerequisites

Setup

# Clone the repository
git clone https://github.com/Sliv3er/BattalaHub.git
cd BattalaHub

# Start all services
docker compose up -d

# Wait for services to be healthy, then open:
# Frontend: http://localhost:3000
# Backend API: http://localhost:4000/api/docs (Swagger)
# MinIO Console: http://localhost:9001

Default Ports

Service Port
Frontend 3000
Backend API 4000
PostgreSQL 5432
MinIO API 9000
MinIO Console 9001
Coturn STUN/TURN 3478

πŸ“ Project Structure

battala-hub/
β”œβ”€β”€ backend/                 # NestJS API server
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   └── schema.prisma    # Database schema (12+ models)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/            # JWT authentication
β”‚   β”‚   β”œβ”€β”€ channels/        # Channel CRUD
β”‚   β”‚   β”œβ”€β”€ database/        # Prisma service
β”‚   β”‚   β”œβ”€β”€ emojis/          # Custom emoji system
β”‚   β”‚   β”œβ”€β”€ messages/        # Message CRUD + reactions
β”‚   β”‚   β”œβ”€β”€ servers/         # Server management + invites
β”‚   β”‚   β”œβ”€β”€ storage/         # MinIO file uploads
β”‚   β”‚   β”œβ”€β”€ users/           # User profiles
β”‚   β”‚   β”œβ”€β”€ voice/           # Voice channel management
β”‚   β”‚   β”œβ”€β”€ websocket/       # Socket.IO gateways (chat + voice)
β”‚   β”‚   └── main.ts          # App bootstrap
β”‚   └── Dockerfile
β”œβ”€β”€ frontend/                # React SPA
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/             # Axios client
β”‚   β”‚   β”œβ”€β”€ components/      # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ AppSettings.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ChannelsSidebar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatArea.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MembersList.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfileSettings.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ServerSettings.tsx
β”‚   β”‚   β”‚   └── VoiceChannel.tsx
β”‚   β”‚   β”œβ”€β”€ pages/           # Route pages
β”‚   β”‚   β”œβ”€β”€ stores/          # Zustand state management
β”‚   β”‚   β”‚   β”œβ”€β”€ authStore.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ settingsStore.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ socketStore.ts
β”‚   β”‚   β”‚   └── voiceStore.ts
β”‚   β”‚   └── main.tsx
β”‚   └── Dockerfile
β”œβ”€β”€ coturn/                  # TURN server config
β”œβ”€β”€ docker-compose.yml       # Full stack orchestration
└── README.md

πŸ”Œ API Endpoints

Authentication

  • POST /api/auth/register β€” Register new user
  • POST /api/auth/login β€” Login
  • POST /api/auth/logout β€” Logout
  • GET /api/auth/me β€” Get current user

Servers

  • POST /api/servers β€” Create server
  • GET /api/servers β€” List user's servers
  • GET /api/servers/:id β€” Get server details
  • PATCH /api/servers/:id β€” Update server
  • DELETE /api/servers/:id β€” Delete server
  • GET /api/servers/search?name= β€” Search servers by name
  • POST /api/servers/:id/join β€” Join server
  • POST /api/servers/:id/invites β€” Create invite
  • POST /api/servers/join/:inviteCode β€” Join via invite

Channels

  • POST /api/channels/:serverId β€” Create channel
  • GET /api/channels/server/:serverId β€” List channels
  • PATCH /api/channels/:id β€” Update channel
  • DELETE /api/channels/:id β€” Delete channel

Messages

  • POST /api/messages/channel/:channelId β€” Send message
  • GET /api/messages/channel/:channelId β€” Get messages
  • PATCH /api/messages/:id β€” Edit message
  • DELETE /api/messages/:id β€” Delete message
  • POST /api/messages/:id/reactions β€” Add reaction

Voice

  • GET /api/voice/ice-servers β€” Get ICE servers
  • POST /api/voice/channels/:channelId/join β€” Join voice
  • DELETE /api/voice/leave β€” Leave voice
  • GET /api/voice/channels/:channelId/users β€” Get voice users

Emojis

  • POST /api/emojis/:serverId β€” Upload custom emoji
  • GET /api/emojis/:serverId β€” List server emojis
  • DELETE /api/emojis/:id β€” Delete emoji

Storage

  • POST /api/storage/upload β€” Upload file (max 10MB)

πŸ”§ WebSocket Events

Chat Namespace (default)

Event Direction Description
join_channel Client β†’ Server Join a text channel
leave_channel Client β†’ Server Leave a text channel
send_message Client β†’ Server Send a message
edit_message Client β†’ Server Edit a message
delete_message Client β†’ Server Delete a message
add_reaction Client β†’ Server Add emoji reaction
typing_start Client β†’ Server Start typing indicator
new_message Server β†’ Client New message received
message_updated Server β†’ Client Message was edited
message_deleted Server β†’ Client Message was deleted
user_typing Server β†’ Client User is typing

Voice Namespace (/voice)

Event Direction Description
join_voice Client β†’ Server Join voice channel
leave_voice Client β†’ Server Leave voice channel
webrtc_offer Bidirectional WebRTC SDP offer
webrtc_answer Bidirectional WebRTC SDP answer
webrtc_ice_candidate Bidirectional ICE candidate exchange
user_joined_voice Server β†’ Client User joined voice
user_left_voice Server β†’ Client User left voice

πŸ—ƒοΈ Database Schema

Key models: User, Server, ServerMember, Role, Channel (TEXT/VOICE), Message, Reaction, Attachment, Emoji, Invite, VoiceSession, TypingIndicator

See backend/prisma/schema.prisma for full schema.

πŸ”’ Environment Variables

All configured via docker-compose.yml. Key variables:

Variable Description Default
DATABASE_URL PostgreSQL connection string Set in compose
JWT_SECRET JWT signing key Set in compose
MINIO_ENDPOINT MinIO internal hostname minio
MINIO_PUBLIC_URL MinIO public URL for browser http://localhost:9000
CORS_ORIGIN Allowed CORS origin http://localhost:3000
TURN_SERVER_URL Coturn TURN server URL turn:coturn:3478

πŸ“œ License

MIT

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

About

πŸ’¬ Production-grade Discord alternative β€” Real-time chat, WebRTC voice, screen sharing & custom emojis

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages