Thanks to visit codestin.com
Credit goes to docs.pdfding.com

Skip to content

Development Setup

Tech Stack

  • The web app is build using the Python web framework Django
  • Mozilla's PDF.js is used for viewing PDF files in the browser
  • The frondend is build using Alpine.js, htmx and Tailwind CSS
  • Authentication, registration, account management and OIDC are achieved by django-allauth

Setup

Note

Make sure you have installed Python 3, Poetry and Node.js on your system before you continue.

Fork the repository and cd into the project:

cd PdfDing

Create the virtual environment and install all dependencies:

poetry install

Activate the environment for your shell:

$( poetry env activate ) 

Install frontend dependencies:

mkdir ./js && mkdir ./css
npm ci
npm run build

Initialize the database:

python pdfding/manage.py migrate

Create a user for the frontend:

python pdfding/manage.py createsuperuser

Start the development server with:

# in one shell run
python pdfding/manage.py runserver
# in another run
npx @tailwindcss/cli -i pdfding/static/css/input.css -o pdfding/static/css/tailwind.css --watch

The frontend is now available under http://127.0.0.1:8000. Any changes in regard to Tailwind CSS will be automatically reflected.

Project Structure

PdfDing is built using the Django web framework. You can get started by checking out the excellent Django docs. Currently, PdfDing consists of four applications:

  • Inside the pdf folder is the one related to managing and viewing PDFs
  • the folder users contains the logic related to users
  • the admin area is implemented inside the admin folder
  • core is the Django root application

Testing

Run all tests with:

pytest

It's also possible to run unit tests and e2e tests separately. Unit tests can be run with:

pytest pdfding/admin pdfding/pdf pdfding/users --cov=pdfding/admin --cov=pdfding/pdf --cov=pdfding/users

E2e tests with

pytest pdfding/e2e

Code Quality

Formatting is done via black:

black .

Further code quality checks are done via flake8:

flake8

Pre-Commit

This project has support for pre-commit hooks. They are used for checking the code quality, e.g. with: black, flake8 and bandit. If pre-commit is installed on your system just run

pre-commit install

Now whenever you commit your changes the pre-commit hooks will be triggered. If you want to bypass pre-commit for some reason just add --no-verify to your commit command, e.g.:

git commit -m 'some commit message' --no-verify