24aa2bca3091f93137ee65fffbfd6cf8427665f9
Build & Deploy (Nix) / build-and-deploy (backend) (push) Successful in 3m14s
Build & Deploy (Nix) / build-and-deploy (discord-gateway) (push) Successful in 2m28s
Build & Deploy (Nix) / build-and-deploy (proxy) (push) Successful in 2m38s
127.0.0.1 from inside Docker container is the container's own loopback, not host's. Changed to listen 8080 (all interfaces) so Traefik can reach it via host.docker.internal:8080.
Bete — Discord Moderation Dashboard
Bot monitoring Discord yang merekam voice channel, menangkap pesan teks, menyimpan attachment, menjalankan analisis AI opsional, dan menyediakan dashboard web real-time.
Stack utama: Node.js (Express 5), pnpm, TypeScript, React 19 (Next.js 16), Tailwind v4, shadcn/ui, Drizzle ORM, PostgreSQL, WebSocket, Redis pub/sub.
Prasyarat
- Node.js 22+
- pnpm 11.x
- FFmpeg di
PATH(untuk audio muxing dan playback media) yt-dlpdiPATH(untuk resolve audio YouTube/Spotify)- Bun (untuk frontend dev — opsional, bisa pake pnpm)
- PostgreSQL 15+
Setup
pnpm install
cp .env.example .env
# Edit .env sesuai konfigurasi server
Menjalankan
# Backend (port 3001)
pnpm run dev:backend
# Discord Gateway (capture messages, voice, dll)
pnpm run dev:discord-gateway
# Frontend (port 3000)
pnpm run dev:web
Build
pnpm run build:backend
pnpm run build:discord-gateway
pnpm run build:web # next build — static export ke out/
pnpm run build # build semua service
Deploy
./deploy.sh # Build + deploy semua service ke VPS
./deploy.sh --frontend # Frontend only
./deploy.sh --backend # Backend only
./deploy.sh --no-build # Skip build, copy files aja
Service Architecture
Discord
|
v
discord-gateway ←→ Redis ←→ backend (Express 5) ←→ frontend (Next.js)
| pub/sub | |
| +— REST API (/api/*) |
| +— WebSocket (/ws) |
+— message capture +— AI moderation |
+— voice recording +— dashboard data +— dashboard UI
+— attachment upload +— real-time updates
Fitur
- Message capture: Capture pesan baru, edit, dan delete dari Discord
- Voice recording: Rekam voice channel ke segmen OGG per user, streaming PCM real-time ke WebSocket
- Attachment upload: Download + upload attachment ke external storage
- AI moderation: Analisis pesan opsional via LLM, auto-delete, queue management
- Dashboard: Messages feed, AI analysis review, voice connection, music player, recordings, user/channel stats
- Media playback: Playback dari URL, file lokal, YouTube, Spotify
- WebSocket: Real-time event streaming untuk semua aktivitas
- Public API: Semua endpoint REST dan WebSocket dapat diakses tanpa autentikasi
Struktur Proyek
services/
├── backend/ # Express 5 REST API + WebSocket server
│ ├── src/modules/ # Feature modules (messages, voice, media, dll)
│ └── src/http/ # Express app setup, middleware
├── discord-gateway/ # Discord client, voice recording, AI analysis
│ ├── src/modules/ # message-capture, voice-recording, ai-moderation
│ └── src/shared/ # Config, database, Discord client
└── frontend/ # Next.js 16 dashboard (static export)
├── src/app/ # Pages (login, dashboard tabs)
├── src/features/ # Feature components (dashboard, live, messages)
└── src/lib/ # API client, WebSocket, types
packages/
└── shared/ # Shared types, errors, logger, utilities
Database
PostgreSQL via Drizzle ORM. Migrasi:
pnpm run db:generate # Generate migration
pnpm run db:migrate # Apply migration
pnpm run db:studio # Drizzle Studio
WebSocket Events
Backend broadcast event berikut ke frontend via WebSocket:
message_created,message_updated,message_deleted,message_analyzedattachment_created,attachment_uploadedvoice_recording_started,voice_recording_stopped,voice_recording_uploadedvoice_active_user,voice_pcm_datamedia_statereaction_*,thread_*,presence_updated,guild_member_*
Languages
TypeScript
97.2%
Nix
0.9%
Shell
0.8%
CSS
0.7%
PLpgSQL
0.4%