Skip to content

Commit 7333b7f

Browse files
authored
Merge pull request #98 from standleypg-dev/UI-migrate
UI migrate
2 parents 92357d1 + a7256f9 commit 7333b7f

61 files changed

Lines changed: 4079 additions & 3043 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"WebFetch(domain:github.com)",
5+
"WebSearch",
6+
"WebFetch(domain:support.discord.com)"
7+
]
8+
}
9+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"eslint.useFlatConfig": true,
3+
"eslint.workingDirectories": ["src/UI/App_v2"]
4+
}

CLAUDE.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Discord Music Bot - A .NET 9 application that provides music playback functionality for Discord servers. Supports YouTube, SoundCloud, Spotify (for playlist fetching), and radio streams.
8+
9+
## Build & Run Commands
10+
11+
```bash
12+
# Build and run with Docker (recommended)
13+
docker-compose -f deployment/docker-compose.yml up --build
14+
15+
# Build .NET solution
16+
dotnet build discord-project.slnx
17+
18+
# Run the Worker (main entry point)
19+
dotnet run --project src/Worker/Worker.csproj
20+
21+
# Run with specific configuration
22+
dotnet run --project src/Worker/Worker.csproj -c Release
23+
24+
# Frontend dev server (from src/UI/App)
25+
npm run dev
26+
27+
# Frontend production build
28+
npm run build
29+
30+
# Frontend development build
31+
npm run build:dev
32+
```
33+
34+
## Architecture
35+
36+
### Clean Architecture Layers
37+
38+
- **Domain** (`src/Domain/`) - Core entities (Song, User, PlayHistory, RadioSource), event interfaces (`IEventHandler<T>`, `IAsyncEventHandler<T>`), and common abstractions
39+
- **Application** (`src/Application/`) - Business logic services, DTOs, configuration models, event dispatching system, and service interfaces
40+
- **Infrastructure** (`src/Infrastructure/`) - Discord bot implementation using NetCord, audio processing with FFmpeg/NAudio, database access via EF Core, YouTube/SoundCloud integration
41+
- **UI** (`src/UI/`) - Contains two sub-projects:
42+
- `Api/` - ASP.NET Core REST API with JWT authentication
43+
- `App/` - Lit-based TypeScript frontend (Vite build)
44+
- **Worker** (`src/Worker/`) - Main entry point that composes all layers, hosts the Discord bot and web API
45+
46+
### Key Patterns
47+
48+
**Event System**: Custom domain event dispatching via `IEventHandler<T>` and `IAsyncEventHandler<T>`. Handlers are auto-discovered from assemblies at startup via `AddEventing()`.
49+
50+
**Service Registration**: Keyed services pattern for multiple implementations:
51+
```csharp
52+
services.AddKeyedScoped<IStreamService, YoutubeService>(nameof(YoutubeService));
53+
services.AddKeyedScoped<IStreamService, SoundCloudService>(nameof(SoundCloudService));
54+
```
55+
56+
**Discord Commands**: Organized in `src/Infrastructure/Commands/`:
57+
- `MusicPlayCommands.cs` - Play/queue commands
58+
- `MusicActionCommands.cs` - Pause, skip, volume, etc.
59+
- `AdminCommands.cs` - Admin functionality
60+
- `MiscCommands.cs` - Utility commands
61+
62+
### Database
63+
64+
PostgreSQL with EF Core. Context: `Infrastructure/Data/DiscordBotContext.cs`. Migrations run automatically on startup.
65+
66+
### Audio Pipeline
67+
68+
Audio flows through: YoutubeDLSharp/YoutubeExplode -> FFmpeg processing (`FfmpegProcessService`) -> NAudio conversion -> NetCord voice client
69+
70+
### Native Dependencies (Linux/Docker)
71+
72+
- FFmpeg
73+
- libsodium
74+
- libopus
75+
- yt-dlp
76+
77+
## Configuration
78+
79+
Environment variables (via docker-compose or appsettings.json):
80+
- `Discord__Token` - Discord bot token
81+
- `SpotifySettings__ClientId/ClientSecret` - Spotify API credentials
82+
- `ConnectionStrings__DefaultConnection` - PostgreSQL connection string
83+
- `JwtSettings__Secret/Issuer/Audience` - JWT configuration
84+
- `WebsiteSettings__Url` - Base URL for the web UI
85+
- `Cors__AllowedOrigins` - Allowed CORS origins
86+
87+
## Frontend Stack
88+
89+
TypeScript with Lit web components, Vaadin Router, Chart.js. Build output goes to `src/Worker/wwwroot/`.

deployment/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ RUN apt update && apt install -y --no-install-recommends \
99
libopus-dev \
1010
wget \
1111
unzip \
12-
&& curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
13-
&& apt install -y --no-install-recommends nodejs \
12+
&& curl -fsSL https://bun.sh/install | bash \
13+
&& ln -s /root/.bun/bin/bun /usr/local/bin/bun \
1414
&& rm -rf /var/lib/apt/lists/*
1515

1616
RUN wget -O /tmp/libdave.zip \

src/Infrastructure/Services/SoundCloudService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Application.Interfaces.Services;
22
using Microsoft.Extensions.Logging;
33
using SoundCloudExplode;
4-
using SoundCloudExplode.Common;
54

65
namespace Infrastructure.Services;
76

src/UI/App/.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_API_BASE_URL=http://localhost:5000/api
1+
VITE_API_BASE_URL=http://localhost:5000/api

src/UI/App/.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_API_BASE_URL=https://rytho.standleypg.com/api
1+
VITE_API_BASE_URL=https://rytho.standleypg.com/api

src/UI/App/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
node_modules
3+
package-lock.json
4+
*.min.js
5+
*.min.css

src/UI/App/.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 80,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"jsxSingleQuote": false,
10+
"arrowParens": "always",
11+
"endOfLine": "auto"
12+
}

src/UI/App/App.esproj

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)