SongRadar is a song recommendation service that helps users discover music according to their tastes. This backend service is built using FastAPI and SQLite.
-
JWT Authorization: Uses JSON Web Tokens (JWT) for secure authorization, included as a bearer token in the header.
-
Password Hashing: All user passwords are securely hashed before being stored in the SQLite database.
-
Unique User Validation: Denies the creation of users with existing usernames or emails.
-
Username Requirements: Usernames must meet the following conditions:
- Must be at least 6 characters long
- Must not be more than 18 characters long
- Must only contain alphanumeric characters (letters and numbers)
- Must not begin with a number
-
Email Validation: Checks for valid email format during the sign-up process.
-
Strong Password Policy: Passwords must meet the following conditions:
- Minimum length of 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one numeric digit
- At least one special character
- No whitespace allowed
- Python
- FastAPI
- SQLite
- Uvicorn
- Python 3.10+
- pip
- virtualenv
-
Clone the repository
git clone https://github.com/ilhaniskurt/songradar-backend.git
-
Navigate to the project directory
cd songradar-backend
-
Create a virtual environment
virtualenv venv
-
Activate the virtual environment
On macOS and Linux:
source venv/bin/activate
On Windows:
venv\\Scripts\\activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
uvicorn app.main:app --reload
- URL:
/auth/sign_up
- Method:
POST
- Headers:
{ "accept": "application/json", "Content-Type": "application/json" }
- Body:
{ "username": "string", "email": "string", "password": "string" }
- Response:
{ "username": "string", "email": "string", "id": 0 }
- URL:
/auth/sign_in
- Method:
POST
- Headers:
{ "accept": "application/json" }
- Body:
{ "username": "string", "password": "string" }
- Response:
{ "access_token": "string", "token_type": "string" }
- Instructions: To use the returned access token, include it in the
Authorization
header with theBearer
keyword when making requests to endpoints that require authorization. For example:curl -X 'GET' \ 'http://127.0.0.1:8000/auth/me' \ -H 'accept: application/json' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwiZXhwIjoxNjk4NjgyMjE0fQ.dNvWxR8BG21vAaCnHd5LNX1_NoKpcjamNB_SHf1Y1NM'
- URL:
/auth/me
- Method:
GET
- Headers:
{ "accept": "application/json" "Authorization": "Bearer {access_token}" }
- Response:
{ "username": "string", "email": "string", "id": 1 }