- Notifications
You must be signed in to change notification settings - Fork1
Django Powerful Movie Finder App
jackshendrikov/strichka
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 alsoregister 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 inPython 3.11 andDjango 4.1 (latest versions).
The application also has its ownAPI (REST) andSwagger.
Contains linters for checking code quality, integrated intoGitHub Actions.
The project hascaching for almost everything important. Therefore, a quick response will be even faster.
Also, the project is fullydockerized.
You can read about all the mentioned and other things further.
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 runmypy checks:
make types
To runflake8 checks:
make flake
To runblack checks:
make black
To run together:
make lint
Replace
.env.example
with real.env
, changing placeholdersSECRET_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!
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 onmore 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 throughPydantic
, similarly, if you want to add a new item through the admin panel, it will also be validated throughPydantic
models. See the logic for this inschema.py
.
Therefore, the data here is clean and beautiful (maybe not all).
Another cool feature of this project is the presence of its own API implemented using theDjango REST API
.
BasicAuthentication is configured for logging into the API. There are also corresponding serializers for each model. Views are implemented on the basis ofModelViewSet
.DjangoFilterBackend
from thedjango_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 theapi/
folder andserializers.py
for more details.
API View | API Filters |
---|---|
API POST Form | Swagger |
---|---|
Really, just look at this design, it's beautiful.
Here everything is written in pureCSS
+JavaScript
, also using such libraries asJQuery
,Bootstrap
,InfinityScroll
andOwl
.
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 thestatic
/ andtemplates/
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 |
---|---|---|
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 theimport-export
library is also implemented. For this, there is a corresponding resource for each model in theresource.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 is used here withallauth
.
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 bySendGrid
, 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 |
---|---|---|
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.
The app is fully dockerized. In thedocker
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.
Seedocker-compose.yml
for main logic.
For local testing (running through dev setup) debug toolbar is used, this great library isdjango-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 |
---|
🌍🇺🇦 | 🇺🇦 | 🇺🇦 | 🇺🇸 | 🌍 | 🇺🇦 |
🇺🇸 | 🇺🇸 | 🌍 | 🇺🇸 | 🇺🇸 | 🌍 |
🇺🇸 | 🇺🇸 | 🌍 | 🇺🇸 | 🇺🇸 | 🇺🇸 |
👑 Jack Shendrikov 👑 |