# gta6mods.sh: proposed architecture Status: proposal, 2026-12-03. The front end follows design direction 1, "Library" (`design/project/d1-library-*.dc.html`): a gta5-mods-style site, filtered to the player's game build, that says plainly what each mod needs and which game files it replaces. ## Goals - **Simple.** One Go binary, one Postgres database, one object store. No SPA, no microservices, no queue server, no search server until Postgres is not enough. - **Secure.** No passwords stored. Nothing an author uploads is downloadable until it has been unpacked, checked and scanned. User files are served from a different domain from the site. No third-party scripts. - **Extendable.** Platforms, game builds, mod kinds and categories are rows, not code. The PC release and the consoles arrive as new rows (plus an inspector if their file formats differ). ## What the site has to understand Today's modding runs on the Xbox Series build 1.0.2.1 under VIctory-NVIDIA. The PC release will be a new target, not a new site. | Mod kind | What is in the upload | What it needs on the player's PC | |---|---|---| | script | `.asi` plugins built with the ViceHook SDK | ViceHook in `%LOCALAPPDATA%\victory\mods` | | archive | loose files laid out by archive path (`common.rpf/data/handling.meta`) | vicerpf modloader; `vicerpf mod pack` rebuilds archive copies locally | | tool | a standalone program | nothing from us | **Mods never contain game files.** An upload that holds an `.rpf` is rejected. Archive mods are loose files only, and the archives are rebuilt on the player's PC from their own copy of the game. That keeps game data off the site. Because archive mods are laid out by archive path, the site knows exactly which game files each one replaces without decrypting anything. That path list drives the "Game files it replaces" box, the conflict list and search by file name. ## Shape ``` players, authors mod managers / installer (later) \ / Cloudflare: DNS, TLS, WAF, rate limits, Turnstile, page cache | | gta6mods.sh files domain (separate, cookieless) modd web (Go) | | \ R2 public bucket <-- worker copies clean files Postgres presigned PUT by SHA-256 | \ modd worker <-- R2 quarantine bucket (private) | inspectors + clamd (sandboxed) ``` ### modd: one binary, two modes - `modd web`: HTTP server. Server-rendered HTML with `html/template` (escapes by default), a little progressive-enhancement JS, and a JSON API under `/api/v1` that calls the same service functions as the pages. - `modd worker`: takes jobs from Postgres (`SELECT … FOR UPDATE SKIP LOCKED`) and runs the upload pipeline. Same binary, same config, its own systemd unit. Dependencies stay few: `pgx`, an S3 client for R2, a WebAuthn library, an OAuth2 library. Routing is the standard library's. ### Postgres (the only state) Postgres 18 holds everything: data, sessions, the job queue, full-text search (`tsvector` on name, summary, tags and replaced paths), the event outbox and the audit log. Core tables: - `users`, `identities` (OAuth provider + subject), `passkeys`, `sessions` (stores the SHA-256 of the token, never the token) - `targets` (`xbox-series`, `pc`, `ps5`…), `builds` (target, version, PE timestamp, released), `kinds`, `categories`, `tags` - `mods`, `versions`, `files` (sha256, size, storage key), `version_builds` (author-tested / player-reported / broken), `version_requires` (mod + version range, e.g. ViceHook >= 0.3.0) - `replaced_paths` (version, archive path), indexed by path: conflicts are a join - `media` (screenshots, re-encoded), `comments`, `bug_reports` (carry the build), `endorsements`, `download_counts` (daily rollups) - `reports`, `moderation_actions`, `takedowns`, `audit_log` - `jobs`, `events` (outbox) ### Object storage: Cloudflare R2 R2 has no egress fees, which matters most for a site that is mostly downloads. - **quarantine** (private): uploads go straight here through a presigned PUT capped at the declared size. The web server never streams upload bytes. - **public**: only files that passed. Keyed by SHA-256 (`/f//`), immutable, cached for a year. Served from a separate registrable domain so a hostile file can never read site cookies. Downloads go through `gta6mods.sh/d/`, which counts the download (in memory, flushed every minute) and redirects to the files domain. ## The upload pipeline 1. The author creates a draft version: kind, targets and builds tested, what it requires, changelog. 2. The site returns a presigned PUT to the quarantine bucket. The browser uploads. 3. The site enqueues `inspect(version)`. 4. The worker, in a sandbox with no network and capped CPU, memory and disk: - checks the size and SHA-256 against what was declared - unpacks zip (7z later) with limits: at most 5,000 entries, 4 GB unpacked, a 100:1 compression ratio, one level of nested archives, no absolute paths, no `..`, no links - rejects any `.rpf`, and anything that is not what the declared kind allows - records `replaced_paths` for archive mods and checks them against the public name list vicerpf uses - flags code (`.asi`, `.dll`, `.exe`) and runs clamd on every file - re-encodes screenshots to WebP, which strips metadata and kills polyglot files 5. Clean, no code, and the author is established: the file is copied to the public bucket and the version goes live. Otherwise it waits for a moderator. Code from a new author always waits. 6. An event is written (`version.published`). Handlers update search, the feed and the Discord webhook. ## Accounts and sessions - Sign in with Discord or GitHub (OAuth), or a passkey. No passwords at all. Moderators must use a passkey. - Session: 32 random bytes in a `__Host-session` cookie (`HttpOnly`, `Secure`, `SameSite=Lax`); the database keeps only its hash. Signing out deletes the row. - Changes need `POST` plus an `Origin` check plus a per-form token. - Turnstile on sign-up, first upload and reports. Per-account and per-IP rate limits in Cloudflare and in `modd`. ## Headers CSP with a per-request nonce and no third-party origins; `frame-ancestors 'none'`; HSTS with preload; `Referrer-Policy: strict-origin-when-cross-origin`; `X-Content-Type-Options: nosniff`. ## How it grows - **A new platform or build:** insert into `targets` and `builds`. If the file format differs, register another inspector for that kind. - **New features** subscribe to the outbox (notifications, webhooks, search) and don't touch the upload path. - **The installer** (Direction 2, later) uses the public API: it reports the build and what is in `victory\mods`, gets an install plan, checks SHA-256, and calls `vicerpf mod pack`. `gta6mods://install/` links hand off to it. The API is shaped for that from day one, even before the installer exists. - **Search** stays in Postgres until it is measurably slow; Meilisearch can then read the outbox. ## Hosting One DigitalOcean droplet behind Cloudflare (origin certificate, Caddy, two systemd units), Postgres on the same box to start, nightly `pg_dump` to R2 and WAL archiving once there are real users. Uptime is watched from outside, like the other droplets. Moving Postgres to a managed instance or a second box is a config change. ## Rules the code enforces - Story mode only. No mods for online play. - No game files in uploads (`.rpf` is rejected; moderators remove anything else). - Every file shows its SHA-256; every version shows what it replaces and needs. - Takedowns have their own queue and leave an audit trail. - Not affiliated with Rockstar Games, Take-Two or VIctory. ## Phases 1. **Before the PC release:** the site with the Library front end, invite-only uploads, Ethan's own tools (ViceHook, ViceMenu, vicerpf modloader) listed first. 2. **PC launch:** open uploads with moderation, the PC target added. 3. **Installer:** API tokens, install plans, `gta6mods://` links. 4. **Consoles:** when a console build can be modded, its targets and inspectors. ## Alternatives considered - **Node/TypeScript** (the stack of most other projects here): workable, but a larger dependency tree to audit for a site that accepts files from strangers. Go keeps it to one static binary and a short dependency list. - **An SPA front end:** more JS, a token-based auth surface, and worse caching for mostly-read pages. Server-rendered pages are faster and simpler. - **S3 or Spaces for files:** egress fees on a download site; R2 has none.