A Django REST API for managing users and movies, allowing users to register, authenticate, add movies to their list, and view their collection. This API also allows users to store a list of URLs where each movie is available.
- User registration and authentication (JWT-based).
- Adding movies to a user's collection with an optional description.
- Storing URLs where each movie can be watched.
- Viewing the list of movies added by a user.
To run this project locally, follow these steps:
- Clone the repository:
git clone https://github.com/HETTski/movie-recommendation-AI-app.git cd movie-recommendation-api
- Set up the virtual environment:
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
- Install dependencies:
pip install -r req.txt
- Apply migrations:
python manage.py makemigrations python manage.py migrate
- Run the development server:
python manage.py runserver
Your API should now be running locally at http://127.0.0.1:8000
.
This API uses JSON Web Tokens (JWT) for authentication. You can obtain a token by sending a POST request with your credentials to /api/token/get. Include this token in the Authorization header for all authenticated requests.
- Register a new user at
/api/user/register/
. - Obtain a token by logging in at
/api/token/get
. - Use the token to add movies to the user's collection via
/api/user/movies/add/
. - View the user's movie collection at
/api/user/movies/
. - View for recommendation
/api/movies/recommendations/
.
- POST
/api/user/register/
: Register a new user. - POST
/api/token/get
: Obtain an access and refresh token. - POST
/api/token/refresh
: Refresh the access token using the refresh token.
- GET
/api/user/movies/
: Retrieve the current user's movie list. - POST
/api/user/movies/add/
: Add a movie to the current user's movie list. - POST
/api/movies/recommendations/
: Search new movies for all users or for auth users. Additional may use your movies db.
Sample JSON for Adding a Movie
{
"title": "Inception",
"description": "A mind-bending thriller about dreams within dreams.",
"sites": [
"https://example.com/inception",
"https://anotherexample.com/inception"
]
}
Sample JSON for Recommend Movies:
{
"query": "Recommend sci-fi movies",
"watched_movies": ["Interstellar", "Matrix"]
}
Optional
{
"query": "Recommend sci-fi movies",
"watched_movies": ["Interstellar", "Matrix"]
}
For Auth users:
{
"query": "Recommend sci-fi movies",
"use_db": true
}
For authenticated routes, use the token in the Authorization header:
Authorization: Bearer your_jwt_token
- Backend Framework: Django & Django REST Framework
- Database: PostgreSQL (with ArrayField for storing multiple URLs)
- Authentication: JWT (using django-rest-framework-simplejwt)
- Environment: Python 3
- AI: OpenAI (for movies recommendations)