Frontend Overview
The frontend is a standalone React 18 single-page application built with Vite, TailwindCSS, and Radix UI. It serves as the web dashboard for controlling the bot, managing guild settings, and viewing statistics.
Technology Stack
| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| Vite | Build tool and dev server |
| TailwindCSS | Utility-first CSS |
| Radix UI | Accessible UI primitives |
| TanStack React Query | Data fetching and caching |
| Socket.IO Client | Real-time player state |
| React Router v6 | Client-side routing |
| Sonner | Toast notifications |
Environment Variables
Create a .env file in frontend/ based on .env.example:
| Variable | Description | Example |
|---|---|---|
VITE_BACKEND_URL | Backend Fastify API base URL | https://api.meww.me |
VITE_DISCORD_CLIENT_ID | Discord application client ID | 928966154817523723 |
VITE_CLARITY_ID | Microsoft Clarity analytics ID (optional) | vpmd4zvp19 |
The redirect URI for the Discord OAuth2 flow must be set to /invite-callback on your frontend domain (e.g., https://meww.me/invite-callback).
Application Root (App.tsx)
The root component wraps the application with providers:
QueryClientProvider (TanStack)
└── AuthProvider (Discord session)
└── TooltipProvider (Radix)
└── Sonner (Toasts)
└── BrowserRouter
└── SmoothScroll
└── Routes
└── BackgroundMusicPlayerRouting
| Path | Component | Auth Required |
|---|---|---|
/ | Index | No |
/commands | Commands | No |
/premium | Premium | No |
/privacy | PrivacyPolicy | No |
/termsofservice | TermsOfService | No |
/refundpolicy | RefundPolicy | No |
/login | Login | No |
/servers | Dashboard | Yes |
/profile | Profile | Yes |
/global-stats | GlobalStats | No |
/dashboard/:guildId/:view? | PlayerPage | Yes |
/invite-callback | InviteCallback | No |
/team | Team | No |
/admin | AdminDashboard | Yes (Admin) |
/systemstatus | SystemStatus | No |
/player/:guildId | Redirect → /dashboard/:guildId | - |
Key Hooks
useAuth (hooks/useAuth.tsx)
Authentication context provider. Fetches user session from /auth/me on mount and exposes:
user- current user object (id, username, avatar, isAdmin)isAuthenticated- booleanlogout()- calls/auth/logoutand clears state
usePlayer (hooks/usePlayer.ts)
Central player state management hook. Handles:
- Fetching player state from
/api/player/:guildId - Sending control commands (pause, skip, volume, loop, seek, shuffle, queue management)
- Socket.IO event subscription for real-time state updates
- Automatic reconnection and state reconciliation
Returns the full player state including: current, queue, paused, volume, loop, position, autoplay, isPremium.
useSocket (hooks/useSocket.ts)
Socket.IO connection hook. Manages:
- Connection to the backend Socket.IO server
- Guild-specific room subscription (
subscribe/unsubscribeevents) - Automatic reconnection on disconnect
useLikedSongs (hooks/useLikedSongs.ts)
Manages the user's liked songs collection. Provides:
likedSongs- array of liked trackstoggleLike(track)- add or remove a track from liked songsisLiked(uri)- check if a track is liked
useTrackColor (hooks/useTrackColor.ts)
Extracts dominant color from album artwork to create dynamic UI theming.
Backend Communication
All API calls go to VITE_BACKEND_URL. The frontend uses two communication channels:
HTTP (REST API)
Session-based authentication via cookies. The Fastify backend sets an httpOnly cookie (mewwme-dash.sid) on login. All /api/* requests include credentials.
Key patterns:
GET /auth/me- check sessionGET /api/guilds- list mutual guildsGET /api/player/:guildId- get player statePATCH /api/player/:guildId- control playerGET /api/search?identifier=...&source=...- search tracks
Socket.IO (Real-time)
After connecting, the client emits subscribe with a guildId to join a guild room. The server then emits real-time player events:
| Event | Direction | Description |
|---|---|---|
subscribe | Client → Server | Join guild room |
subscribed | Server → Client | Confirmation of room join |
requestState | Client → Server | Request current player state |
playerState | Server → Client | Full player state snapshot |
playerCreate | Server → Client | Initial state on subscribe |
trackStart | Server → Client | New track started |
trackEnd | Server → Client | Track finished |
queueUpdate | Server → Client | Queue changed |
unsubscribe | Client → Server | Leave guild room |
External Links (config/links.ts)
Centralized link definitions used across the frontend:
| Key | URL |
|---|---|
botInvite | https://discord.com/oauth2/authorize?client_id=... |
supportServer | https://discord.com/invite/6EXgrmtkPX |
topgg | https://top.gg/bot/.../vote |
patreon | https://www.patreon.com/c/mewwme |
kofi | https://ko-fi.com/mewwme |
docs | https://docs.meww.me |
github | https://github.com/mewwme |
email | mailto:support@meww.me |
Running the Frontend
Development
cd frontend
npm install
npm run devThe Vite dev server starts on port 5173 by default.
Production
cd frontend
npm run build
npm run previewThe build output is in frontend/dist/. Serve with any static file server or deploy to a CDN.