TODO
TODO
TODO
This setup has been tested with Python 3.11 and Node 16.
django
djangorestframework
django-extensions
- useful utilities (e.g better shell)django-cors-headers
- handling cross-origin requestspsycopg
- Postgres connector (needed in Docker container)drf-spectacular
- open api documentation (swagger and redoc)gunicorn
- production wsgi http serverwhitenoise
- building and serving static filespipenv
- venv and package management toolcoverage
- for code coverage reports and running unit testsmypy
+ djangorestframework-stubs
- for better typing experienceSuggested packages:
sentry-sdk
- for error reporting in productiondjango-debug-toolbar
- for debugging purposesdjango-filter
- enables filtering querysets with url parameters and morechannels
- websockets backenddjangorestframework-simplejwt
, dj-rest-auth
, django-allauth
, djoser
- making auth easierdjango-import-export
- import/export data from admin pagedjango-ninja
- API framework similar to Fast API but tied with Djangofactory-boy
- creating test data (for unit tests and staging)freezegun
- mocking time in unit testspytest
- alternative to built-in unittestplaywright
/ selenium
- for e2e testingUseful materials:
svelte
typescript
sass
- enables scss/sass supportaxios
- http requests clientvite
- bundlervitest
, @testing-library/svelte
+ additional packages - unit testing componentspnpm
- package managerSuggested packages:
shadcn-svelte
, TailwindCSS
, Svelte Material UI
, Smelte
, Carbon Components Svelte
,
Svelte Materialify
, Sveltestrap
etc.@tanstack/svelte-query
- for data fetching, caching and server state managementUseful materials:
Create a virtual environment and install dependencies from Pipfile with pipenv
cd backend
mkdir .venv
pipenv shell
pipenv run pip install --upgrade pip
pipenv install
If you are not using Docker, then you need to create a .env
file in the backend
directory and add the following
variables:
SECRET_KEY=your_secret_key
If you have multiple Python interpreters installed and you want to use version specified in the Pipfile, then you can
run commands prefixed with pipenv run
, otherwise first one from the system path will be used.
pipenv run COMMAND
Run django application from cmd (or add new Django configuration if using Pycharm)
python manage.py runserver
Preparing (if there are any changes to db schema) and running migrations
python manage.py makemigrations
python manage.py migrate
Create superuser
python manage.py createsuperuser
cd backend
Run tests using Coverage instead of python manage.py test
coverage run manage.py test
Get report from coverage:
coverage report -m
Install node dependencies. You may use npm instead of pnpm if you wish.
cd frontend
pnpm install
Run development server in second terminal (build script in watch mode)
pnpm dev
cd frontend
Run tests and gather coverage report
pnpm run test
pnpm run coverage
Run tests with Vitest in watch mode
pnpm test:watch
IMPORTANT: You need to change CRLF to LF in entrypoint-dev.sh, entrypoint-prod.sh and entrypoint-build.sh, otherwise build will fail because Linux uses different line endings than Windows. You can do this e.g. using Pycharm, choosing LF in Line Separator at the bottom bar. Other files are not affected by this issue.
Create env
directory in project's root directory and add corresponding .env files with environment variables:
env/backend.env
SECRET_KEY=your_secret_key
DJANGO_SETTINGS_MODULE=core.settings.dev
DB_NAME=postgres
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=postgres_db
DB_PORT=5432
env/frontend.env
CHOKIDAR_USEPOLLING=true
NODE_ENV=development
DOCKER=true
env/postgres.env
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
Make sure Docker Engine is running.
While in root directory, build docker images and run them with docker-compose. This might take up to few minutes. Rebuilding image is crucial after installing new packages via pip or npm.
docker-compose up --build
Application should be up and running at http://127.0.0.1:8000
.
Frontend build server runs in the background, does not output anything to the browser.
If images had been installed and no additional packages have been installed, just run to start containers:
docker-compose up
Bringing down containers with optional -v
flag removes all attached volumes and invalidates caches.
docker-compose down
To run commands in active container:
docker exec -it CONTAINER_NAME COMMAND
e.g.
docker exec -it backend python manage.py bash
Rebuilding individual containers instead of all of them
docker-compose build CONTAINER_NAME
docker-compose build CONTAINER_NAME --no-cache
Useful links:
To configure and launch the app, run the fly launch
command and follow the wizard.
You need to provision a Postgres database before launching the app.
Set environment variables in Fly.io dashboard or via flyctl
cli.
SECRET_KEY=...
PRODUCTION_HOST=<your_app_name>.fly.dev
fly secrets set VARIABLE=...
Obtain Fly.io API key and add it as a secret to your repository to enable continuous deployments.
fly auth token
fly deploy
fly ssh console