
- Set up FastAPI project structure with main.py and requirements.txt - Created SQLite database models for users, beats, and transactions - Implemented Alembic database migrations - Added user authentication system with JWT tokens - Created beat management endpoints (CRUD operations) - Implemented purchase/transaction system - Added file upload/download functionality for beat files - Created health endpoint and API documentation - Updated README with comprehensive documentation - Fixed all linting issues with Ruff Environment variables needed: - SECRET_KEY: JWT secret key for authentication
Beat Marketplace API
A REST API for selling beats built with FastAPI and SQLite.
Features
- User registration and authentication
- Beat management (CRUD operations)
- File upload for beats and previews
- Purchase/transaction system
- Producer and buyer roles
- File downloads for purchased beats
- Health check endpoint
Installation
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
Environment Variables
Set the following environment variables for production:
SECRET_KEY
: JWT secret key for authentication (required)
API Endpoints
Authentication
POST /api/v1/auth/register
- Register a new userPOST /api/v1/auth/login
- Login and get access token
Beats
GET /api/v1/beats/
- Get all available beatsGET /api/v1/beats/{beat_id}
- Get specific beatPOST /api/v1/beats/
- Create new beat (producers only)PUT /api/v1/beats/{beat_id}
- Update beat (producers only)DELETE /api/v1/beats/{beat_id}
- Delete beat (producers only)POST /api/v1/beats/{beat_id}/upload-file
- Upload beat filePOST /api/v1/beats/{beat_id}/upload-preview
- Upload beat preview
Transactions
GET /api/v1/transactions/
- Get user's transactionsGET /api/v1/transactions/{transaction_id}
- Get specific transactionPOST /api/v1/transactions/purchase
- Purchase a beatPUT /api/v1/transactions/{transaction_id}/complete
- Complete transactionGET /api/v1/transactions/producer/sales
- Get producer's sales
Files
GET /api/v1/files/download/{beat_id}
- Download purchased beatGET /api/v1/files/preview/{beat_id}
- Get beat preview
Health
GET /health
- Health check endpointGET /
- API information
Database
The application uses SQLite database with the following models:
- Users (authentication and profiles)
- Beats (music files and metadata)
- Transactions (purchase records)
Database file is stored at: /app/storage/db/db.sqlite
File Storage
Beat files are stored in: /app/storage/beats/
Preview files are stored in: /app/storage/beats/previews/
Documentation
- API documentation available at
/docs
- ReDoc documentation available at
/redoc
- OpenAPI schema available at
/openapi.json
Development
Run with auto-reload:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
Testing
The application includes a health check endpoint for monitoring.
Description
Languages
Python
98.2%
Mako
1.8%