From 31309046d21942dd28c6ecca399457478cea4e30 Mon Sep 17 00:00:00 2001 From: Top1055 <123alexfeetham@gmail.com> Date: Sun, 1 Feb 2026 18:44:36 +0000 Subject: [PATCH] removed current roadmap --- PRODUCTION_ROADMAP.md | 849 ------------------------------------------ 1 file changed, 849 deletions(-) delete mode 100644 PRODUCTION_ROADMAP.md diff --git a/PRODUCTION_ROADMAP.md b/PRODUCTION_ROADMAP.md deleted file mode 100644 index 8cefbd5..0000000 --- a/PRODUCTION_ROADMAP.md +++ /dev/null @@ -1,849 +0,0 @@ -# Groovy-Zilean Production Roadmap - -**Goal:** Transform groovy-zilean from a personal project into a production-ready Discord music bot with a web dashboard. - -**Philosophy:** Production-quality architecture with manageable complexity for a solo developer. No overkill, no shortcuts. - ---- - -## Table of Contents -1. [Architecture Overview](#architecture-overview) -2. [Tech Stack Decisions](#tech-stack-decisions) -3. [Development Phases](#development-phases) -4. [Python Environment Setup](#python-environment-setup) -5. [Why This Approach](#why-this-approach) -6. [Quick Reference](#quick-reference) - ---- - -## Architecture Overview - -### The Winning Design: Database-Mediated Architecture - -``` -┌─────────────┐ HTTP/SSE ┌──────────────┐ -│ Browser │◄────────────►│ FastAPI │ -│ (HTMX HTML) │ │ Backend │ -└─────────────┘ └──────┬───────┘ - │ - ┌──────▼───────┐ ┌─────────────┐ - │ PostgreSQL │◄────────│ Discord Bot │ - │ Database │ │ (discord.py)│ - └──────────────┘ └─────────────┘ -``` - -### Key Principles - -1. **Decoupled Services** - - Bot and web can restart independently - - No tight coupling via IPC - - Database is the single source of truth - -2. **Simple Frontend (Initially)** - - HTMX for interactivity (no build step) - - Jinja2 templates (server-side rendering) - - Tailwind CSS via CDN (beautiful, no npm) - - **Optional:** Upgrade to React later when ready - -3. **Production-Ready Backend** - - PostgreSQL for reliability - - FastAPI for modern Python web - - Discord OAuth2 for authentication - - Connection pooling, proper error handling - ---- - -## Tech Stack Decisions - -### Backend - -| Component | Choice | Why | -|-----------|--------|-----| -| **Bot Framework** | discord.py 2.6.4+ | Industry standard, hybrid commands | -| **Web Framework** | FastAPI | Modern, async, auto-docs, large community | -| **Database** | PostgreSQL 14+ | Production-ready, ACID compliance, better than SQLite | -| **Music Extraction** | yt-dlp | Actively maintained, multi-platform support | -| **Auth** | Discord OAuth2 | Native Discord integration | -| **ORM** | SQLAlchemy (optional) | Or use asyncpg directly for simplicity | - -### Frontend (Phase 1) - -| Component | Choice | Why | -|-----------|--------|-----| -| **Templates** | Jinja2 | Server-side rendering, no build step | -| **Interactivity** | HTMX | Modern interactivity without React complexity | -| **Styling** | Tailwind CSS (CDN) | Beautiful UI, no build process | -| **Real-time** | Server-Sent Events | Simple polling/updates, no WebSocket complexity | - -### Frontend (Phase 2 - Optional) - -| Component | Choice | Why | -|-----------|--------|-----| -| **Framework** | React 18 | If you need more complex UI later | -| **Real-time** | WebSocket | For true real-time when needed | -| **State** | Zustand/Context | Simpler than Redux | - -### Infrastructure - -| Component | Choice | Why | -|-----------|--------|-----| -| **Python Version** | 3.11 or 3.12 | Modern features, better performance | -| **Environment** | venv | Isolated dependencies, no PATH conflicts | -| **Process Manager** | systemd | Reliable, built into Linux | -| **Reverse Proxy** | nginx | Standard, handles SSL, static files | - ---- - -## Development Phases - -### Phase 0: Current State ✅ -- Working Discord bot with music playback -- SQLite database -- Hybrid commands (slash + prefix) -- 17 audio effects -- Queue, loop, shuffle functionality -- Spotify integration - -### Phase 1: Quick Wins (1-2 hours) - -**Goal:** Immediate improvements for better UX - -Tasks: -1. **Lower default volume from 100% to 25%** - - Change default in `queue.py:119` - - Scale volume command display (user sees 0-200%, internally 0-50%) - - Prevents earrape for new users - -2. **Add .mp3 and .mp4 file support** - - Extend `translate.py` to detect direct file URLs - - Support HTTP/HTTPS links to audio files - - Validate file type before processing - -**Files to modify:** -- `cogs/music/queue.py` -- `cogs/music/translate.py` - ---- - -### Phase 2: Code Refactoring (4-6 hours) - -**Goal:** Clean, maintainable, documented codebase - -#### 2.1 Database Abstraction -Create `cogs/music/db_manager.py`: -- Database connection class with context manager -- Connection pooling preparation -- Centralize all SQL queries -- Remove scattered `sqlite3.connect()` calls - -#### 2.2 Configuration Management -Update `config.py`: -- Use environment variables for secrets -- Create `.env.example` template -- Remove hardcoded credentials -- Add validation for required config - -#### 2.3 Code Organization -``` -groovy-zilean/ -├── bot/ -│ ├── __init__.py -│ ├── bot.py # Main bot class -│ └── cogs/ -│ └── music/ -│ ├── __init__.py -│ ├── commands.py # User-facing commands -│ ├── player.py # Playback logic -│ ├── queue.py # Queue management -│ ├── effects.py # Audio effects -│ ├── db_manager.py # Database abstraction -│ └── translate.py # URL/playlist parsing -├── web/ -│ ├── __init__.py # (Future web app) -├── shared/ -│ ├── __init__.py -│ ├── config.py # Shared configuration -│ └── models.py # Data models -├── main.py # Entry point -├── requirements.txt -├── .env.example -└── README.md -``` - -#### 2.4 Error Handling & Logging -- Wrap all commands in try/except -- User-friendly error messages -- Proper logging setup (rotating file logs) -- Debug mode toggle - -#### 2.5 Type Hints & Documentation -- Add type hints to all functions -- Docstrings for all classes/methods -- Inline comments for complex logic - -**Expected outcome:** -- Easy to navigate codebase -- No secrets in code -- Consistent patterns throughout - ---- - -### Phase 3: PostgreSQL Migration (3-4 hours) - -**Goal:** Production-ready database layer - -#### 3.1 Local PostgreSQL Setup -```bash -# Install PostgreSQL -sudo apt update -sudo apt install postgresql postgresql-contrib - -# Create database and user -sudo -u postgres psql -CREATE DATABASE groovy_zilean; -CREATE USER groovy WITH PASSWORD 'your_password'; -GRANT ALL PRIVILEGES ON DATABASE groovy_zilean TO groovy; -``` - -#### 3.2 Database Schema Design -```sql --- servers table -CREATE TABLE servers ( - server_id BIGINT PRIMARY KEY, - is_playing BOOLEAN DEFAULT FALSE, - song_name TEXT, - song_url TEXT, - song_thumbnail TEXT, - loop_mode VARCHAR(10) DEFAULT 'off', - volume INTEGER DEFAULT 25, -- NEW default! - effect VARCHAR(20) DEFAULT 'none', - song_start_time DOUBLE PRECISION DEFAULT 0, - song_duration INTEGER DEFAULT 0, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); - --- songs/queue table -CREATE TABLE songs ( - id SERIAL PRIMARY KEY, - server_id BIGINT NOT NULL REFERENCES servers(server_id) ON DELETE CASCADE, - song_link TEXT, - queued_by TEXT, - position INTEGER NOT NULL, - title TEXT, - thumbnail TEXT, - duration INTEGER, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - UNIQUE(server_id, position) -); - --- Future: users table for web auth -CREATE TABLE users ( - discord_id BIGINT PRIMARY KEY, - username TEXT, - avatar TEXT, - access_token TEXT, - refresh_token TEXT, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - last_login TIMESTAMP -); - --- Future: permissions table -CREATE TABLE permissions ( - id SERIAL PRIMARY KEY, - server_id BIGINT REFERENCES servers(server_id), - user_id BIGINT, - role_id BIGINT, - can_play BOOLEAN DEFAULT TRUE, - can_skip BOOLEAN DEFAULT FALSE, - can_clear BOOLEAN DEFAULT FALSE, - can_modify_settings BOOLEAN DEFAULT FALSE -); -``` - -#### 3.3 Migration Script -Create `scripts/migrate_to_postgres.py`: -- Read all data from SQLite -- Insert into PostgreSQL -- Validate migration -- Backup SQLite file - -#### 3.4 Update Database Code -Replace all `sqlite3` calls with `asyncpg` or `psycopg3`: -```python -# Old (SQLite) -conn = sqlite3.connect(db_path) -cursor = conn.cursor() - -# New (PostgreSQL with asyncpg) -async with pool.acquire() as conn: - result = await conn.fetch("SELECT * FROM servers WHERE server_id = $1", server_id) -``` - -#### 3.5 Connection Pooling -```python -# In bot startup -self.db_pool = await asyncpg.create_pool( - host='localhost', - database='groovy_zilean', - user='groovy', - password=os.getenv('DB_PASSWORD'), - min_size=5, - max_size=20 -) -``` - -**Expected outcome:** -- Reliable database with ACID guarantees -- Better concurrent access handling -- Ready for multi-server production load - ---- - -### Phase 4: Web Dashboard (20-30 hours) - -**Goal:** User-friendly web interface for bot control - -#### 4.1 FastAPI Backend Setup - -**Project structure:** -``` -web/ -├── __init__.py -├── main.py # FastAPI app -├── routes/ -│ ├── __init__.py -│ ├── auth.py # Discord OAuth2 -│ ├── servers.py # Server list/select -│ └── playback.py # Queue/controls -├── templates/ -│ ├── base.html -│ ├── index.html -│ ├── dashboard.html -│ └── components/ -│ ├── queue.html -│ └── controls.html -├── static/ -│ ├── css/ -│ └── js/ -└── dependencies.py # Auth dependencies -``` - -**Core dependencies:** -```bash -pip install fastapi uvicorn jinja2 python-multipart httpx -``` - -#### 4.2 Discord OAuth2 Authentication - -**Flow:** -1. User clicks "Login with Discord" -2. Redirect to Discord OAuth -3. Discord redirects back with code -4. Exchange code for token -5. Fetch user info + guilds -6. Create session -7. Show dashboard with user's servers - -**Implementation:** -```python -# routes/auth.py -@router.get("/login") -async def login(): - # Redirect to Discord OAuth - discord_auth_url = ( - f"https://discord.com/api/oauth2/authorize" - f"?client_id={DISCORD_CLIENT_ID}" - f"&redirect_uri={REDIRECT_URI}" - f"&response_type=code" - f"&scope=identify guilds" - ) - return RedirectResponse(discord_auth_url) - -@router.get("/callback") -async def callback(code: str): - # Exchange code for token - # Fetch user info - # Create session - # Redirect to dashboard -``` - -#### 4.3 HTMX Frontend - -**Example dashboard with HTMX:** -```html - -