Automated Action c5e673d2ea Implement complete beat marketplace API with FastAPI
- 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
2025-07-06 17:42:23 +00:00
2025-07-06 17:35:57 +00:00

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:
pip install -r requirements.txt
  1. 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 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:

uvicorn main:app --reload --host 0.0.0.0 --port 8000

Testing

The application includes a health check endpoint for monitoring.

Description
Project: Beat Marketplace API
Readme 43 KiB
Languages
Python 98.2%
Mako 1.8%