Skip to content

Repository files navigation

MovieRanker

MovieRanker is a prototype web application written in Django. Its primary goal is to help users discover movies tailored to their preferences using The Movie Database (TMDB) API.


Features

  • Integration with TMDB API: Fetch movie genres, ranks, and other details using TMDB API endpoints.
  • Genre Filtering: Filter movies by selecting genres from a dropdown menu.
  • Dynamic Movie List: Display a ranked list of movies based on the selected genre.
  • Movie Details Page: View detailed information about a selected movie.

Key Components

  1. api.py:

    • Interacts with the TMDB API.
    • Fetches genres, movies by genre, and detailed movie information.
  2. views.py:

    • Handles user requests and business logic.
    • Includes views for the movie list and movie details.
  3. models.py:

    • Defines the data structure for movies.
  4. movie_list.html:

    • Frontend template for viewing and filtering movies by genre.
  5. movie_details.html:

    • Frontend template for displaying detailed information about a specific movie.

Installation and Setup

Follow these steps to set up and run MovieRanker locally:

Prerequisites

  • Python 3.9 or higher
  • Django installed
  • TMDB API Key (for API integration)

Steps

  1. Clone the Repository:

    git clone https://github.com/Mike014/MovieRanker.git
    cd MovieRanker
  2. Set Up a Virtual Environment:

    python3 -m venv venv
    source venv/bin/activate  # Mac/Linux
    venv\\Scripts\\activate     # Windows
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Run Database Migrations:

    python manage.py migrate
  5. Set Up TMDB API Key: • Create a .env file in the root directory. • Add your TMDB API key:

    TMDB_API_KEY=your_api_key_here
  6. Run the Development Server:

    python manage.py runserver
  7. Access the Application:

    http://127.0.0.1:8000/
    

Development Workflow

Linting and Formatting

  • This project uses Pylint, Black, and isort for linting and formatting. Pre-commit hooks are set up to enforce these standards.

    1. Install pre-commit:
      pip install pre-commit
      pre-commit install
    2. Run pre-commit hooks:
      pre-commit run --all-files

    Running Tests

    To run tests, use:

    pytest

    Using Tox Tox is configured to automate testing and linting:

    tox

    GitHub Actions The project includes a GitHub Actions workflow for automated testing and linting. The configuration is in .github/workflows/lint-and-test.yml.

    Running Django Tests To run Django tests for the Movies app and discover any bugs, you can use the following command:

     python manage.py test movies

Useful TMDB API Endpoints

  1. Fetch Genre List:

    https://api.themoviedb.org/3/genre/movie/list
  2. Discover Movies by Genre:

    https://api.themoviedb.org/3/discover/movie
  3. Get Movie Details:

    https://api.themoviedb.org/3/movie/{movie_id}
  4. Fetch Similar Movies:

    https://api.themoviedb.org/3/movie/{movie_id}/similar

Back-End Database with PostgreSQL

Install and Configure Docker

  1. Install Docker:

    • Visit Docker Desktop and download the version for your operating system (Windows, macOS, Linux).
    • Follow the installation instructions.
  2. Start a PostgreSQL Container:

    docker run --name postgres -e POSTGRES_PASSWORD=your_password_here -d -p 5432:5432 postgres
  3. Verify the PostgreSQL Container is Running::

    docker ps
    • Displays all active containers.
  4. Test Database Connection::

    docker ps

    OR

    python manage.py dbshell
    • Perform Database Migrations
    python manage.py makemigrations
    python manage.py migrate

Querying the Database

  • First i have created a Custom Management Command:
movies/
    management/
        __init__.py
        commands/
            __init__.py
            query_movies.py
  • To run the command, use:
python manage.py query_movies --type all
  • Check in the query_mvovies.py which command you can use for querying the database

Documentation

  • The documentation for MovieRanker is available at: MovieRanker Documentation
  • Created a new requirements.txt file with command:
pip install pipreqs
pipreqs .
  • created docker file, you can buld the image with this command:
docker build . -t movies:latest && docker run -e PYTHONUNBUFFERED=1 -p 8000:8000 movies

Future Goals

  • Implement content-based and collaborative filtering for advanced movie recommendations.
  • Enhance user interface and add user authentication.
  • Deploy the application on a cloud platform.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Feel free to fork the repository and submit pull requests.

Contact

Maintainer: Michele Grimaldi GitHub: Mike014Mike014

About

A Django-based web application that fetches and displays movies from The Movie Database (TMDB) API, allowing users to filter movies by genre.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages