A standalone container for web_server, shaped like job-tracker: serves /usaco/ with solved problems public and solving/skipped plus edits (status, link, notes) for the site admin. Git is the only store: the server clones adamf/usaco from Gitea, pulls on the push webhook, and commits edits back. CI builds the image only when site/ changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 lines
1.8 KiB
Markdown
27 lines
1.8 KiB
Markdown
# CLAUDE.md
|
|
|
|
Guidance for Claude Code in `site/`. README.md has the full picture (routes, git sync, deployment).
|
|
|
|
## Commands
|
|
|
|
```
|
|
make check # go vet ./... && go test ./..., then a vite build of web/ into a temp dir
|
|
make dev # docker compose up --build: this checkout's problems, AUTH_MODE=dev, GIT_PUSH=false
|
|
cd web && npm run dev # SPA hot reload; proxies /usaco/api to localhost:8080
|
|
```
|
|
|
|
## Architecture
|
|
|
|
One Go binary (`cmd/usacosite`) that serves a REST API and the built Vue SPA, all under `/usaco`. It is deployed as one container inside the `web_server` stack, behind its nginx. It has the same shape as `../job-tracker`, from which `internal/auth` and `handlers.SPA` were copied.
|
|
|
|
- **Git is the only store.** `internal/repo` owns the clone and serializes every git command. A sync is fetch + hard reset (the remote wins). `Mutate` does sync, edit, commit and push, and replays the edit once if the push is rejected. Its `onChange` callback (`Server.Reload`) rebuilds the index under the same lock.
|
|
- **The index is an immutable snapshot**, swapped in through an `atomic.Pointer`. Handlers read `s.Index()` once per request.
|
|
- **Visibility is decided server-side.** Non-admins see only `solved/`, and an unsolved problem is a 404, not a 403. `auth.Forward` returns false for a request with no cookies without a network call.
|
|
|
|
## Conventions
|
|
|
|
- **Comments explain why, not what.** Preserve them, and update them when behaviour changes.
|
|
- **Edits look at the disk.** An edit func passed to `Mutate` may run twice, so it must locate the problem with `findOnDisk`, never from the index.
|
|
- **Commit subjects match the CLI's** (`lib/cmd/done.sh`): "Solve <name>" and so on.
|
|
- **The problem layout belongs to the CLI** in the repo root (`lib/`). When the CLI's layout changes, update `internal/index`.
|