Files
GMW/README.md
T

119 lines
3.9 KiB
Markdown
Raw Normal View History

# Bete — Discord Moderation Dashboard
2026-05-12 19:38:23 +07:00
Bot monitoring Discord yang merekam voice channel, menangkap pesan teks, menyimpan attachment, menjalankan analisis AI opsional, dan menyediakan dashboard web real-time.
2026-05-12 19:38:23 +07:00
**Stack utama:** Node.js (Express 5), pnpm, TypeScript, React 19 (Next.js 16), Tailwind v4, shadcn/ui, Drizzle ORM, PostgreSQL, WebSocket, Redis pub/sub.
2026-05-12 19:38:23 +07:00
2026-05-15 05:45:19 +07:00
## Prasyarat
2026-05-12 19:38:23 +07:00
- Node.js 22+
- pnpm 11.x
- FFmpeg di `PATH` (untuk audio muxing dan playback media)
- `yt-dlp` di `PATH` (untuk resolve audio YouTube/Spotify)
- Bun (untuk frontend dev — opsional, bisa pake pnpm)
- PostgreSQL 15+
2026-05-15 05:45:19 +07:00
## Setup
2026-05-12 19:38:23 +07:00
```bash
2026-05-15 05:45:19 +07:00
pnpm install
2026-05-12 19:38:23 +07:00
cp .env.example .env
# Edit .env sesuai konfigurasi server
2026-05-12 19:38:23 +07:00
```
2026-05-15 05:45:19 +07:00
## Menjalankan
2026-05-12 19:38:23 +07:00
```bash
# Backend (port 3001)
pnpm run dev:backend
2026-05-12 19:38:23 +07:00
# Discord Gateway (capture messages, voice, dll)
pnpm run dev:discord-gateway
2026-05-15 05:45:19 +07:00
# Frontend (port 3000)
2026-05-15 05:45:19 +07:00
pnpm run dev:web
2026-05-12 19:38:23 +07:00
```
## Build
2026-05-12 19:38:23 +07:00
2026-05-15 05:45:19 +07:00
```bash
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
2026-05-12 19:38:23 +07:00
```
2026-05-15 05:45:19 +07:00
## Deploy
2026-05-15 05:45:19 +07:00
```bash
./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
2026-05-15 05:45:19 +07:00
```
## Service Architecture
2026-05-15 05:45:19 +07:00
```
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
2026-05-15 05:45:19 +07:00
```
## 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
2026-05-12 19:38:23 +07:00
2026-05-15 05:45:19 +07:00
## Struktur Proyek
2026-05-12 19:38:23 +07:00
```
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
2026-05-12 19:38:23 +07:00
```
2026-05-15 05:45:19 +07:00
## Database
2026-05-15 05:45:19 +07:00
PostgreSQL via Drizzle ORM. Migrasi:
```bash
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_analyzed`
- `attachment_created`, `attachment_uploaded`
- `voice_recording_started`, `voice_recording_stopped`, `voice_recording_uploaded`
- `voice_active_user`, `voice_pcm_data`
- `media_state`
- `reaction_*`, `thread_*`, `presence_updated`, `guild_member_*`