- Python 44.5%
- JavaScript 21.5%
- CSS 16.7%
- HTML 14.6%
- Shell 2.3%
- Other 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| auth | ||
| blog | ||
| deploy | ||
| migrations | ||
| pages | ||
| scripts | ||
| static | ||
| stats | ||
| templates/admin | ||
| tests | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .python-version | ||
| admin.py | ||
| AGENTS.md | ||
| app.py | ||
| config.py | ||
| docker-compose.yml | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| extensions.py | ||
| i18n.py | ||
| LICENSE | ||
| markdown_render.py | ||
| pyproject.toml | ||
| README.md | ||
| TASKS.md | ||
| uv.lock | ||
| wsgi.py | ||
pvlb.dev — web-frontend
Personal portfolio and blog for pvlb.dev, built on a Flask + SQLAlchemy fork of Flango. The public site is a small, fast, server-rendered landing page; the blog is written in Markdown and edited through a private Flask-Admin CMS.
- English is canonical at
/, German lives under/de/. - Dark, terminal-flavoured design with self-hosted JetBrains Mono and an orange accent.
- Markdown source is stored in SQLite; HTML is rendered server-side with
markdown-it-pyand highlighted with Pygments. - Admin-only post editor with EasyMDE, drafts, scheduling, image uploads and
bilingual
translation_keypairing. - Docker image, Compose file and Forgejo Actions for tests and image publishing.
Architecture and conventions live in the AGENTS.md map. The long-form
topic files live in the private agentic/web-frontend repo, cloned as
AGENTS.d/; a public checkout deliberately has no AGENTS.d/. Open work and
deferred ideas live in TASKS.md. The house baseline for agents on this
box is the DSH bootcamp.
Quick start
Requires uv and Python 3.14 on the host (the
container currently uses the supported 3.13 base; pyproject.toml allows
>=3.13). uv creates and owns .venv; do not install project packages globally.
uv sync
cp .env.example .env
uv run flask --app app db upgrade
uv run flask --app app create-admin --username admin # prompts for a password
uv run flask --app app set-password --username admin # rotate the password
uv run flask --app app run --debug
Open:
| URL | What it is |
|---|---|
/ |
English landing page |
/de/ |
German landing page |
/projects/ |
English project index |
/de/projekte/ |
German project index |
/contact/ |
English contact page |
/de/kontakt/ |
German contact page |
/contact/phone/ |
English rotary phone game |
/de/kontakt/telefon/ |
German rotary phone game |
/blog/ |
English blog index |
/de/blog/ |
German blog index |
/blog/<slug> |
English post |
/de/blog/<slug> |
German post |
/admin |
Flask-Admin CMS (admin users only) |
/admin/stats/ |
First-party visit statistics (admin users only) |
/auth/login |
Session login for the CMS |
/healthz |
JSON health check |
/sitemap.xml |
Sitemap |
/robots.txt |
Crawler rules |
The phone game is a playful client-side gate, not privacy. Valid steps are
stored as salted SHA-256 hashes and the full number is assembled only from the
entered digits, so it is not plaintext in the JS. The QR is generated client-side
from the vCard after a successful solve, but the 10^7 space is brute-forceable.
It is noindexed, but a determined visitor can recover the number. Use a
dedicated/alias number if that matters. The dial tones are local, shuffle-bagged OGG loops in
static/audio/phone/ with a mute toggle on the page.
Visit statistics
The admin console has a read-only /admin/stats/ page: views, unique visitors
per UTC day, a 14-day series, top pages, referrers and a separate crawler
bucket. It is first-party and cookie-free:
ip_hashisHMAC(SECRET_KEY, "<utc-date>:<ip>"), so the raw IP is never stored and the same visitor has a different id tomorrow;/static,/api,/auth,/admin,/healthz,robots.txt/sitemap.xmland non-200 responses are not counted; POSTs are not counted;- only
browser/crawler/otheris stored, never the full user agent; STATS_ENABLED=0stops recording; existing rows remain visible;uv run flask --app app stats pruneremoves rows older thanSTATS_RETENTION_DAYS(default 90). Run it on a timer in production.
The visits table lives in the normal app database. This is site-owned
analytics, not a third-party tracker, but it is still stored data — contact
page copy must not claim otherwise.
Writing a post
- Log in at
/auth/loginand open/admin. - Create a post under Posts:
langselects English or German.slugcan be left empty; it is generated from the title (German umlauts are transliterated).translation_keycan be left empty; it defaults to the slug. Reuse the same key on the other language version to link the two.- Write the body in Markdown. Raw HTML is intentionally escaped.
published_atis a UTC date only; leave it empty when publishing to use “now”.
- Insert images with the editor's img toolbar button (upload) or url
(remote image). Uploads are stored under
instance/uploads/, served at/media/..., and only admins can upload. - Set
statustopublished. Drafts and future-dated posts return 404 in public views. - To preview drafts from the public site, use show drafts in the header
while logged in as an admin. A direct draft URL also works with
?preview=1.
Markdown supports CommonMark plus tables, strikethrough, footnotes, task lists, autolinked URLs and fenced code blocks with Pygments highlighting.
Bilingual content
- English routes are unprefixed; German routes use the
/deprefix. There is noAccept-Languageredirect and no/en/duplicate. - UI strings and landing copy live in
i18n.pyandpages/content.py. - Blog posts are one row per language.
translation_keypairs a post with its counterpart; the detail page links to it, or shows a note if it is missing. - Auth/admin UI is English-only by design.
Configuration
Configuration is read from environment variables and .env via python-dotenv.
| Variable | Default | Purpose |
|---|---|---|
SECRET_KEY |
dev fallback | Set a real secret in production. |
DATABASE_URL |
sqlite:///main.db |
Relative SQLite paths resolve to instance/. |
FLASK_DEBUG |
off | Flask debug mode. |
LOG_LEVEL |
INFO |
stdout and instance/app.log. |
SITE_URL |
http://localhost:5000 |
Canonical base for SEO, sitemap, Open Graph. |
SITE_NAME |
pvlb.dev |
Site name in branding and metadata. |
SITE_OWNER |
Pavel Burda |
Name shown on the landing page and footer. |
FORGEJO_URL |
explore repos URL | Projects CTA. |
SOURCE_URL |
repo URL | Footer source link. |
CONTACT_EMAIL |
empty | Optional mailto link; .env.example suggests mail@pvlb.dev. |
ONION_URL |
built-in pvlb.dev onion | Optional Tor onion-service link used in the footer. |
GITHUB_URL |
empty | Optional GitHub link on the contact page. |
MATRIX_DM_HANDLE |
@pvl:pvlb.dev |
Matrix DM handle. |
MATRIX_DM_URL |
matrix.to link | Matrix DM link. |
MATRIX_CHAT_URL |
https://chat.pvlb.dev |
Cinny web client. |
MATRIX_ROOM_URL |
#hi:pvlb.dev matrix.to |
Main chat room. |
MATRIX_SPACE_URL |
#public:pvlb.dev matrix.to |
Public Matrix space. |
MATRIX_ACCOUNT_URL |
https://matrix.org |
“get an account” link. |
MATRIX_LEARN_URL |
https://joinmatrix.org |
“learn about Matrix” link. |
TRUST_PROXY |
off | Trust one X-Forwarded-* hop behind a reverse proxy. |
SESSION_COOKIE_SECURE |
derived from SITE_URL |
Force secure session cookies. |
STATS_ENABLED |
on | First-party visit statistics; 0 stops recording. |
STATS_RETENTION_DAYS |
90 |
Age at which flask stats prune deletes visits. |
Runtime files (SQLite database, logs) live in instance/ and are git-ignored.
Development
uv run pytest -q # full test suite
uv run ruff check . # lint
uv run flask --app app routes # URL map
uv run flask --app app shell # app context
The suite uses in-memory SQLite and covers the landing pages, bilingual routes, Markdown rendering and safety, blog visibility, admin CMS flows and CSRF.
Design notes:
- Public CSS is in
static/css/style.css; tokens are at the top (--bg,--accent,--line,--radius). - JetBrains Mono is self-hosted under
static/fonts/(OFL license included). - Pygments CSS is generated by
uv run python scripts/generate_pygments_css.py. - EasyMDE is vendored under
static/vendor/easymde/and loaded only on the admin post create/edit pages.
Database and migrations
uv run flask --app app db upgrade
uv run flask --app app db migrate -m "describe the change"
Migrations are committed. The current history creates the original Flango tables,
then adds posts and drops tasks. For PostgreSQL later, set DATABASE_URL
and install the driver; the models use SQLAlchemy 2.0 typed mappings.
Docker and Forgejo CI/CD
Local container test:
cp .env.example .env
docker compose up --build
# http://127.0.0.1:8000
The container runs flask db upgrade and then Gunicorn. SQLite data and logs are
persisted in the instance named volume. The Compose file binds the app to
127.0.0.1:8000 by default; put Caddy/Traefik/nginx in front for TLS.
Temporary tailnet dev server
Rootless Docker runs as the deeps user; the default socket is
$XDG_RUNTIME_DIR/docker.sock. Put this in the local (gitignored) .env:
BIND_ADDR=100.x.y.z # `tailscale ip -4`
WEB_PORT=8000
SITE_URL=http://srvbtw.tortoise-triggerfish.ts.net:8000
TRUST_PROXY=0
SESSION_COOKIE_SECURE=0
Then:
systemctl --user start docker.service
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR}/docker.sock"
docker compose up -d --build
docker compose ps
docker compose logs -f web # follow
docker compose exec web flask --app app create-admin --username admin
# or rotate an existing admin:
docker compose exec web flask --app app set-password --username pvl
The container then listens on <tailscale-ip>:8000, reachable at
http://srvbtw.tortoise-triggerfish.ts.net:8000. Stop it with
docker compose down (the named instance volume persists). This is a
temporary dev binding; production keeps BIND_ADDR=127.0.0.1.
Before exposing the container, set at least:
FLASK_DEBUG=0
SECRET_KEY=<long random value>
SITE_URL=https://pvlb.dev
TRUST_PROXY=1
SESSION_COOKIE_SECURE=1
Forgejo workflows:
.forgejo/workflows/ci.yml— lint + tests on pushes tomasterand manual dispatch. There is deliberately nopull_requesttrigger..forgejo/workflows/publish.yml— builds the image on manual dispatch (dry run) and pushesgit.pvlb.dev/web/web-frontend:{version,latest}only forv*tags. The tag must match thepyproject.tomlversion..forgejo/workflows/deploy.yml— manual, version-pinned production deploy. It never deployslatest; the image tag must already be published.
Required repository secrets for publishing/deploy:
| Secret | Purpose |
|---|---|
AUDIENCE |
Repository variable holding the Authorized Integration audience (u:<id>:<uuid>), used by the OIDC image publish. |
DEPLOY_SSH_KEY |
Private key for the forced-command deploy key. |
DEPLOY_HOST |
Deploy host (srv). |
DEPLOY_USER |
SSH user (dsh). |
DEPLOY_KNOWN_HOSTS |
Pinned host key for deploy.yml. |
DEPLOY_PORT |
Optional SSH port; defaults to 2222. |
The production reference lives in deploy/ (compose.yaml, deploy.sh,
receive.sh, .env.example, and the host runbook). deploy.sh pulls one
X.Y.Z image, waits for /healthz, and rolls back to the previous tag on
failure. Never deploy latest.
The runner label is docker; adjust it if your Forgejo runner uses a different
label. Docker-in-Docker/socket access is required for the publish job. If your
instance cannot resolve actions/checkout@v4, replace it with a git clone step
using the job token.
Project structure
app.py application factory
wsgi.py Gunicorn entry point
config.py environment-driven configuration
extensions.py db, migrate, csrf, login_manager
admin.py Flask-Admin instance, dashboard, admin access gate
i18n.py EN/DE URL helpers and UI translations
markdown_render.py Markdown → HTML, excerpts, reading time
pages/ landing pages, sitemap/robots/health, public base template
blog/ Post model, services, public views, admin editor
auth/ session login and create-admin CLI
stats/ first-party visit statistics model/recorder/services/CLI
templates/admin/ Flask-Admin dashboard, stats and blog editor overrides
deploy/ production compose, deploy/rollback scripts, host runbook
static/ CSS, fonts, vendored EasyMDE, JS, favicon
AGENTS.d/ private knowledge clone (gitignored; absent after a clone)
input/ (optional) local operator drop box -> AGENTS.d/input/
GIT.md local identity doc (gitignored)
migrations/ Alembic history
tests/ pytest suite
Backporting
This repo is intentionally a real site, not a boilerplate. General-purpose
pieces (i18n.py, markdown_render.py, the Docker/Forgejo setup, app-factory
hardening) are written without pvlb.dev-specific assumptions so they can be
proposed back to Flango. Site copy and the design live in clearly separated
files.
License
Apache-2.0. See LICENSE.