You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Clone the repository
git clone git@github.com:fragforce/read.git
cdread# Copy environment config
cp .env.example .env # edit with your settings# Start the dev stack
docker compose up -d
# Run tests
docker compose run --rm test# Access the app
open http://localhost:8000
Docker Services
Service
Purpose
Default Command
web
Development server with hot reload
uv run --frozen python manage.py runserver 0.0.0.0:8000
test
Run the test suite
uv run --frozen pytest
db
PostgreSQL 18.3
-
The web and test services use the same image (Dockerfile) which includes all dev dependencies. Source code is volume-mounted so changes are reflected immediately.
Running Tests
# Full test suite
docker compose run --rm test# Specific module
docker compose run --rm test uv run pytest books/tests
# Specific test file
docker compose run --rm test uv run pytest books/tests/test_playback.py
# Specific test
docker compose run --rm test uv run pytest books/tests/test_playback.py::PlaybackViewTest::test_narrator_shown_before_password_entry
# With verbose output
docker compose run --rm test uv run pytest -v
# With coverage
docker compose run --rm test uv run coverage run -m pytest
docker compose run --rm test uv run coverage report
Linting
# Check for lint issues
docker compose run --rm test uv run ruff check .# Auto-fix lint issues
docker compose run --rm test uv run ruff check --fix .# Check formatting
docker compose run --rm test uv run ruff format --check .# Auto-format code
docker compose run --rm test uv run ruff format .
Development Workflow
Pre-commit Checks
Before committing code, always run:
# Lint
docker compose run --rm test uv run ruff check --fix .
docker compose run --rm test uv run ruff format .# Tests
docker compose run --rm test
Pull Request Requirements
All tests must pass (146+ tests)
Lint must pass (ruff check and format)
Coverage should remain at or above 85%
SonarCloud quality gate must pass
Adding Dependencies
# Add a production dependency
docker compose run --rm web uv add <package># Add a dev dependency
docker compose run --rm web uv add --dev <package># Sync dependencies after pulling
docker compose run --rm web uv sync --frozen
When Tests Are Required
Always for new features
Always for bug fixes
Always when modifying existing behavior
Tests should cover the happy path and edge cases
Database Management
Creating Migrations
# Generate migration for model changes
docker compose run --rm web uv run python manage.py makemigrations
# Apply migrations
docker compose run --rm web uv run python manage.py migrate
# Show migration status
docker compose run --rm web uv run python manage.py showmigrations
Resetting the Database
# Stop services
docker compose down
# Remove database volume
docker volume rm read_pgdata
# Restart and migrate
docker compose up -d
docker compose run --rm web uv run python manage.py migrate
docker compose run --rm web uv run python manage.py createsuperuser
Django Shell
# Interactive Python shell with Django loaded
docker compose run --rm web uv run python manage.py shell
# Example: Create test data
from books.models import Book
Book.objects.create(title="Test Book", slug="test", author="Author")
Admin Setup
Creating a Superuser
docker compose run --rm web uv run python manage.py createsuperuser
Then access the admin at http://localhost:8000/admin/
Admin Capabilities
Manage books, narrators, recordings, QR codes
Retry failed recordings
Generate narrator passphrases
Create event codes and invite links
Download QR code sheets
Debugging
Viewing Logs
# Follow all service logs
docker compose logs -f
# Follow specific service
docker compose logs -f web
# View recent logs
docker compose logs --tail=100 web
Container Shell Access
# Web service shell
docker compose exec web bash
# Database shell
docker compose exec db psql -U fragforce -d fragforce_read
Common Development Tasks
Testing the Recording Workflow
Create a superuser (see Admin Setup)
Log in at /admin/
Create a Book with public_domain=True
Create an InviteLink or EventCode
Register as narrator at /register/invite/<token> or /register/event/
Log in at /login/ with generated passphrase
Select book from dashboard and record
Creating Test Books
docker compose run --rm web uv run python manage.py shell
frombooks.modelsimportBook# Public domain book (no copyright checks)Book.objects.create(
title="Alice in Wonderland",
slug="alice",
author="Lewis Carroll",
public_domain=True,
estimated_duration="30 min"
)
# Licensed book (requires physical book)Book.objects.create(
title="Modern Book",
slug="modern",
author="Current Author",
public_domain=False,
publisher="Publisher Inc",
max_narrators=3,
estimated_duration="45 min"
)
Creating Invite Links
Via admin at /admin/registration/invitelink/add/ or shell: