Skip to content

iamhmh/stemx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

71 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

stemx 🎡

Open-source AI-powered audio stem separation SaaS. Separate vocals and instrumentals from any audio track using state-of-the-art machine learning models running on GPU.

License Next.js FastAPI Python

✨ Features

  • AI Stem Separation - Extract vocals and instrumentals using BS-Roformer model
  • Producer Mode - Advanced settings for music producers (vocal modes, de-reverb, noise gate, de-esser)
  • BPM & Key Detection - Automatic audio analysis
  • Credit System - Built-in billing with Stripe integration
  • Serverless GPU - RunPod serverless for cost-effective GPU processing
  • Real-time Status - Live job status updates

πŸ—οΈ Architecture

apps/
β”œβ”€β”€ api/        # FastAPI backend (REST API, auth, job management)
β”œβ”€β”€ worker/     # Job processor (polls jobs, calls RunPod, post-processing)
β”œβ”€β”€ runpod/     # RunPod serverless handler (GPU stem separation)
β”œβ”€β”€ web/        # Next.js frontend (dashboard, auth, payments)
└── infra/      # Docker Compose for local development

How it works

  1. User uploads audio file β†’ API validates and stores in Supabase Storage
  2. Worker polls for pending jobs and sends audio to RunPod
  3. RunPod runs BS-Roformer on GPU for stem separation
  4. Results uploaded to Supabase Storage, user downloads stems

πŸ› οΈ Tech Stack

Frontend

  • Next.js 16 - React framework with App Router
  • TailwindCSS - Utility-first CSS
  • Radix UI - Accessible UI components
  • Framer Motion - Animations
  • Supabase Auth - Authentication

Backend

  • FastAPI - Modern Python API framework
  • Supabase - PostgreSQL database & storage
  • Stripe - Payments & subscriptions

AI/GPU Processing

  • RunPod Serverless - GPU-as-a-Service (scale to zero)
  • BS-Roformer - State-of-the-art audio separation model
  • audio-separator - Python library for model inference

Infrastructure

  • Railway - Deploy API, Worker, and Web services
  • RunPod - Serverless GPU workers
  • Supabase - Managed PostgreSQL & Storage
  • Docker - Containerization

πŸš€ Getting Started

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+
  • Python 3.11+
  • Supabase account
  • RunPod account
  • Stripe account (for payments)

Local Development

  1. Clone the repository

    git clone https://github.com/iamhmh/stemx.git
    cd stemx
  2. Set up environment variables

    cp .env.example apps/infra/.env
    # Edit apps/infra/.env with your credentials
  3. Start services with Docker Compose

    cd apps/infra
    docker compose up --build
  4. Access the app

Environment Variables

Create apps/infra/.env with:

# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
SUPABASE_JWT_SECRET=your-jwt-secret

# RunPod
RUNPOD_API_KEY=your-runpod-api-key
RUNPOD_ENDPOINT_ID=your-endpoint-id

# Stripe
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxx

☁️ Deployment

Railway (API, Worker, Web)

  1. Create a new Railway project
  2. Add services from the apps/ directories:
    • apps/api β†’ FastAPI service
    • apps/worker β†’ Python worker service
    • apps/web β†’ Next.js frontend
  3. Configure environment variables for each service
  4. Deploy!

Each service includes nixpacks.toml for Railway auto-detection.

RunPod (GPU Serverless)

  1. Build and push Docker image

    cd apps/runpod
    docker build -t your-username/stemx-runpod:latest .
    docker push your-username/stemx-runpod:latest
  2. Create RunPod Serverless Endpoint

    • Go to RunPod β†’ Serverless β†’ Deploy
    • Image: your-username/stemx-runpod:latest
    • GPU: A40 (48GB) recommended
    • Active Workers: 0 (scale to zero)
    • Max Workers: 3
    • Idle Timeout: 5 seconds
  3. Configure environment variables

    • SUPABASE_URL
    • SUPABASE_SERVICE_ROLE_KEY

πŸ“ Project Structure

stemx/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/                 # FastAPI backend
β”‚   β”‚   β”œβ”€β”€ main.py          # API endpoints
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   └── requirements.txt
β”‚   β”‚
β”‚   β”œβ”€β”€ worker/              # Job processor
β”‚   β”‚   β”œβ”€β”€ main.py          # Job polling & orchestration
β”‚   β”‚   β”œβ”€β”€ audio_analyzer.py # BPM/Key detection
β”‚   β”‚   β”œβ”€β”€ audio_processing.py # Post-processing effects
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ runpod/              # GPU serverless handler
β”‚   β”‚   β”œβ”€β”€ handler.py       # RunPod entry point
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ web/                 # Next.js frontend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ app/         # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ components/  # React components
β”‚   β”‚   β”‚   └── lib/         # Utilities
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── infra/               # Docker Compose
β”‚       └── docker-compose.yml
β”‚
β”œβ”€β”€ .env.example             # Environment template
└── README.md

πŸ”§ API Endpoints

Method Endpoint Description
GET /health Health check
GET /users/me Get current user
POST /upload Upload audio for processing
GET /jobs List user's jobs
GET /jobs/{id}/download Get download URLs

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

Open-source AI audio stem separation SaaS powered by BS-Roformer and serverless GPU.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors