movienight-app 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- movienight_app-1.1.0/.env.example +31 -0
- movienight_app-1.1.0/.gitignore +37 -0
- movienight_app-1.1.0/CHANGELOG.md +74 -0
- movienight_app-1.1.0/LICENSE +21 -0
- movienight_app-1.1.0/PKG-INFO +227 -0
- movienight_app-1.1.0/README.md +192 -0
- movienight_app-1.1.0/SECURITY.md +16 -0
- movienight_app-1.1.0/deploy/Caddyfile.example +12 -0
- movienight_app-1.1.0/deploy/movienight.service +28 -0
- movienight_app-1.1.0/pyproject.toml +76 -0
- movienight_app-1.1.0/scripts/__init__.py +0 -0
- movienight_app-1.1.0/scripts/seed_demo.py +8 -0
- movienight_app-1.1.0/src/movienight/__init__.py +3 -0
- movienight_app-1.1.0/src/movienight/auth.py +62 -0
- movienight_app-1.1.0/src/movienight/cli.py +116 -0
- movienight_app-1.1.0/src/movienight/config.py +35 -0
- movienight_app-1.1.0/src/movienight/database.py +37 -0
- movienight_app-1.1.0/src/movienight/dependencies.py +76 -0
- movienight_app-1.1.0/src/movienight/frontend/admin.html +83 -0
- movienight_app-1.1.0/src/movienight/frontend/app.html +151 -0
- movienight_app-1.1.0/src/movienight/frontend/css/admin.css +77 -0
- movienight_app-1.1.0/src/movienight/frontend/css/app.css +293 -0
- movienight_app-1.1.0/src/movienight/frontend/css/base.css +315 -0
- movienight_app-1.1.0/src/movienight/frontend/css/swipe.css +168 -0
- movienight_app-1.1.0/src/movienight/frontend/fonts/OFL.txt +93 -0
- movienight_app-1.1.0/src/movienight/frontend/fonts/inter-latin-wght-normal.woff2 +0 -0
- movienight_app-1.1.0/src/movienight/frontend/fonts/inter.css +10 -0
- movienight_app-1.1.0/src/movienight/frontend/img/favicon.svg +1 -0
- movienight_app-1.1.0/src/movienight/frontend/img/icons.svg +36 -0
- movienight_app-1.1.0/src/movienight/frontend/index.html +45 -0
- movienight_app-1.1.0/src/movienight/frontend/js/admin.js +441 -0
- movienight_app-1.1.0/src/movienight/frontend/js/api.js +123 -0
- movienight_app-1.1.0/src/movienight/frontend/js/app.js +669 -0
- movienight_app-1.1.0/src/movienight/frontend/js/login.js +30 -0
- movienight_app-1.1.0/src/movienight/frontend/js/register.js +50 -0
- movienight_app-1.1.0/src/movienight/frontend/js/store.js +110 -0
- movienight_app-1.1.0/src/movienight/frontend/js/swipe.js +382 -0
- movienight_app-1.1.0/src/movienight/frontend/js/ui.js +162 -0
- movienight_app-1.1.0/src/movienight/frontend/register.html +61 -0
- movienight_app-1.1.0/src/movienight/main.py +120 -0
- movienight_app-1.1.0/src/movienight/migrations.py +26 -0
- movienight_app-1.1.0/src/movienight/models.py +205 -0
- movienight_app-1.1.0/src/movienight/rate_limit.py +69 -0
- movienight_app-1.1.0/src/movienight/routers/__init__.py +0 -0
- movienight_app-1.1.0/src/movienight/routers/admin.py +205 -0
- movienight_app-1.1.0/src/movienight/routers/auth.py +124 -0
- movienight_app-1.1.0/src/movienight/routers/comments.py +83 -0
- movienight_app-1.1.0/src/movienight/routers/movies.py +166 -0
- movienight_app-1.1.0/src/movienight/routers/round_guests.py +53 -0
- movienight_app-1.1.0/src/movienight/routers/rounds.py +170 -0
- movienight_app-1.1.0/src/movienight/routers/tmdb.py +151 -0
- movienight_app-1.1.0/src/movienight/routers/votes.py +97 -0
- movienight_app-1.1.0/src/movienight/schemas.py +218 -0
- movienight_app-1.1.0/src/movienight/seed_demo.py +78 -0
- movienight_app-1.1.0/tests/__init__.py +0 -0
- movienight_app-1.1.0/tests/conftest.py +86 -0
- movienight_app-1.1.0/tests/test_admin.py +44 -0
- movienight_app-1.1.0/tests/test_auth.py +98 -0
- movienight_app-1.1.0/tests/test_cli.py +55 -0
- movienight_app-1.1.0/tests/test_rounds.py +181 -0
- movienight_app-1.1.0/tests/test_scoping.py +86 -0
- movienight_app-1.1.0/tests/test_security.py +146 -0
- movienight_app-1.1.0/tests/test_tmdb.py +37 -0
- movienight_app-1.1.0/tests/test_votes.py +65 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Copy to .env and fill in. Never commit .env.
|
|
2
|
+
|
|
3
|
+
# Signs the login tokens (JWT). Generate with:
|
|
4
|
+
# python -c "import secrets; print(secrets.token_urlsafe(48))"
|
|
5
|
+
SECRET_KEY=change-me
|
|
6
|
+
|
|
7
|
+
# Token lifetime in minutes (default: 7 days).
|
|
8
|
+
ACCESS_TOKEN_EXPIRE_MINUTES=10080
|
|
9
|
+
|
|
10
|
+
# SQLite file, relative to the working directory.
|
|
11
|
+
DATABASE_URL=sqlite:///./movienight.db
|
|
12
|
+
|
|
13
|
+
# TMDB API key (v3 auth) from https://www.themoviedb.org/settings/api
|
|
14
|
+
# Without it the app works, but movie search is disabled.
|
|
15
|
+
TMDB_API_KEY=
|
|
16
|
+
|
|
17
|
+
# Proposals per person and round (admins are not limited).
|
|
18
|
+
MAX_MOVIES_PER_USER=3
|
|
19
|
+
|
|
20
|
+
# Initial admin, created on first start only (when no admin exists yet).
|
|
21
|
+
# The password must be at least 12 characters; there is no default.
|
|
22
|
+
FIRST_ADMIN_USERNAME=admin
|
|
23
|
+
FIRST_ADMIN_PASSWORD=
|
|
24
|
+
|
|
25
|
+
# Only needed if the frontend is served from a different origin.
|
|
26
|
+
# JSON list, e.g. ["https://movies.example.com"]
|
|
27
|
+
CORS_ORIGINS=[]
|
|
28
|
+
|
|
29
|
+
# Login/registration attempts per client IP and time window.
|
|
30
|
+
AUTH_RATE_LIMIT=10
|
|
31
|
+
AUTH_RATE_WINDOW_SECONDS=300
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Environment & Secrets
|
|
2
|
+
.env
|
|
3
|
+
*.db
|
|
4
|
+
*.db-shm
|
|
5
|
+
*.db-wal
|
|
6
|
+
|
|
7
|
+
# Python
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*.pyo
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
env/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
dist/
|
|
16
|
+
build/
|
|
17
|
+
|
|
18
|
+
# Editor
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
|
|
24
|
+
# OS
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# Logs
|
|
29
|
+
*.log
|
|
30
|
+
logs/
|
|
31
|
+
|
|
32
|
+
# Binaries and local artifacts
|
|
33
|
+
*.deb
|
|
34
|
+
*.sqlite
|
|
35
|
+
*.sqlite3
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
.ruff_cache/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [1.1.0] - 2026-12-04
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Packaged as `movienight-app` for PyPI (`src/movienight/` layout with bundled frontend assets) and a `movienight` CLI (`serve`, `demo`, `seed-demo`, `--version`).
|
|
11
|
+
- Hardened `Dockerfile` (non-root user, healthcheck, `/data` volume), `docker-compose.yml`, and `.dockerignore`.
|
|
12
|
+
- Release workflow (`.github/workflows/release.yml`) for PyPI Trusted Publishing and GHCR container images.
|
|
13
|
+
|
|
14
|
+
### Upgrade notes
|
|
15
|
+
- Existing systemd deployments should update `ExecStart` from `uvicorn app.main:app ...` to `movienight serve ...` (or `uvicorn movienight.main:app ...`) after installing the package (`pip install -e .`). Existing `.env` files and SQLite databases remain compatible.
|
|
16
|
+
|
|
17
|
+
## [1.0.0] - 2026-10-10
|
|
18
|
+
|
|
19
|
+
A complete overhaul of security, backend and design.
|
|
20
|
+
|
|
21
|
+
### Upgrade notes
|
|
22
|
+
|
|
23
|
+
- **Everyone has to log in once.** Login tokens are now bound to the user id
|
|
24
|
+
and a per-user token version; tokens from earlier versions are rejected.
|
|
25
|
+
Passwords and all other data stay as they are.
|
|
26
|
+
- The new `users.token_version` column is added automatically at startup.
|
|
27
|
+
- SQLite now runs in WAL mode. Back up with `sqlite3 <db> ".backup <file>"`
|
|
28
|
+
instead of copying the file.
|
|
29
|
+
- Installs without `DATABASE_URL` keep using `filmabend.db`. Do not replace
|
|
30
|
+
an existing `.env` with the new `.env.example`.
|
|
31
|
+
|
|
32
|
+
### Security
|
|
33
|
+
|
|
34
|
+
- Tokens of a deleted user no longer work for a new account registered with
|
|
35
|
+
the same name; password changes and resets log out all other sessions.
|
|
36
|
+
- Votes are only accepted for films of the active round; guests only see
|
|
37
|
+
comments of the round they were invited to; TMDB search requires round
|
|
38
|
+
access.
|
|
39
|
+
- Login timing no longer reveals which usernames exist; usernames are unique
|
|
40
|
+
ignoring case; single-use invite links cannot be redeemed twice in parallel.
|
|
41
|
+
- Strict Content-Security-Policy, Permissions-Policy and cache headers; the
|
|
42
|
+
frontend has no inline scripts anymore.
|
|
43
|
+
- Invite links carry the token in the URL fragment instead of the query
|
|
44
|
+
string.
|
|
45
|
+
- The login rate limiter no longer grows without bound.
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
|
|
49
|
+
- Redesigned interface with a shared design system, native dialogs and
|
|
50
|
+
empty states for every situation.
|
|
51
|
+
- Rebuilt swipe mode: card deck, drag and flick gestures, undo, "later",
|
|
52
|
+
keyboard shortcuts and a summary.
|
|
53
|
+
- Optimistic voting shared by grid, detail view and swipe deck.
|
|
54
|
+
- Manual proposals when no TMDB key is configured.
|
|
55
|
+
- Password change for everyone; admins can reactivate users and grant or
|
|
56
|
+
revoke admin rights.
|
|
57
|
+
- `MAX_MOVIES_PER_USER` setting and `GET /movies/config`.
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- A wrong password reloaded the login page instead of showing an error.
|
|
62
|
+
- Most films had no trailer because only German videos were searched.
|
|
63
|
+
- "Mark watched" in the admin panel also tried to complete the round.
|
|
64
|
+
- Deleting a user removed watched films from the history.
|
|
65
|
+
- Invite expiry times were shown one or two hours off.
|
|
66
|
+
- New rounds used a removal limit of 3 instead of the documented 4.
|
|
67
|
+
- Comment delete buttons were invisible on touch screens.
|
|
68
|
+
|
|
69
|
+
## [0.2.0] - 2026-10-09
|
|
70
|
+
|
|
71
|
+
Initial public release.
|
|
72
|
+
|
|
73
|
+
[1.0.0]: https://github.com/nbomers/movienight/compare/338a55d...v1.0.0
|
|
74
|
+
[0.2.0]: https://github.com/nbomers/movienight/commit/338a55d
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Noah Bomers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: movienight-app
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Self-hosted movie-night voting app for friend groups: propose films, swipe, vote, watch.
|
|
5
|
+
Project-URL: Homepage, https://github.com/nbomers/movienight
|
|
6
|
+
Project-URL: Repository, https://github.com/nbomers/movienight
|
|
7
|
+
Project-URL: Issues, https://github.com/nbomers/movienight/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/nbomers/movienight/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Noah Bomers
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: src/movienight/frontend/fonts/OFL.txt
|
|
13
|
+
Keywords: fastapi,movie-night,self-hosted,sqlite,tmdb,voting
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Framework :: FastAPI
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Requires-Dist: bcrypt<5,>=4.2
|
|
24
|
+
Requires-Dist: fastapi<1,>=0.115
|
|
25
|
+
Requires-Dist: httpx<1,>=0.27
|
|
26
|
+
Requires-Dist: pydantic-settings<3,>=2.5
|
|
27
|
+
Requires-Dist: pydantic<3,>=2.9
|
|
28
|
+
Requires-Dist: pyjwt<3,>=2.10
|
|
29
|
+
Requires-Dist: sqlalchemy<3,>=2.0
|
|
30
|
+
Requires-Dist: uvicorn[standard]<1,>=0.30
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest<10,>=8.3; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff<1,>=0.6; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
<h1 align="center">movienight</h1>
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<strong>A self-hosted movie-night voting app for friend groups.</strong><br>
|
|
40
|
+
Propose films, swipe through the shortlist, and let the group decide what you watch on Friday.
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
<p align="center">
|
|
44
|
+
<a href="https://github.com/nbomers/movienight/actions/workflows/ci.yml"><img src="https://github.com/nbomers/movienight/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
45
|
+
<img src="https://img.shields.io/badge/python-3.12-3776AB?logo=python&logoColor=white" alt="Python 3.12">
|
|
46
|
+
<img src="https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi&logoColor=white" alt="FastAPI">
|
|
47
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="docs/desktop.jpg" alt="Ranked poster grid with the current round, deadline countdown and voting progress" width="900">
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<p align="center">
|
|
55
|
+
<img src="docs/swipe.jpg" width="250" alt="Swipe tab: dragging a card to the right to like it">
|
|
56
|
+
<img src="docs/voting.jpg" width="250" alt="Phone view of the ranked grid">
|
|
57
|
+
<img src="docs/detail.jpg" width="250" alt="Movie detail with votes, overview and comments">
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<p align="center"><sub>Screenshots use the demo data from <code>scripts/seed_demo.py</code> with placeholder poster art.</sub></p>
|
|
61
|
+
|
|
62
|
+
## How it works
|
|
63
|
+
|
|
64
|
+
1. The admin starts a **round** with a voting deadline.
|
|
65
|
+
2. Everyone **proposes** up to three films (configurable), found through TMDB search or entered by hand.
|
|
66
|
+
3. The group **votes**: like, nope, and one superlike per person and round, either in the ranked grid or by swiping through cards.
|
|
67
|
+
4. After movie night, the admin **closes the round** and marks the film you watched. Everything else moves on to the next round with fresh votes, and films nobody picks for too long drop out on their own.
|
|
68
|
+
|
|
69
|
+
> **Note:** The interface is in German, and deadlines are entered and shown in Europe/Berlin time.
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
**Voting**
|
|
74
|
+
- Ranked poster grid; a superlike counts like three likes, a nope subtracts one
|
|
75
|
+
- Swipe mode with drag and flick gestures, keyboard shortcuts, undo, "later" and a summary at the end
|
|
76
|
+
- Live countdown to the deadline; voting and proposals close automatically
|
|
77
|
+
|
|
78
|
+
**Rounds**
|
|
79
|
+
- One active round at a time, with optional deadline
|
|
80
|
+
- Unwatched films carry over and retire after a configurable number of rounds
|
|
81
|
+
- History of every film you watched, with date and who proposed it
|
|
82
|
+
|
|
83
|
+
**People**
|
|
84
|
+
- Invite-only accounts through single- or multi-use links
|
|
85
|
+
- Regulars see every round; guests only the rounds they were invited to
|
|
86
|
+
- Comments per film; everyone can change their own password
|
|
87
|
+
- Admin panel for rounds, guests, invite links and accounts (roles, password reset, deactivation)
|
|
88
|
+
|
|
89
|
+
**Under the hood**
|
|
90
|
+
- FastAPI, SQLite and plain JavaScript modules: no build step, no `node_modules`
|
|
91
|
+
- Posters, genres, overviews and German or English trailers from TMDB; works without a TMDB key
|
|
92
|
+
- Strict Content-Security-Policy, rate-limited login and invite redemption, tokens revoked on password change
|
|
93
|
+
|
|
94
|
+
## Quickstart
|
|
95
|
+
|
|
96
|
+
Requires Python 3.12+ (or Docker).
|
|
97
|
+
|
|
98
|
+
**Try the demo in one command** (temporary SQLite DB, no `.env` needed):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uvx movienight-app demo
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Open <http://localhost:8000> and log in as `demo_admin`, `alex`, `sam` or `robin` (a guest), all with the password `demo-password`.
|
|
105
|
+
|
|
106
|
+
**Install from PyPI:**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv tool install movienight-app # or: pip install movienight-app
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Create a `.env` file (see [`.env.example`](.env.example)), then start the server:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
movienight serve --host 127.0.0.1 --port 8000
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Run with Docker Compose:**
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
git clone https://github.com/nbomers/movienight.git
|
|
122
|
+
cd movienight
|
|
123
|
+
cp .env.example .env
|
|
124
|
+
# Set SECRET_KEY and FIRST_ADMIN_PASSWORD in .env (TMDB_API_KEY is optional).
|
|
125
|
+
docker compose up -d
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Local development:**
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git clone https://github.com/nbomers/movienight.git
|
|
132
|
+
cd movienight
|
|
133
|
+
python -m venv .venv && source .venv/bin/activate
|
|
134
|
+
pip install -r requirements-dev.txt
|
|
135
|
+
|
|
136
|
+
cp .env.example .env
|
|
137
|
+
movienight seed-demo # optional: demo users, films and an active round
|
|
138
|
+
movienight serve --reload
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Without demo data, the app creates the first admin from `FIRST_ADMIN_USERNAME` and `FIRST_ADMIN_PASSWORD` on first start, and refuses to start while no password is set. There is no default password.
|
|
142
|
+
|
|
143
|
+
Run the checks:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
ruff check .
|
|
147
|
+
pytest
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
All settings come from environment variables or a `.env` file.
|
|
153
|
+
|
|
154
|
+
| Variable | Default | Purpose |
|
|
155
|
+
|---|---|---|
|
|
156
|
+
| `SECRET_KEY` | *(required)* | Signs login tokens. Generate with `python -c "import secrets; print(secrets.token_urlsafe(48))"` |
|
|
157
|
+
| `DATABASE_URL` | `sqlite:///./filmabend.db` | SQLite database file; `.env.example` uses `movienight.db` |
|
|
158
|
+
| `TMDB_API_KEY` | *(empty)* | Enables movie search; without it, films are entered by hand |
|
|
159
|
+
| `MAX_MOVIES_PER_USER` | `3` | Proposals per person and round (admins are not limited) |
|
|
160
|
+
| `ACCESS_TOKEN_EXPIRE_MINUTES` | `10080` | Login lifetime (7 days) |
|
|
161
|
+
| `FIRST_ADMIN_USERNAME` | `admin` | Initial admin, created on first start only |
|
|
162
|
+
| `FIRST_ADMIN_PASSWORD` | *(empty)* | At least 12 characters; required until an admin exists |
|
|
163
|
+
| `AUTH_RATE_LIMIT` | `10` | Failed logins or registrations per client IP … |
|
|
164
|
+
| `AUTH_RATE_WINDOW_SECONDS` | `300` | … within this window |
|
|
165
|
+
| `CORS_ORIGINS` | `[]` | Only needed when the frontend is served from another origin |
|
|
166
|
+
|
|
167
|
+
## Self-hosting
|
|
168
|
+
|
|
169
|
+
The app is a single process that serves the API and the frontend from the same origin. A typical setup:
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
Browser ──HTTPS──▶ Caddy ──▶ uvicorn / FastAPI ──▶ SQLite
|
|
173
|
+
│
|
|
174
|
+
└──▶ TMDB API (search, details, trailers)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Deployment files:
|
|
178
|
+
|
|
179
|
+
- [`docker-compose.yml`](docker-compose.yml) + [`Dockerfile`](Dockerfile): non-root container with read-only root filesystem, `/health` check and a persistent `/data` volume for SQLite
|
|
180
|
+
- [`deploy/movienight.service`](deploy/movienight.service): systemd unit that binds `movienight serve` to localhost and enables `--proxy-headers`, so the rate limit sees real client IPs
|
|
181
|
+
- [`deploy/Caddyfile.example`](deploy/Caddyfile.example): reverse proxy with automatic HTTPS, plus a variant for use behind Cloudflare Tunnel
|
|
182
|
+
|
|
183
|
+
Run a single uvicorn worker: the login rate limit is kept in memory.
|
|
184
|
+
|
|
185
|
+
**Backups.** SQLite runs in WAL mode, so a plain file copy of a running database can miss recent writes. Use SQLite's backup command instead:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
sqlite3 movienight.db ".backup movienight-$(date +%F).db"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Updating.** Pull, install the requirements and restart the service. Schema changes are applied automatically at startup. Check the [changelog](CHANGELOG.md) for anything that needs attention, such as everyone having to log in again after 1.0.0.
|
|
192
|
+
|
|
193
|
+
## Design decisions
|
|
194
|
+
|
|
195
|
+
**SQLite instead of Postgres.** A friend group produces a few hundred rows a year, with one writer most of the time. SQLite means no extra service, a single file to back up, and a test suite that runs against the same engine as production. WAL mode and a busy timeout let a group vote at the same moment. If this ever needed several app servers, the database would be the first thing to change.
|
|
196
|
+
|
|
197
|
+
**No frontend framework.** The UI is a handful of views over a small JSON API. Plain ES modules load directly in the browser, so there is no build step and deploying is copying files. The cost is manual DOM updates and manual escaping: every value from the API goes through one `esc()` helper before it reaches `innerHTML`, and the backend only accepts poster paths and trailer links in the exact shape TMDB produces.
|
|
198
|
+
|
|
199
|
+
**Round logic.** Exactly one round is active at a time. When the admin closes a round, they mark the film that was watched and it leaves the pool. When the next round starts, all other films from the last round move over, their votes are cleared, and their `rounds_survived` counter goes up. Once it reaches the configured limit (default 4), the film retires. The list stays fresh without anyone cleaning it up by hand.
|
|
200
|
+
|
|
201
|
+
**Superlikes are derived, not stored.** Whether someone has used their superlike is a query over the current round's votes. An earlier version kept a separate list that could drift from the votes, for example when a superliked film was removed.
|
|
202
|
+
|
|
203
|
+
**Optimistic voting.** A vote updates the UI immediately and is rolled back if the server rejects it. The grid, the detail view and the swipe deck share one store, so they never disagree.
|
|
204
|
+
|
|
205
|
+
**Time zones.** Deadlines are entered as Berlin time, converted to UTC for storage and sent to the browser with an explicit offset. SQLite does not store offsets, so the API attaches UTC when reading.
|
|
206
|
+
|
|
207
|
+
## Security
|
|
208
|
+
|
|
209
|
+
- **Accounts** exist only through invite links (`secrets.token_urlsafe(32)`). The token travels in the URL fragment, so it never reaches server or proxy logs.
|
|
210
|
+
- **Sessions** are signed JWTs bound to the user id and a per-user token version. Changing or resetting a password logs out every other session; deactivating a user takes effect on their next request.
|
|
211
|
+
- **Login** answers unknown users and wrong passwords with the same error in the same time. Usernames are unique ignoring case. Failed logins and invite redemptions are rate-limited per IP.
|
|
212
|
+
- **Access** is checked on every round-scoped endpoint: guests only see the round they were invited to, including its comments and the TMDB search.
|
|
213
|
+
- **Frontend:** no inline scripts or event handlers, and a strict Content-Security-Policy (`script-src 'self'`), so injected markup cannot run code even if an escaping mistake slipped through. A test keeps it that way.
|
|
214
|
+
|
|
215
|
+
Found a vulnerability? Please report it privately as described in [SECURITY.md](SECURITY.md) rather than opening a public issue.
|
|
216
|
+
|
|
217
|
+
## Contributing
|
|
218
|
+
|
|
219
|
+
Issues and pull requests are welcome. Please run `ruff check .` and `pytest` before opening a pull request; CI runs both.
|
|
220
|
+
|
|
221
|
+
## TMDB attribution
|
|
222
|
+
|
|
223
|
+
This product uses the TMDB API but is not endorsed or certified by TMDB.
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
[MIT](LICENSE). The bundled Inter font is licensed under the [SIL Open Font License](src/movienight/frontend/fonts/OFL.txt).
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
<h1 align="center">movienight</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>A self-hosted movie-night voting app for friend groups.</strong><br>
|
|
5
|
+
Propose films, swipe through the shortlist, and let the group decide what you watch on Friday.
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://github.com/nbomers/movienight/actions/workflows/ci.yml"><img src="https://github.com/nbomers/movienight/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
10
|
+
<img src="https://img.shields.io/badge/python-3.12-3776AB?logo=python&logoColor=white" alt="Python 3.12">
|
|
11
|
+
<img src="https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi&logoColor=white" alt="FastAPI">
|
|
12
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="docs/desktop.jpg" alt="Ranked poster grid with the current round, deadline countdown and voting progress" width="900">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="docs/swipe.jpg" width="250" alt="Swipe tab: dragging a card to the right to like it">
|
|
21
|
+
<img src="docs/voting.jpg" width="250" alt="Phone view of the ranked grid">
|
|
22
|
+
<img src="docs/detail.jpg" width="250" alt="Movie detail with votes, overview and comments">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center"><sub>Screenshots use the demo data from <code>scripts/seed_demo.py</code> with placeholder poster art.</sub></p>
|
|
26
|
+
|
|
27
|
+
## How it works
|
|
28
|
+
|
|
29
|
+
1. The admin starts a **round** with a voting deadline.
|
|
30
|
+
2. Everyone **proposes** up to three films (configurable), found through TMDB search or entered by hand.
|
|
31
|
+
3. The group **votes**: like, nope, and one superlike per person and round, either in the ranked grid or by swiping through cards.
|
|
32
|
+
4. After movie night, the admin **closes the round** and marks the film you watched. Everything else moves on to the next round with fresh votes, and films nobody picks for too long drop out on their own.
|
|
33
|
+
|
|
34
|
+
> **Note:** The interface is in German, and deadlines are entered and shown in Europe/Berlin time.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
**Voting**
|
|
39
|
+
- Ranked poster grid; a superlike counts like three likes, a nope subtracts one
|
|
40
|
+
- Swipe mode with drag and flick gestures, keyboard shortcuts, undo, "later" and a summary at the end
|
|
41
|
+
- Live countdown to the deadline; voting and proposals close automatically
|
|
42
|
+
|
|
43
|
+
**Rounds**
|
|
44
|
+
- One active round at a time, with optional deadline
|
|
45
|
+
- Unwatched films carry over and retire after a configurable number of rounds
|
|
46
|
+
- History of every film you watched, with date and who proposed it
|
|
47
|
+
|
|
48
|
+
**People**
|
|
49
|
+
- Invite-only accounts through single- or multi-use links
|
|
50
|
+
- Regulars see every round; guests only the rounds they were invited to
|
|
51
|
+
- Comments per film; everyone can change their own password
|
|
52
|
+
- Admin panel for rounds, guests, invite links and accounts (roles, password reset, deactivation)
|
|
53
|
+
|
|
54
|
+
**Under the hood**
|
|
55
|
+
- FastAPI, SQLite and plain JavaScript modules: no build step, no `node_modules`
|
|
56
|
+
- Posters, genres, overviews and German or English trailers from TMDB; works without a TMDB key
|
|
57
|
+
- Strict Content-Security-Policy, rate-limited login and invite redemption, tokens revoked on password change
|
|
58
|
+
|
|
59
|
+
## Quickstart
|
|
60
|
+
|
|
61
|
+
Requires Python 3.12+ (or Docker).
|
|
62
|
+
|
|
63
|
+
**Try the demo in one command** (temporary SQLite DB, no `.env` needed):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uvx movienight-app demo
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Open <http://localhost:8000> and log in as `demo_admin`, `alex`, `sam` or `robin` (a guest), all with the password `demo-password`.
|
|
70
|
+
|
|
71
|
+
**Install from PyPI:**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
uv tool install movienight-app # or: pip install movienight-app
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Create a `.env` file (see [`.env.example`](.env.example)), then start the server:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
movienight serve --host 127.0.0.1 --port 8000
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Run with Docker Compose:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
git clone https://github.com/nbomers/movienight.git
|
|
87
|
+
cd movienight
|
|
88
|
+
cp .env.example .env
|
|
89
|
+
# Set SECRET_KEY and FIRST_ADMIN_PASSWORD in .env (TMDB_API_KEY is optional).
|
|
90
|
+
docker compose up -d
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Local development:**
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git clone https://github.com/nbomers/movienight.git
|
|
97
|
+
cd movienight
|
|
98
|
+
python -m venv .venv && source .venv/bin/activate
|
|
99
|
+
pip install -r requirements-dev.txt
|
|
100
|
+
|
|
101
|
+
cp .env.example .env
|
|
102
|
+
movienight seed-demo # optional: demo users, films and an active round
|
|
103
|
+
movienight serve --reload
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Without demo data, the app creates the first admin from `FIRST_ADMIN_USERNAME` and `FIRST_ADMIN_PASSWORD` on first start, and refuses to start while no password is set. There is no default password.
|
|
107
|
+
|
|
108
|
+
Run the checks:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
ruff check .
|
|
112
|
+
pytest
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
All settings come from environment variables or a `.env` file.
|
|
118
|
+
|
|
119
|
+
| Variable | Default | Purpose |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `SECRET_KEY` | *(required)* | Signs login tokens. Generate with `python -c "import secrets; print(secrets.token_urlsafe(48))"` |
|
|
122
|
+
| `DATABASE_URL` | `sqlite:///./filmabend.db` | SQLite database file; `.env.example` uses `movienight.db` |
|
|
123
|
+
| `TMDB_API_KEY` | *(empty)* | Enables movie search; without it, films are entered by hand |
|
|
124
|
+
| `MAX_MOVIES_PER_USER` | `3` | Proposals per person and round (admins are not limited) |
|
|
125
|
+
| `ACCESS_TOKEN_EXPIRE_MINUTES` | `10080` | Login lifetime (7 days) |
|
|
126
|
+
| `FIRST_ADMIN_USERNAME` | `admin` | Initial admin, created on first start only |
|
|
127
|
+
| `FIRST_ADMIN_PASSWORD` | *(empty)* | At least 12 characters; required until an admin exists |
|
|
128
|
+
| `AUTH_RATE_LIMIT` | `10` | Failed logins or registrations per client IP … |
|
|
129
|
+
| `AUTH_RATE_WINDOW_SECONDS` | `300` | … within this window |
|
|
130
|
+
| `CORS_ORIGINS` | `[]` | Only needed when the frontend is served from another origin |
|
|
131
|
+
|
|
132
|
+
## Self-hosting
|
|
133
|
+
|
|
134
|
+
The app is a single process that serves the API and the frontend from the same origin. A typical setup:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Browser ──HTTPS──▶ Caddy ──▶ uvicorn / FastAPI ──▶ SQLite
|
|
138
|
+
│
|
|
139
|
+
└──▶ TMDB API (search, details, trailers)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Deployment files:
|
|
143
|
+
|
|
144
|
+
- [`docker-compose.yml`](docker-compose.yml) + [`Dockerfile`](Dockerfile): non-root container with read-only root filesystem, `/health` check and a persistent `/data` volume for SQLite
|
|
145
|
+
- [`deploy/movienight.service`](deploy/movienight.service): systemd unit that binds `movienight serve` to localhost and enables `--proxy-headers`, so the rate limit sees real client IPs
|
|
146
|
+
- [`deploy/Caddyfile.example`](deploy/Caddyfile.example): reverse proxy with automatic HTTPS, plus a variant for use behind Cloudflare Tunnel
|
|
147
|
+
|
|
148
|
+
Run a single uvicorn worker: the login rate limit is kept in memory.
|
|
149
|
+
|
|
150
|
+
**Backups.** SQLite runs in WAL mode, so a plain file copy of a running database can miss recent writes. Use SQLite's backup command instead:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
sqlite3 movienight.db ".backup movienight-$(date +%F).db"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Updating.** Pull, install the requirements and restart the service. Schema changes are applied automatically at startup. Check the [changelog](CHANGELOG.md) for anything that needs attention, such as everyone having to log in again after 1.0.0.
|
|
157
|
+
|
|
158
|
+
## Design decisions
|
|
159
|
+
|
|
160
|
+
**SQLite instead of Postgres.** A friend group produces a few hundred rows a year, with one writer most of the time. SQLite means no extra service, a single file to back up, and a test suite that runs against the same engine as production. WAL mode and a busy timeout let a group vote at the same moment. If this ever needed several app servers, the database would be the first thing to change.
|
|
161
|
+
|
|
162
|
+
**No frontend framework.** The UI is a handful of views over a small JSON API. Plain ES modules load directly in the browser, so there is no build step and deploying is copying files. The cost is manual DOM updates and manual escaping: every value from the API goes through one `esc()` helper before it reaches `innerHTML`, and the backend only accepts poster paths and trailer links in the exact shape TMDB produces.
|
|
163
|
+
|
|
164
|
+
**Round logic.** Exactly one round is active at a time. When the admin closes a round, they mark the film that was watched and it leaves the pool. When the next round starts, all other films from the last round move over, their votes are cleared, and their `rounds_survived` counter goes up. Once it reaches the configured limit (default 4), the film retires. The list stays fresh without anyone cleaning it up by hand.
|
|
165
|
+
|
|
166
|
+
**Superlikes are derived, not stored.** Whether someone has used their superlike is a query over the current round's votes. An earlier version kept a separate list that could drift from the votes, for example when a superliked film was removed.
|
|
167
|
+
|
|
168
|
+
**Optimistic voting.** A vote updates the UI immediately and is rolled back if the server rejects it. The grid, the detail view and the swipe deck share one store, so they never disagree.
|
|
169
|
+
|
|
170
|
+
**Time zones.** Deadlines are entered as Berlin time, converted to UTC for storage and sent to the browser with an explicit offset. SQLite does not store offsets, so the API attaches UTC when reading.
|
|
171
|
+
|
|
172
|
+
## Security
|
|
173
|
+
|
|
174
|
+
- **Accounts** exist only through invite links (`secrets.token_urlsafe(32)`). The token travels in the URL fragment, so it never reaches server or proxy logs.
|
|
175
|
+
- **Sessions** are signed JWTs bound to the user id and a per-user token version. Changing or resetting a password logs out every other session; deactivating a user takes effect on their next request.
|
|
176
|
+
- **Login** answers unknown users and wrong passwords with the same error in the same time. Usernames are unique ignoring case. Failed logins and invite redemptions are rate-limited per IP.
|
|
177
|
+
- **Access** is checked on every round-scoped endpoint: guests only see the round they were invited to, including its comments and the TMDB search.
|
|
178
|
+
- **Frontend:** no inline scripts or event handlers, and a strict Content-Security-Policy (`script-src 'self'`), so injected markup cannot run code even if an escaping mistake slipped through. A test keeps it that way.
|
|
179
|
+
|
|
180
|
+
Found a vulnerability? Please report it privately as described in [SECURITY.md](SECURITY.md) rather than opening a public issue.
|
|
181
|
+
|
|
182
|
+
## Contributing
|
|
183
|
+
|
|
184
|
+
Issues and pull requests are welcome. Please run `ruff check .` and `pytest` before opening a pull request; CI runs both.
|
|
185
|
+
|
|
186
|
+
## TMDB attribution
|
|
187
|
+
|
|
188
|
+
This product uses the TMDB API but is not endorsed or certified by TMDB.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
[MIT](LICENSE). The bundled Inter font is licensed under the [SIL Open Font License](src/movienight/frontend/fonts/OFL.txt).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please do not open a public issue for security problems. Report them
|
|
6
|
+
privately through GitHub instead:
|
|
7
|
+
**Security → Report a vulnerability** on this repository
|
|
8
|
+
([direct link](https://github.com/nbomers/movienight/security/advisories/new)).
|
|
9
|
+
|
|
10
|
+
Include what you found, how to reproduce it and which version or commit you
|
|
11
|
+
tested. You will get an answer within a week. Once a fix is released, the
|
|
12
|
+
advisory is published with credit to you, unless you prefer otherwise.
|
|
13
|
+
|
|
14
|
+
## Supported versions
|
|
15
|
+
|
|
16
|
+
Only the latest release receives security fixes.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Example Caddyfile. Replace the domain with your own.
|
|
2
|
+
# Caddy obtains a TLS certificate automatically when the domain points here.
|
|
3
|
+
movies.example.com {
|
|
4
|
+
encode zstd gzip
|
|
5
|
+
reverse_proxy 127.0.0.1:8000
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
# Behind Cloudflare Tunnel, TLS ends at Cloudflare and the tunnel connects to
|
|
9
|
+
# Caddy over plain HTTP. Use a site address like this instead:
|
|
10
|
+
# :8080 {
|
|
11
|
+
# reverse_proxy 127.0.0.1:8000
|
|
12
|
+
# }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Example systemd unit. Adjust User, WorkingDirectory and paths.
|
|
2
|
+
# Install: sudo cp deploy/movienight.service /etc/systemd/system/
|
|
3
|
+
# sudo systemctl daemon-reload && sudo systemctl enable --now movienight
|
|
4
|
+
[Unit]
|
|
5
|
+
Description=movienight (FastAPI)
|
|
6
|
+
After=network.target
|
|
7
|
+
|
|
8
|
+
[Service]
|
|
9
|
+
Type=simple
|
|
10
|
+
User=movienight
|
|
11
|
+
Group=movienight
|
|
12
|
+
WorkingDirectory=/opt/movienight
|
|
13
|
+
EnvironmentFile=/opt/movienight/.env
|
|
14
|
+
# --proxy-headers makes the real client IP visible behind Caddy, which the
|
|
15
|
+
# login rate limit relies on. Bind to localhost only; Caddy is the entry point.
|
|
16
|
+
ExecStart=/opt/movienight/.venv/bin/movienight serve --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips 127.0.0.1
|
|
17
|
+
Restart=on-failure
|
|
18
|
+
RestartSec=5
|
|
19
|
+
|
|
20
|
+
# Hardening
|
|
21
|
+
NoNewPrivileges=true
|
|
22
|
+
PrivateTmp=true
|
|
23
|
+
ProtectSystem=strict
|
|
24
|
+
ProtectHome=true
|
|
25
|
+
ReadWritePaths=/opt/movienight
|
|
26
|
+
|
|
27
|
+
[Install]
|
|
28
|
+
WantedBy=multi-user.target
|