eeaad62b10
- internal/postgres: pgx-over-database/sql pool (otelsql), embedded goose
migrations into schema 'backend', committed go-jet code + cmd/jetgen tool.
- internal/account: durable accounts + unified telegram/email identities
(UUIDv7 keys), find-or-create provisioning with unique-conflict handling.
- internal/session: opaque 256-bit tokens stored as a SHA-256 hash, revoke-only
(no TTL); write-through cache gating /readyz; store + service.
- internal/telemetry: OTel tracer/meter providers (none/stdout) + request-timing
middleware; internal/config gains Postgres + OTel env loading.
- internal/server: /api/v1 {public,user,internal,admin} skeleton + X-User-ID
middleware; /readyz checks DB ping + cache; main wires
telemetry -> db+migrate -> warm cache -> server.
- Tests: unit + integration (build tag 'integration', testcontainers
postgres:17) for migrations, accounts, sessions, readyz; new integration.yaml.
- Docs: ARCHITECTURE, TESTING, PLAN refinements, root + backend READMEs.
Session/account REST handlers deferred to Stage 6 (gateway); OTLP + dashboards
to Stage 11.
57 lines
2.5 KiB
Markdown
57 lines
2.5 KiB
Markdown
# scrabble-game
|
|
|
|
Multiplatform Scrabble game. Players arrive from a platform (Telegram first;
|
|
later VK/MAX/iOS/Android) or from standalone web (email / guest). The game
|
|
supports English Scrabble, Russian Scrabble and Эрудит.
|
|
|
|
## Components
|
|
|
|
- **`gateway`** — the only public ingress: anti-abuse, platform authentication
|
|
(resolves the player and injects `X-User-ID`), routing to `backend`, and an
|
|
admin surface behind Basic Auth. *(added in a later stage)*
|
|
- **`backend`** — internal-only service that owns every domain concern and
|
|
embeds the [`scrabble-solver`](../scrabble-solver) engine library in-process.
|
|
- **`ui`** — pure-HTML5 client (plain Svelte + Vite), embeddable in platform
|
|
webviews and packageable to native via Capacitor. *(added in a later stage)*
|
|
- **`platform/*`** — per-platform side-services (e.g. the Telegram bot).
|
|
*(added in a later stage)*
|
|
|
|
## Documentation (sources of truth)
|
|
|
|
- [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) — global architecture, transport,
|
|
security, cross-service contracts.
|
|
- [`docs/FUNCTIONAL.md`](docs/FUNCTIONAL.md) (+ [`_ru`](docs/FUNCTIONAL_ru.md)) —
|
|
per-domain user stories.
|
|
- [`docs/TESTING.md`](docs/TESTING.md) — test layers and the per-stage CI gate.
|
|
- [`PLAN.md`](PLAN.md) — the staged implementation plan and stage tracker.
|
|
- [`CLAUDE.md`](CLAUDE.md) — project guide and the mandatory per-stage workflow.
|
|
|
|
## Build & test
|
|
|
|
```sh
|
|
go build ./backend/... # per module (the workspace spans several modules)
|
|
go vet ./backend/...
|
|
gofmt -l . # must print nothing
|
|
go test -count=1 ./backend/... # unit tests
|
|
go test -tags=integration -count=1 -p=1 ./backend/... # + Postgres (needs Docker)
|
|
```
|
|
|
|
The `integration`-tagged tests start a throwaway `postgres:17-alpine` container
|
|
via testcontainers-go and require a reachable Docker daemon.
|
|
|
|
## Run the backend locally
|
|
|
|
The backend now owns persistence, so it needs Postgres and applies its embedded
|
|
migrations at startup:
|
|
|
|
```sh
|
|
docker run -d --name scrabble-pg -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres:17-alpine
|
|
BACKEND_POSTGRES_DSN='postgres://postgres:dev@localhost:5432/postgres?search_path=backend&sslmode=disable' \
|
|
go run ./backend/cmd/backend # serves /healthz and /readyz on :8080
|
|
```
|
|
|
|
Key environment: `BACKEND_HTTP_ADDR` (default `:8080`), `BACKEND_LOG_LEVEL`
|
|
(`debug|info|warn|error`, default `info`), `BACKEND_POSTGRES_DSN` (**required**).
|
|
The full configuration surface and the go-jet regeneration step live in
|
|
[`backend/README.md`](backend/README.md).
|