Skip to content

jackshendrikov/strichka

Repository files navigation

Stand With Ukraine

Strichka UA

Welcome Logo

-----------------------------------------------------

-----------------------------------------------------

📖 Description

This project is designed to find movies, under the hood it contains a whole variety of different scrapers thanks to which you can find on which platforms a movie is available, so you can conveniently find a movie to watch on your favorite platform.

You can also register on the site (with email confirmation), after which you will become a full-fledged user.

Registered users have the opportunity to rate, comment and add movie to the watchlist.

The project is written in Python 3.11 and Django 4.1 (latest versions).

The application also has its own API (REST) and Swagger.

Contains linters for checking code quality, integrated into GitHub Actions.

The project has caching for almost everything important. Therefore, a quick response will be even faster.

Also, the project is fully dockerized.

You can read about all the mentioned and other things further.

-----------------------------------------------------

⚡️ Quickstart

  • Clone the repo.

  • Create and activate a python3 virtualenv via your preferred method.

  • Install the dependencies. Run:

     pip install -r requirements.txt
  • Install pre-commit hooks to ensure code quality checks and style checks:

     make install_hooks
    • You can also use these commands during dev process:

      • To run mypy checks:

         make types
      • To run flake8 checks:

         make flake
      • To run black checks:

         make black
      • To run together:

         make lint
  • Replace .env.example with real .env, changing placeholders

     SECRET_KEY=<fill-me>
     DEPLOY_ENVIRONMENT=<stage|prod>
    
     SITE_ID=<site-id>
    
     EMAIL_HOST_USER=<email-host-user>
     EMAIL_HOST_PASSWORD=email-host-password
     EMAIL_HOST=<email-host>
    
     DATABASE_URL=<postgres-connection-uri>
    
     REDIS_HOST=<redis-host>
     REDIS_PASSWORD=<redis-password>
     REDIS_PORT=<redis-port>
     REDIS_DB=<redis-db>
    
  • Export path to Environment Variables:

     export PYTHONPATH='.'
  • Run following commands to make migrations and create admin user:

     make migrate
     make user
  • Start the Strichka App:

    • Run server with test settings:

        make runserver-test
    • Run server with dev settings:

        make runserver-dev
    • Run server with prod settings:

        makerunserver-prod
  • Alternatively, you can just start Docker:

     make docker_build
  • And it's done!

-----------------------------------------------------

✨ Features

Scraping and Validation

Data scraping is one of the best features of this project, but due to its uniqueness, certain tricks and a bit of unpreparedness of the code, I did not include this module in this project.

At the moment, my project can find if a movie is available for viewing on more than 20 platforms, however, there are still big nuances with updating information, but at the basic level it is supported, at least once a month.

All data that was collected before entering the database is validated through Pydantic, similarly, if you want to add a new item through the admin panel, it will also be validated through Pydantic models. See the logic for this in schema.py.

Therefore, the data here is clean and beautiful (maybe not all).

REST API + Swagger

Another cool feature of this project is the presence of its own API implemented using the Django REST API.

BasicAuthentication is configured for logging into the API. There are also corresponding serializers for each model. Views are implemented on the basis of ModelViewSet. DjangoFilterBackend from the django_filters library is also implemented. This allows us to conveniently filter, sort and search our data. Of course, pagination is also available here.

Swagger was also installed for the project, drf_spectacular helped.

On the screenshots below, you can see how everything looks. See the api/ folder and serializers.py for more details.

API View API Filters
API POST Form Swagger

Awesome Front-End

Really, just look at this design, it's beautiful.

Here everything is written in pure CSS + JavaScript, also using such libraries as JQuery, Bootstrap, InfinityScroll and Owl.

I tried to make the design as user-friendly and pleasant as possible, so it supports easily on phones as well.

For more details, see the implementation in the static/ and templates/ folders.

And on the screenshots below you can see all the beauty of my project:

Main Page Movies List Movie Page
Movie Page Extra Collection Page Comments

Admin Panel

The structure of the admin panel was designed here for the most convenient data management, you can see the implementation in the admin.py files.

It includes pagination, searching, filtering of selected fields, specific sorting, and the ability to edit selected fields in-place.

The logic for data import/export using the import-export library is also implemented. For this, there is a corresponding resource for each model in the resource.py file.

The theme for the admin panel is based on this beautiful library - django-jazzmin. This is how it looks:

Login Page Dashboard
Model View Edit View

Authentication

Authentication is used here with allauth.

Also, confirmation of your mail is configured here through an email with a verification link, which will be sent to the specified mail, valid for 1 day.

Since Google removed access for less secure applications, the whole process related to emails is now handled by SendGrid, so that's why you can see the following configuration for email in the settings:

EMAIL_HOST = "smtp.sendgrid.net"

You can see an example of registration on the site below:

Sign Up Page Validation Email Confirmation Page
Password Reset Page Password Reset Email Login Page

Caching

At first, I wrote myself the logic for caching and resetting the cache when the state of the model object changes, but later I just gave the cache handling to this wonderful library - django-cacheops.

Now the project has caching of almost all queries, caches selected views, and in the future I think I will add caching of template fragments. Caching is never enough!

I have Redis on the server to store the cache.

Dockerization

The app is fully dockerized. In the docker folder, you can find Dockerfiles for configuring the database (Postgres 15.1) and for configuring the project itself (Python 3.11).

Also in this folder there are bash scripts, one of which is an entrypoint for the application, and the other is used to transfer the dump of the production database to docker Postgres.

See docker-compose.yml for main logic.

Debug Toolbar

For local testing (running through dev setup) debug toolbar is used, this great library is django-debug-toolbar.

These panels helped me find a bunch of problems that I later solved. Do not pass this treasure)

In the photo you can see which panels are used in this application:

Debug Toolbar View

-----------------------------------------------------

🎞️ Supported Platforms

NetflixNetflix
🌍🇺🇦
MegogoMegogo
🇺🇦
KyivstarKyivstar TV
🇺🇦
DisneyDisney+
🇺🇸
YouTubeYouTube TV
🌍
UAkinoUAkino
🇺🇦
HBOHBO MAX
🇺🇸
PrimeAmazon Prime
🇺🇸
AppleTVAppleTV+
🌍
HuluHulu
🇺🇸
MegogoPeacock
🇺🇸
MegogoiTunes
🌍
AmazonAmazon
🇺🇸
Google PlayGoogle Play
🇺🇸
Microsoft StoreMicrosoft Store
🌍
ParamountParamount+
🇺🇸
ShudderShudder
🇺🇸
SyfySyfy
🇺🇸

-----------------------------------------------------

📚 Stack

-----------------------------------------------------

✨ Contributors

Jack Shendrikov
👑 Jack Shendrikov 👑

-----------------------------------------------------

✨ 🍰 ✨