Skip to content

shawndenggh/dj-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 DJ Hub

A full-stack SaaS platform for DJs to discover music, manage channels, and get AI-powered recommendations powered by the Deezer API.

CI License: MIT

✨ Features

  • πŸ” Authentication – GitHub OAuth + Email/Password via NextAuth.js
  • πŸ’³ Stripe Subscriptions – Free, Pro ($19.99/mo), Enterprise ($99.99/mo)
  • 🎡 Deezer Integration – Music search, recommendations by genre/BPM/energy
  • πŸ“» Channel Management – Create, organize, and share curated music channels
  • πŸŽ›οΈ Music Preferences – Configure genre, BPM, energy, danceability filters
  • πŸ€– Smart Recommendations – Personalized track suggestions from Deezer
  • 🎨 shadcn/ui – Beautiful, accessible UI components
  • πŸš€ Production Ready – Docker, GitHub Actions CI/CD, Vercel deployment

πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 14 (App Router)
Language TypeScript
Database SQLite (via Prisma ORM)
Auth NextAuth.js v4
Payments Stripe
Music API Deezer API
UI shadcn/ui + Tailwind CSS
Deployment Vercel / Docker

πŸ“ Project Structure

dj-hub/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma          # Database schema
β”‚   └── seed.ts                # Database seeding
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (auth)/            # Login, Register pages
β”‚   β”‚   β”œβ”€β”€ (dashboard)/       # Protected dashboard routes
β”‚   β”‚   β”œβ”€β”€ api/               # REST API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/          # NextAuth + Register
β”‚   β”‚   β”‚   β”œβ”€β”€ users/         # User CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ preferences/   # Music preferences
β”‚   β”‚   β”‚   β”œβ”€β”€ channels/      # Channel management
β”‚   β”‚   β”‚   β”œβ”€β”€ recommendations/ # Deezer recommendations
β”‚   β”‚   β”‚   β”œβ”€β”€ subscriptions/ # Subscription info
β”‚   β”‚   β”‚   β”œβ”€β”€ stripe/        # Checkout, Portal, Webhook
β”‚   β”‚   β”‚   └── health/        # Health check
β”‚   β”‚   β”œβ”€β”€ pricing/           # Pricing page
β”‚   β”‚   β”œβ”€β”€ layout.tsx         # Root layout
β”‚   β”‚   └── page.tsx           # Landing page
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ auth/              # Login/Register forms
β”‚   β”‚   β”œβ”€β”€ dashboard/         # Dashboard components
β”‚   β”‚   β”œβ”€β”€ layout/            # Navigation, Providers
β”‚   β”‚   └── ui/                # shadcn/ui components
β”‚   β”œβ”€β”€ hooks/                 # Custom React hooks
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ auth.ts            # NextAuth config
β”‚   β”‚   β”œβ”€β”€ deezer.ts          # Deezer API client
β”‚   β”‚   β”œβ”€β”€ prisma.ts          # Prisma client singleton
β”‚   β”‚   β”œβ”€β”€ stripe.ts          # Stripe config & helpers
β”‚   β”‚   β”œβ”€β”€ utils.ts           # Utility functions
β”‚   β”‚   └── validations.ts     # Zod schemas
β”‚   └── types/                 # TypeScript types
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ ci.yml             # CI pipeline
β”‚       └── deploy.yml         # Vercel deployment
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ next.config.js
β”œβ”€β”€ tailwind.config.ts
└── vercel.json

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • A Stripe account (for payments)
  • A GitHub OAuth App (for auth)

1. Clone & Install

git clone https://github.com/your-org/dj-hub.git
cd dj-hub
npm install

2. Configure Environment

cp .env.example .env.local

Edit .env.local with your credentials:

# Database
DATABASE_URL="file:./dev.db"

# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret"  # openssl rand -base64 32

# GitHub OAuth (https://github.com/settings/applications/new)
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

# Stripe (https://dashboard.stripe.com)
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_PUBLISHABLE_KEY="pk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."
STRIPE_PRO_PRICE_ID="price_..."
STRIPE_ENTERPRISE_PRICE_ID="price_..."

# App
NEXT_PUBLIC_APP_URL="http://localhost:3000"

3. Setup Database

# Push schema to database
npm run db:push

# (Optional) Seed with demo data
npm run db:seed

4. Run Development Server

npm run dev

Open http://localhost:3000

Demo accounts (after seeding):

Email Password Plan
admin@djhub.com admin123 Enterprise
pro@djhub.com pro123 Pro
free@djhub.com free123 Free

🌐 API Reference

Authentication

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/[...nextauth] NextAuth handler

Users

Method Endpoint Description
GET /api/users/:id Get user details
PATCH /api/users/:id Update user profile
DELETE /api/users/:id Delete account

Preferences

Method Endpoint Description
GET /api/preferences Get user preferences
PUT /api/preferences Update preferences

Channels

Method Endpoint Description
GET /api/channels List user channels
POST /api/channels Create channel
GET /api/channels/:id Get channel
PATCH /api/channels/:id Update channel
DELETE /api/channels/:id Delete channel

Recommendations

Method Endpoint Description
GET /api/recommendations?limit=20 Get recommendations
POST /api/recommendations Submit track feedback

Subscriptions & Stripe

Method Endpoint Description
GET /api/subscriptions Get subscription
POST /api/stripe/checkout Create Stripe checkout
POST /api/stripe/portal Open billing portal
POST /api/stripe/webhook Stripe webhook handler

πŸ’³ Stripe Setup

Create Products

  1. Go to Stripe Dashboard
  2. Create Pro product: $19.99/month recurring
  3. Create Enterprise product: $99.99/month recurring
  4. Copy the Price IDs to your .env.local

Webhook Setup (Development)

# Install Stripe CLI
stripe listen --forward-to localhost:3000/api/stripe/webhook

# Copy the webhook secret to STRIPE_WEBHOOK_SECRET

Webhook Events

The following Stripe events are handled:

  • checkout.session.completed
  • invoice.payment_succeeded
  • invoice.payment_failed
  • customer.subscription.updated
  • customer.subscription.deleted

🐳 Docker

Build & Run

# Build image
docker build -t dj-hub .

# Run with Docker Compose
docker-compose up -d

Environment Variables for Docker

Create a .env file (not committed) with all production variables.

πŸš€ Deployment

Vercel (Recommended)

  1. Connect your GitHub repo to Vercel
  2. Set all environment variables in Vercel Dashboard
  3. Deploy automatically on push to main

Note: For Vercel deployment, use a persistent database (e.g., PlanetScale, Turso, or Neon) instead of SQLite.

GitHub Actions

Required secrets in your repo:

  • VERCEL_TOKEN
  • VERCEL_ORG_ID
  • VERCEL_PROJECT_ID

πŸ—„οΈ Database Schema

User ──── Account (OAuth)
     ──── Session
     ──── Subscription (Stripe)
     ──── Preference (music settings)
     ──── Channel[] ──── Track[]
     ──── Recommendation[]

πŸ“¦ Available Scripts

npm run dev          # Start development server
npm run build        # Production build
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # TypeScript check
npm run db:push      # Push Prisma schema
npm run db:migrate   # Run migrations
npm run db:generate  # Regenerate Prisma client
npm run db:studio    # Open Prisma Studio
npm run db:seed      # Seed demo data

πŸ”’ Security

  • Passwords hashed with bcrypt (12 rounds)
  • JWT sessions via NextAuth
  • API routes protected with session checks
  • Stripe webhook signature verification
  • Input validation with Zod schemas
  • CORS headers configured

πŸ“„ License

MIT License β€” see LICENSE for details.


Built with ❀️ for the DJ community. Powered by Next.js and Deezer API.

About

🎧 ε€šη”¨ζˆ· DJ 推荐平台 - 基于δΈͺ人偏ε₯½ηš„ιŸ³δΉθ‡ͺεŠ¨ζŽ¨ι€η³»η»Ÿ

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors