# 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 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run the application: ```bash 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 user - `POST /api/v1/auth/login` - Login and get access token ### Beats - `GET /api/v1/beats/` - Get all available beats - `GET /api/v1/beats/{beat_id}` - Get specific beat - `POST /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 file - `POST /api/v1/beats/{beat_id}/upload-preview` - Upload beat preview ### Transactions - `GET /api/v1/transactions/` - Get user's transactions - `GET /api/v1/transactions/{transaction_id}` - Get specific transaction - `POST /api/v1/transactions/purchase` - Purchase a beat - `PUT /api/v1/transactions/{transaction_id}/complete` - Complete transaction - `GET /api/v1/transactions/producer/sales` - Get producer's sales ### Files - `GET /api/v1/files/download/{beat_id}` - Download purchased beat - `GET /api/v1/files/preview/{beat_id}` - Get beat preview ### Health - `GET /health` - Health check endpoint - `GET /` - 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: ```bash uvicorn main:app --reload --host 0.0.0.0 --port 8000 ``` ## Testing The application includes a health check endpoint for monitoring.