Skip to content

f/rebuild: 公開ページをフロントへ移譲・統計公開・k3s 向け設定外部化#168

Merged
Uno-Takashi merged 15 commits into
mainfrom
f/rebuild
Jun 21, 2026
Merged

f/rebuild: 公開ページをフロントへ移譲・統計公開・k3s 向け設定外部化#168
Uno-Takashi merged 15 commits into
mainfrom
f/rebuild

Conversation

@Uno-Takashi

Copy link
Copy Markdown
Member

React フロントエンド移行のバックエンド側(f/rebuild 作業を含む)。

変更

  • 移行済みページ(LP / 使い方 / ロビー)の Django テンプレート・ビューを削除。web/urls.py/admin/chart(管理者向け統計)のみ。
  • AnimeStoreLobbyResolveAPIGET /api/v1/anime-store/lobby/<uuid>)を追加。フロントのロビーが room_id → dアニメストア リダイレクト URL を解決。
  • 統計系 8 エンドポイントを公開(AllowAny)。公開 /stats ページ用。
  • nginx: 公開ページ→フロント、/api/admin/metrics・WebSocket(/anime-store/party/)→ Django に振り分け。/api はローカル用 CORS 付き。
  • docker-compose: frontend サービス追加。
  • サービス解決先を env 化(.env.global: DJANGO_UPSTREAM/FRONTEND_UPSTREAM/GRAFANA_UPSTREAM)— k3s 移行を見据えた設定外部化。
  • 進行中の rebuild 変更(settings・依存・docs)を含む。

検証: ruff check / format パス。Django ランタイム check は環境都合で未実行(uv run python manage.py check 推奨)。

🤖 Generated with Claude Code

Uno-Takashi and others added 4 commits June 20, 2026 12:21
Aggressive dependency/tooling modernization while preserving the WebSocket
protocol, model semantics and REST API contract (the public interfaces).

Tooling & runtime:
- Poetry -> uv (PEP 621 pyproject + uv.lock); Dockerfile rebuilt on
  python:3.13-slim + uv (venv at /opt/venv to survive the compose bind-mount)
- Python 3.11 -> 3.13, Django 4.1 -> 5.2 LTS, Channels/DRF/jazzmin/axes bumped
- black -> ruff (format + lint), config in pyproject
- gunicorn worker -> maintained uvicorn-worker package

Database MySQL -> PostgreSQL:
- mysqlclient -> psycopg; docker-compose mysql/phpMyAdmin -> postgres/adminer
- settings + env vars (POSTGRES_*), postgres healthcheck + depends_on condition
- MySQL-specific `.extra(select="date(...)")` -> ORM TruncDate (DB-agnostic)

Replaced unmaintained packages (behaviour preserved):
- django-boost LogicalDeletionMixin -> streamer/mixins.py
- django-cryptography encrypt() -> streamer/fields.py (Fernet EncryptedCharField)
- django-dynamic-shields -> plain shields.io endpoints in api/views.py
- django-crontab -> `manage.py cleanup` driven by system cron (entrypoint.sh)
- distutils StrictVersion -> strict x.y.z parser (removed in Py3.12)
- pydantic v1 -> v2 (SerializeAsAny keeps subclass fields on the wire)
- dropped django-request / django-debreach / pandas-era cruft and dead imports

Tests verified green (13/13) against Postgres+Redis; conftest swaps in
InMemoryChannelLayer for deterministic, Redis-free unit tests. CI workflows
updated to docker compose v2 / uv / ruff / codeql v3. Added backend AGENTS.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Chrome extension sends `option.paused` as a bool and `rate` as a number;
pydantic v1 stringified these (False -> "False") and the client depends on that
exact form (`option["paused"] === "False"`). Add a before-validator so the v2
models reproduce the v1 wire behaviour. Existing string inputs are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dアニメストア migrated anime.dmkt-sp.jp -> animestore.docomo.ne.jp. The lobby
"join party" redirect was hardcoded to the old domain; drive it from the
already-configured D_ANIME_STORE_DOMAIN env var instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…config

Backend side of the React frontend migration, on top of the f/rebuild work.

- Remove the migrated Django pages (LP / usage / lobby templates + views);
  keep the admin statistics chart. web/urls.py now only serves /admin/chart.
- Add AnimeStoreLobbyResolveAPI (GET /api/v1/anime-store/lobby/<uuid>) so the
  React lobby can resolve room_id -> dアニメストア redirect URL.
- Make the 8 statistics endpoints public (AllowAny) for the public /stats page.
- nginx: route public pages to the frontend upstream and /api·/admin·/metrics·
  WebSocket (/anime-store/party/) to Django; CORS on /api for local dev.
- docker-compose: add the frontend service (build ../frontend).
- Externalize service endpoints to env (.env.global: DJANGO_UPSTREAM /
  FRONTEND_UPSTREAM / GRAFANA_UPSTREAM) for the planned k3s migration.
- Includes in-progress rebuild changes (settings, dependencies, docs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

actionlint

🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/setup-python@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L13


🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L19


🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/upload-artifact@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L25


🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/setup-python@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L36


🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L42


🚫 [actionlint] reported by reviewdog 🐶
the runner of "actions/upload-artifact@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue [action]

https://github.com/d-party/d-party-Backend/blob/e8ecde3978f5f6c1138a1a931028d012fef9ac74/.github/workflows/security.yml#L48

Uno-Takashi and others added 9 commits June 21, 2026 02:35
The monorepo modernization introduced several CI regressions because the
backend repo is checked out standalone (the `frontend` submodule is absent)
and because tooling/action versions had bit-rotted.

- pytest / license-check: `docker compose up -d` built every service,
  including the new `frontend` (`context: ../frontend`, missing in a
  backend-only checkout). Start only `django`; postgres/redis come up as
  deps. Same fix for the trivy build in security.yml (`build django`).
- dockle / trivy: pin `image: backend-django` on the django service so the
  built image name no longer depends on the checkout-directory/project name.
- dockerlint: a comment sat inside the multi-line `ENV` continuation
  ("Empty / bogus instruction on line 13"); moved it above the `ENV`.
- hadolint DL3022: `COPY --from=ghcr.io/astral-sh/uv` referenced an external
  image; introduce a named `FROM ghcr.io/astral-sh/uv:0.9 AS uv` stage.
- textlint: `setup-node@v1` + node 15 lacked `node:stream/consumers`
  (needs Node >=16.7); bump to setup-node@v4 / node 20.
- actionlint: bump deprecated runners (checkout@v2/v3 -> v4,
  setup-node@v1 -> v4, setup-python@v3 -> v5, upload-artifact@v2 -> v4) and
  fix shellcheck quoting (SC2016/SC2086) in autoblack.yml.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two checks surfaced real (non-build) failures once the compose build was
fixed:

- license-check: psycopg 3.3.4 reports its license as the SPDX identifier
  `LGPL-3.0-only`; the allow-list only had the classifier spelling
  (`...LGPLv3+`). LGPL is already permitted, so add the SPDX form.
- textlint: now that Node is modern enough to run, textlint had no rules
  ("No rules found" -> reviewdog parse error). Add `.textlintrc.json`
  enabling the write-good rule the workflow installs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- pytest: web/tests.py still exercised the landing/usage/lobby pages that
  this PR moved to the React frontend (Django now returns 404 for them).
  Remove those obsolete view tests; lobby resolution is covered by api/tests.
- license-check: newer dependencies report SPDX license expressions
  (e.g. pytest-asyncio -> Apache-2.0) that the classifier-based allow-list
  missed. Add the SPDX spellings of the already-permitted licenses.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- pytest: the test step passes; only the Codecov upload failed because a
  token is required on protected branches. Set fail_ci_if_error: false so a
  missing-token upload does not fail CI (tests still gate the job).
- license-check: numpy reports a compound SPDX expression
  (BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0); allow that exact
  expression plus its Zlib/CC0-1.0 components.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Exact allow-only matching fails on compound SPDX expressions (e.g.
cryptography 'Apache-2.0 OR BSD-3-Clause', numpy 'BSD-3-Clause AND 0BSD
AND MIT AND Zlib AND CC0-1.0') even when every component is permissive.
--partial-match matches an allowed license as a substring, so the
permissive allow-list covers these without enumerating each expression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…aves

Avoid destroying a room the instant the host's WS blips or a tab reloads
(which made guests hit failed_join). Schedule a logical delete after a
grace period and cancel it if anyone rejoins. Also guard actions when the
join was rejected, and exclude logically-deleted rooms from join.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…r CI

The backend repository is now the django server only. The monorepo root
owns docker-compose and the infra (nginx/postgres/redis/prometheus/grafana).

- Flatten: move Django/* to the repository root (repo root = django project).
- Remove infra now owned by the d-party monorepo root: nginx/, Postgres/,
  Redis/, prometheus/, grafana/, docker-compose.yml, .env.global.
- CI no longer depends on docker compose:
  - pytest: postgres + redis as GitHub Actions service containers; uv sync;
    migrate; pytest (env provided via the job, not mounted .env files).
  - license-check: uv run pip-licenses --partial-match.
  - dockerlint/hadolint/dockle/trivy: target ./Dockerfile and
    `docker build` (no compose); lizard/mypy/bandit/pyt/ruff paths -> repo root.
- Add .dockerignore so the now repo-root build context excludes dev/CI files
  and local env from the image.
- Fix stale test: failed_join uses the migrated `message_type` field (the new
  chrome-extension protocol), not the old `message`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread web/urls.py
@@ -0,0 +1,10 @@
from django.urls import path

from . import views

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
No parent module -- cannot perform relative import

Uno-Takashi and others added 2 commits June 21, 2026 05:49
monorepo ルートの env 3分割(.env.global/.env.dev/.env.prod)と
dev=pnpm dev(HMR)/prod=ビルド配信・Let's Encrypt の構成変更に追従。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Uno-Takashi Uno-Takashi merged commit 41ba974 into main Jun 21, 2026
13 of 14 checks passed
@Uno-Takashi Uno-Takashi deleted the f/rebuild branch June 21, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant