This is a FastAPI project setup using uv, a blazing fast Python package manager.
Follow the steps below to get started.
- Python 3.12 (uv handles virtual environments automatically)
- uv installed
curl -LsSf https://astral.sh/uv/install.sh | sh- (Optional) Docker & Docker Compose
Create a .env file in the project root with the following values:
# Spotify API Keys
SPOTIFY_CLIENT_ID=
SPOTIFY_CLIENT_SECRET=
# Google YT API key
YOUTUBE_API_KEY=
# Supabase API keys
SUPABASE_API_KEY=
SUPABASE_URL=
BUCKET_NAME=
# Atlas MONGODB Connection String
MONGODB_URL=
# Replicate API Key
REPLICATE_API_TOKEN=
# API Key
GROQ_API_KEY=
# Logging
LOG_LEVEL=INFO # Options: NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL
⚠️ Make sure not to commit.envto version control.
- Visit MongoDB Atlas Login.
- Once logged in, you'll be redirected to the MongoDB Atlas Dashboard.
- Click on "Create Cluster".
- Select the Free Plan (M0) as your cluster type.
- Follow the steps for creating a cluster (choose cloud provider and region).
- Click on "Create Cluster".
-
After the cluster is created, you will be taken to a "Connect to _cluster_name" popup.
-
Under "Create Database User", you need to create a user with a username and password:
- Choose a Username (e.g.,
myUser). - Choose a Password (e.g.,
myPassword123). - Click on the "Create Database User" button.
- Choose a Username (e.g.,
-
After creating your database user, go to the next step in the popup.
-
Choose "Drivers" as the connection method.
-
Select Python as your driver.
-
In the next step, select the version of Python you’re using.
-
MongoDB will now show you the connection string. It will look something like this:
mongodb+srv://<username>:<password>@cluster0.mongodb.net/test?retryWrites=true&w=majority
Saves processed stems file to Supabase Storage.
Before running:
-
Go to your Supabase project dashboard
-
Navigate to Storage → Buckets
-
Create a new bucket with the name:
Media-Files -
Enable ✅ “Public bucket”
-
Inside this bucket, create a directory:
audio_stems
Now, Splitter AI will save all audio files under:
Media-Files/audio_stems/
The API supports two versions for stem extraction, each with different processing methods and costs:
| API Version | Processing Method | Cost | Notes |
|---|---|---|---|
| v1 | Local Processing | Free | Uses the local logic with HTDemucs model. Requires sufficient local resources. |
| v2 | Replicate | ~$0.039 / run | Uses cloud-based processing via Replicate. Ideal for scalable deployments without local GPU. |
💡 Tip: Use
v2if you want to offload processing power, or stick tov1for free local testing.
-
Clone the repository
git clone https://github.com/NafeesMadni/Stratum-Backend.git cd Stratum-Backend -
Install dependencies
uv sync
-
Activate the virtual environment (optional if you run via
uv run)source .venv/bin/activate # Linux / MacOS .venv\Scripts\activate # Windows
uv run main.py- App: http://127.0.0.1:8000
- Docs: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
celery -A app.core.celery_app worker --loglevel=infoRun all tests:
pytestRun Audio Processing API tests:
pytest tests/test_audio_api_workflow.pydocker-compose up --buildServices started:
- Redis (broker & backend for Celery)
- Web (FastAPI app) → http://localhost:8000
- Celery Worker (background task processor)
docker-compose downRemove volumes (e.g., Redis data):
docker-compose down -vdocker-compose logs -f # all services
docker-compose logs -f web # only FastAPI
docker-compose logs -f celery-worker