Skip to content

About

Taiko Fanmade Community

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

OurTaikoNet

The one backend and website of OurTaiko at net.ourtaiko.org. It is being built to replace three services (OurTaiko Fanmade, OurTaiko Database and OurTaikoProfile) with one service on one database. Those three stay untouched until this one is shown to work.

Status: the database layer and a first backend exist and pass their tests locally. On a copy of production data the import matches table for table, and the two sources and the players' pages answer every public question as the three old sites do. It is in production since 2026-11-14; how it is published is in deploy/README.md. The website is web/, a React app this server serves (WEB_DIR) in front of the API. It was a repository of its own, OurTaikoNetWeb, until 2026-11-14; its history is kept under web/ with the same commit hashes.

Part State
db/ One database, ourtaiko_net, built from the three old ones; importer; tests
Backend (Go, this repository) One program on the one database. internal/songs serves a song source, and the program runs it twice: once for Fanmade and once for the official source (sources.go holds what each has of its own). internal/profile serves the players' pages. internal/signin is the website's sign-in and sessions, which all of them use
internal/site The new address: each source under /api/v1/sources/<source>/, players' routes (titles, nameplates, all their scores, the site's latest activity) under /api/v1/, and the website's build (WEB_DIR) for every other address
internal/legacy The old host names: their APIs answered as the old sites answered, their pages sent to the same pages of the new site. The only place that knows about them
internal/groups User groups, one bit each on a player's row: who may do the work each part reserves for its managers. The account center only says who the site's administrator is; the administrator assigns groups under /api/v1/admin/
internal/multiplay, cmd/rooms, proto/ Multi-Enso, the game's online rooms: a gRPC service, in production the program cmd/rooms in a container of its own, in development optionally inside the site's program. See "Multi-Enso" below
internal/comments Threaded comments, kept wherever they are hosted: replies under replies, an upvote or a 何意味 on each, five orders, editing, deleting, an administrator's removal. Each song source hosts the comments under its songs and 段位 courses in its own comments and comment_votes tables; the site hosts the comments under its announcements in the tables of those names in net. A host says what a thread hangs on, who may write and whom to tell. The server keeps a comment's text as written; the website shows it as Markdown, as an announcement's (web/src/kit/markdown.tsx with by="member": pictures shown, fetched without a referrer, every link marked nofollow ugc, HTML never run), and shows it as plain text with linked addresses until the parser has loaded.
internal/inproc The one call the parts still make over HTTP inside the program: the sources reading the title catalog. A stage: it is to become a direct call
web/ The website (React): both song sources and the players' pages in one app; see web/README.md
contracts/ Cases both sides run: validation.json, the upload rules of the Go package tja and of the website's src/kit/tja.ts; chart-text.json, how a song's name is picked by language (internal/site/chart_text.go for link cards, the website's src/kit/chart-language.ts)
Dockerfile, deploy/, .github/workflows/ The image, how the backend and the website are published to the server and rolled back; see deploy/README.md

API versions

The API's code (internal/songs, internal/profile, internal/site) answers paths under /api/ with no version in them, and names every public file by its path under the distribution root https://distrib.ourtaiko.org/ (internal/files): fanmade/<sha256>.webp, 3dchara/cos/0.glb, sso/avatars/<a>/<b>.webp. A published file is never replaced in place (a changed file gets a new path); only JSON catalogs and manifests change. Each version mounts that code under its prefix (internal/api/mount); a path with no version, or an unknown one, is 404.

  • /api/v2/ (internal/api/v2), the website's: answers as the code gives them, the same for every visitor. A client asks once GET /api/v2/distribution/source → {"mirror","baseUrl","canonicalBaseUrl"} (the mirror for mainland China, else the canonical CDN) and joins baseUrl and a path, retrying canonicalBaseUrl and the same path if that fails. File fields: songCoverPath, songListCoverPath (the game's folders add songListCoverSha256/Size), authorAvatarPath (a chart's author, which v1 calls the uploader, and a comment's), avatarPath, 3dCharaPath (a Don's files; the icon of a Don part given as a reward), audioPreview.path; a chart's resource manifest is {chartId, resources: {kind: {path, sha256, size, contentType}}}; the 3D Don and nameplate catalogs give full paths and no base address. With files on the server's disk (development) the root is the server's own /api/v2/files/, which serves the sources' folders and redirects any other path to the canonical root. A playlist, the game's folder of it and a category carry scenePreset: the play backdrop the game uses for songs opened from it (a stage preset's name, as a chart's SCENEPRESET; "" for none). The server only checks its form (^[A-Za-z0-9_]{0,32}$): which presets exist is published with the game's stage files (stage/catalog.json under the distribution root), and a game passes over a name it does not have. Its owner sets a playlist's; an administrator may set it, and nothing else, on any public playlist. A score's score is the site's: score in an upload (POST /api/game/scores, a 段位 attempt's scores) is deprecated, read from released games so they are not refused and ignored, and clients leave it out. The score is (good + Ad-Lib 良) × the block's 良 points + (ok + Ad-Lib 可) × its 可 points + drumroll × 100, by the block's scoring that TJAParser reads when the file is stored (chart_difficulties.good_points…; blocks without it, stored before it was kept or under an older rule, are read when the server starts, which rescores their current scores, and until that is done every path but /healthz and /readyz answers 503 SCORING_IN_PROGRESS with Retry-After). A block TJAParser cannot score takes no new scores (422 DIFFICULTY_NOT_SCORABLE). scoreRank is its rank against the block's kiwami line: 0 none, 1–6 (白粋 to 紫雅) from 50, 60, 70, 80, 90 and 95 % of the line, 7 極 at the line; null for a score the site has not worked out (a block it cannot score, or content replaced since the play).
  • /api/v1/ (internal/api/v1), released games': the same code, its answers converted back to version 1's full addresses and names, a mainland visitor's on the mirror, with fallbackUrl, mirrorBaseUrl/mirrorPaths, ?origin=1 and /api/v1/distribution/avatar as before; an answer with nothing to convert is passed on byte for byte. The old hosts and online rooms speak version 1. When no client uses it any more, its folder and the lines mounting it in internal/app go.

Routes below are written as /api/v1/…; each is also at /api/v2/… with version 2's file fields.

Running

scripts/test.sh                          # every Go test; see the script for what it needs
go run ./cmd/server -init                # create the schema in an empty database
go run ./cmd/server                      # DATABASE_URL, LISTEN_ADDR, STORAGE_DIR, TJAPARSER_BIN, …
db/dev/pull-backups.sh                   # fill the local source databases from production backups (aws login first)
tools/compare-local.sh <3 local dbs>     # run the old sites and this one side by side and compare their answers
scripts/proto.sh                         # regenerate internal/multiplay/multiplaypb after changing proto/
go run ./tools/multiplay-smoke           # a player of Multi-Enso for trying it by hand; see "Local development"

Multi-Enso (online rooms over gRPC)

OurTaikoPlay's online multiplayer (マルチ演奏). The protocol is proto/ourtaiko/multiplay/v1/multiplay.proto: one bidirectional stream per player, ourtaiko.multiplay.v1.MultiEnso/Connect. The first message is join; from then on the server sends the whole room (room) every time anything in it changes. A player is who the game's session says: metadata authorization: Bearer <game session>, the session the game sends to /api/v1/…/game/….

  • Process. In production the rooms are the program cmd/rooms, in the container ourtaiko-net-rooms: rooms live in its memory, so releasing the site does not touch them. It holds no secrets and reads no database; it asks the site who a game session is and what the songs are (internal/multiplay/roomsapi, the site's MULTIPLAY_INTERNAL_ADDR, a port nothing outside the containers reaches). While the site restarts, what it last said stands in: players in a room notice nothing, a dropped player gets back in, and a chart the rooms have never seen waits for the site. In development MULTIPLAY_LISTEN_ADDR runs the same service inside the site's program instead. Either way it speaks gRPC in clear text (h2c); the reverse proxy ends TLS and passes /ourtaiko.multiplay.v1.MultiEnso/ on with grpc_pass (deploy/README.md, "Multi-Enso (gRPC)"). The game asks GET /api/v1/game/multiplay before it connects: {"url": …, "protocol": 1, "maxProtocol": 2, "maxMembers": 5}, where url is MULTIPLAY_PUBLIC_URL (default: the site's address the game asked at, APP_ORIGIN or one of APP_OTHER_ORIGINS), protocol the oldest version of the protocol a game may speak (an older game asks its player to update) and maxProtocol the newest the server speaks (a newer game joins with that one), or 404 MULTIPLAY_UNAVAILABLE where the service is off. A restart of the rooms' own program closes its rooms (ROOM_CLOSED); a release waits for the rounds under way first (ourtaiko-rooms drain), during which no room opens, no new player enters and no round begins.
  • Rooms. Up to 5 players, a 5-digit number. quick_match enters the fullest public room that is waiting, or opens one; create_private opens a room only its number can enter (room_code), which its host can make public for good (open_room). The first player is the host; when the host leaves, the longest-standing connected member is. A round begins in one of two ways only, in a public room as in a private one: the host locks the members (lock_members) with at least MULTIPLAY_MIN_PLAYERS of them in the room (default 2), or the room is full and every member is in it, when it begins by itself. No room begins a round for having waited. "In the room" is connected and not away at a play or its result (see "Coming back after a play"). The host can remove a member while the room waits (kick). An account is in one room at a time.
  • A round. Song select, 90 s: each player picks a chart of either source ({source, chart_id}: published, with files) or leaves it to chance (おまかせ), and names the course they would play; what was picked stays hidden until the draw → a chart somebody picked always goes before chance: one of the charts that were picked is drawn, each with the same chance, and only when everyone left it to chance is any chart drawn (any the game's catalog lists, each with the same chance); it is shown for 4 s → course, 15 s: each player picks one of the drawn chart's courses and is ready; the default is the course they asked for, else the one they played last round, else Oni, when the chart has it, otherwise the nearest easier course, otherwise the nearest harder one → loading, up to 90 s: the game downloads the chart (it is described in the room snapshot exactly as GET /charts/{id} of its source describes it) and reports loaded; start_play is sent once everyone has, and whoever has not in time sits the round out → the play: each player reports score, combo, 良/可/不可, 連打 and the soul gauge about 5 times a second, and the server sends everyone's every 250 ms → the result, once everyone has finished or 30 s after the first one did (no play lasts more than 15 minutes), shown for 10 s → back to the lobby with the same members. A phase that is left with fewer connected players than a round needs goes back to the lobby (NOT_ENOUGH_PLAYERS).
  • The result. Players who finished first, by score, then 良, max combo and gauge. The top finisher is the MVP, or the SUPER_STAR when at least 30 % ahead of the second; with fewer than two finishers, or a top score of zero, nobody is. team_score is the sum. full_combo: no 不可; all_good: only 良. cleared is what the game reported. Scores are the game's word: the server ranks them and does not check them, and each player's own score is uploaded by the game as after any play.
  • Coming back after a play (protocol 2). A play is the game's own play scene, and after it the player's own result screen, so a round's players are away from the room's screen for a while. From start_play each of them is away in the room snapshot until their game says returned, which it does while the room's screen is up and the snapshot still has the player away (about once a second, so a message lost with a connection is said again). A member who is away is not in the room: a full room does not begin its next round until every member is back, and the host cannot start with fewer than the minimum in the room (NOT_ENOUGH_PLAYERS). When the host does start, the members who are still away are left behind: they are taken out of the room (closed LEFT_BEHIND) and may come in again by its number once it is back in its lobby. Nothing begins or ends by itself for a player staying away. A member whose game joined with protocol 1 is never away: those games do not say when they are back.
  • Losing the connection. A stream nothing has come from for 40 s is ended (DEADLINE_EXCEEDED, SILENT): the game pings every 15 s, and a connection that died without a word is found by its silence. A stream that ends without leave keeps its place for 10 s; join with the room's number takes it back, in any phase. A player who drops during a play stays in the result as disconnected, as does one still playing when the round is ended. A second connection of the same account to the same room replaces the first (REPLACED).
  • Stamps. stamp_id 0–15, one a second per player, none from a player in the middle of a play. There is no text chat.
  • Limits. 40 messages a second from a client on average (and 40 at once), 64 KiB a message, join within 15 s, 2000 rooms. Everything a client reports is clamped to a sane range. A client that does not read what it is sent is dropped.
  • Codes. A request the room refuses is answered with notice and the stream stays open; closed ends it. Both carry a code for the game to show in the player's language and a message in English for logs: ROOM_NOT_FOUND, BAD_ROOM_CODE, ROOM_FULL, ROOM_BUSY, ROOM_CLOSED, SERVER_FULL, NOT_HOST, BAD_PHASE, BAD_REQUEST, NOT_ENOUGH_PLAYERS, CHART_NOT_FOUND, NO_CHARTS, LOAD_FAILED, SERVER_ERROR, LEFT, KICKED, REPLACED, NOT_IN_ROOM, UPDATE_REQUIRED (the client's protocol is newer than the server's). A stream that cannot be served at all ends with a gRPC status instead: UNAUTHENTICATED AUTH_REQUIRED (no session, or one the account center refuses), UNAVAILABLE AUTH_UNAVAILABLE (the account center could not be asked), FAILED_PRECONDITION (the first message was not join), DEADLINE_EXCEEDED (no join in time), RESOURCE_EXHAUSTED (TOO_MANY_MESSAGES, SLOW_CONSUMER, or a message over the size limit).

The state machine (room.go, manager.go) does no I/O and is tested on a clock the tests move; server.go is the gRPC service around it, tested over a loopback connection.

Visits

How much the website is visited (internal/visits, migrations 0008_visit_times and 0016_visit_addresses). The website tells the server each page it shows (web/src/kit/shell/visits.ts, from the frame, once a page has stayed 0.6 s); nothing is counted from the requests themselves, so the game and programs reading the API are not visitors. Every view is kept with the moment it was made, and whoever reads the count names their time zone (?tz=, the browser's IANA name; UTC without one): days, "today" and hours are those of that zone.

  • What is kept. net.visit_views (at, page, visitor_even, visitor_odd, address, country), one row a view, and net.visit_salts (span, salt). A page is an address with every part that is not a plain word replaced by :id (/fanmade/charts/:id).
  • Addresses and countries. Since 0016 each view keeps the IP address it came from (address, the client address of internal/web/clientip.go) and the country that address was in at that moment (country, two letters, from the DON_GEOIP_DB country database; the database is read whenever it is set, with or without the mirror). Both are kept for good and neither is ever deleted. country is NULL without a database, for an address in no country, and for a private address; the views made before 0016 have neither. No answer of the API gives an address out: the administrator's report counts by country only. Whoever can read net.visit_views in the database (the console's roles) reads the addresses.
  • The site's address. Since 0018 each view also keeps which of the site's own addresses the page was seen at (site, the host name of APP_ORIGIN or one of APP_OTHER_ORIGINS the request came to, such as otnet.sakura-bot.cn for the address in mainland China). 0018 set the views made before the second address opened (2026-11-22 02:53:25 UTC) to net.ourtaiko.org, the only address then; those made between then and 0018 may have been seen at either and have none.
  • Visitors. No cookie. A salt belongs to a span of two UTC days, and a span begins every day, so every moment lies in two spans: one beginning on an even day (counted from 1970-01-01), one on an odd day. Each view keeps sha256(salt || IP and User-Agent) under both. A day of any time zone (up to 24 h from UTC) lies inside the span beginning on the UTC day it begins on, so its visitors are the distinct hashes of that span's column. Every hour the salts of spans that are over (begun two days ago or more) are deleted: from then on the hashes still tell that span's visitors apart and cannot be made again from an address and a browser. (The addresses kept since 0016 are another matter: by them a view can be traced to where it came from.) Over several days "visitors" is the sum of each day's. A 25-hour day at the end of daylight saving time may stick out of its span by the extra hour at most; a visitor in that hour can be counted twice.
  • Before 2026-11-17. The first count (0005) kept only totals per day of UTC+8 (net.visit_days, net.visit_pages, net.visit_visitors). 0017_drop_first_visit_count dropped those tables and what they had counted: every number is of net.visit_views alone.
  • POST /api/v1/visits {"path": "/fanmade/charts/…"} → 204, with or without a session. Not counted, and still 204: a User-Agent that is a program's or missing, more than 60 a minute from one address, a path that is no address of the site. It does not count against the 40 writes a minute.
  • GET /api/v1/visits?tz=Asia/Shanghai, public → {"total":{"views","visitors"},"today":{…},"since":"YYYY-MM-DD"}, kept in memory for 30 s per time zone (64 zones at most). The footer of every page shows it. A tz that is no time zone → 400.
  • GET /api/v1/admin/visits?days=30&tz=Asia/Shanghai (days 1–366), the site's administrator → the same, plus zone, days (each day of that zone, oldest first, with the days nobody came), hours (views in each hour of the day 0–23 over those days), pages (the 50 seen most in the period) and countries ([{"country":"JP","views","addresses"}], every country the period's views came from, most views first, with the number of different addresses; the country "" is the unknown one) and sites ([{"site":"net.ourtaiko.org","views","addresses"}], the same by the site's address the views were seen at; "" is the views it is not known of). The website shows it at /manage/visits (web/src/players/pages/visits.tsx), in the menu for the administrator, in the browser's time zone.

Recommended playlists

The home page recommends a few playlists the site's administrator chose (internal/profile/httpapi/featured.go, migration 0013_featured_playlists): public playlists of either source, in the administrator's order, each with an optional line of the administrator's own. Only the choice is kept, in net.featured_playlists; what a playlist is stays its source's to answer. A playlist that is deleted or made private in its source leaves the list by trigger, so a row always names a public playlist.

  • GET /api/v1/featured-playlists (public) → {"items": [{"source", "playlistId", "note"}, …], "max": 6}, in the order shown.
  • PUT /api/v1/admin/featured-playlists {"items": […]}, the site's administrator → the same. The list sent replaces the one kept; an empty list recommends nothing. 422 FEATURED_INVALID (more than 6, an unknown source, an id that is no stored playlist's, one named twice, a note over 40 characters or of several lines), 422 FEATURED_PLAYLIST_UNAVAILABLE (a playlist that does not exist or is private).
  • GET /api/v1/sources/<source>/playlists?ids=a,b (public, at most 12) → the public ones of the playlists named, as the playlist list gives them (without songs), in the order named. One that is private or gone is left out.

The website shows them under the newest charts (web/src/players/components/featured-playlists.tsx): one at a time, moving on by itself as the newest charts do (carousel.tsx is what both share), with every song of the one shown in a list that scrolls by itself, as the community's activity does, and, on a wide page, all the playlists beside it. It asks for the list, then each source once for its playlists, then the songs of the one shown (not of the others until they are shown). The administrator sets them at /manage/featured (web/src/players/pages/featured.tsx).

Fanmade's categories

Fanmade has eight categories (internal/songs/httpapi/sources.go), one for each of the official source's, since migration 0032_fanmade_eight_categories: game 1 (the games that are not rhythm games; its title is Non-Rhythm Game, which is the name of its folder in the game), vocaloid 2, pop 4, classics 8, variety 16, anime 32, rhythm-game 1024 and kids 16384. The official source keeps the eight of the official game; rhythm-game stands where that has namco, and the other seven have the same IDs there. The bits are each source's own and differ between them: across sources a category is compared by its ID. A category is a folder of the game's song select (the game makes one for each category the catalog lists and draws it in the frame of its genre, so rhythm-game's is NAMCO and kids' CHILDREN), a filter of the chart list, and something a title rule can name.

Between 0027_fanmade_categories and 0032 Fanmade had fourteen: the bits 64 (touhou), 128 (gekichumai), 256 (bemani), 512 (project-sekai), 2048 (bms), 4096 (album) and 8192 (internet) are retired and never to be used again, 1024 was other-rhythm-games, and virtual-singer and classic were the IDs of vocaloid and classics. 0032 put touhou's charts in variety, gekichumai's, bemani's, project-sekai's and bms's in rhythm-game, album's and internet's in variety when they were in no other category, and took every chart in rhythm-game out of game; touhou, gekichumai, bms and internet became tags of those charts (next section), voted by the chart's first owner.

A chart's owners and Fanmade's managers (FANMADE_MANAGER) set its categories, by editing the chart (PATCH /charts/{id} categoryIds). Between 0027 and 0032 players also suggested categories for Fanmade's managers to accept or reject (category_suggestions, category_rejections); that went when the categories became eight (what a player says of a song is a tag now), and the two tables are left unread for a later migration to drop.

The tags this replaced. 0026_chart_tags added site-wide tags (net.tags, each source's chart_tags, tag_rejections, tag_suggestions) and the group TAG_MANAGER (bit 8). A day later 0027 turned them into Fanmade categories: every tagged chart was put in the categories its tags became (anime, pops, vsingers and game-original became the categories anime, pop, virtual-singer and game) and taken out of Variety, the tags' suggestions and rejections became category ones, and bit 8 was taken from everyone (it is not to be given another meaning). Tags came back in 0031_tag_votes, put on by the players (next section): that migration dropped chart_tags and tag_suggestions, and kept net.tags and tag_rejections.

Tags

Tags say what a song is beside its categories (東方Project, BMS…); a category stays the folder of the game's song select. The catalog (net.tags) is the site's, the same for both sources; the players put the tags on (internal/songs/httpapi/tags.go, migration 0031_tag_votes).

  • Votes. A chart has a tag while at least one player's vote for it stands (chart_tag_votes of each source, vote 1; taking it back sets 0 and keeps the row). A signed-in player adds a tag and takes their own vote back; nobody changes another player's vote.
  • Pending and official. A tag is official (the catalog, in position order) or pending. A manager's new tag is official at once. A player who names a tag the catalog does not have makes a pending one (at most 20 of their own at a time), offered to everyone like the others. It becomes official when 3 different players have used it, on whatever charts of either source; one nobody votes for any more is deleted. Names are 1 to 24 characters and no two tags share one, whatever the case; a player's tag has the one name, kept as en.
  • Reports. A player reports a tag that does not belong on a chart (chart_tag_reports, one per player, chart and tag, with a reason of up to 500 characters). A manager of the source upholds it, which withdraws every vote for the tag on that chart and remembers it (tag_rejections: later votes are refused with 409 TAG_REJECTED, until a manager votes for the tag there), or dismisses it. Either answers every waiting report of that tag on that chart.
  • GET /api/v1/sources/{source}/tags → {"items": [{"id","names","status","chartCount"}]}: official tags first, then pending; chartCount is of the source's published charts.
  • GET …/charts/{id}/tags → {"tags": [{"id","names","status","count","mine"}], "reported", "canReview"}, the most voted first; mine, reported (the tags the viewer reported and waits on) and canReview (a manager) are of the signed-in viewer.
  • PUT …/charts/{id}/tags/{tag} {"vote": 1|0} and POST …/charts/{id}/tags {"name"} (the tag of that name in any language, or a new one) → {"tags"}. 404 TAG_NOT_FOUND, 422 TAG_NAME_INVALID, 409 TAG_LIMIT, 409 TAG_REJECTED.
  • POST …/charts/{id}/tags/{tag}/reports {"reason"} → 204; 404 TAG_NOT_ON_CHART. A waiting report takes the new reason; a decided one stays as decided.
  • For the source's managers: GET …/tag-reports?status=pending|upheld|dismissed&page=n (grouped by chart and tag, 30 a page, the first five reporters with their reason, and votes), POST …/tag-reports/decision {"chartId","tag","uphold"}; and the catalog, which either source's manager keeps for both: POST …/tags {"names"} (en required; en, zh-Hans, ja, ko), PATCH …/tags/{tag} {"names"?, "official"?: true}, DELETE …/tags/{tag} (with its votes, reports and rejections everywhere), POST …/tags/{tag}/merge {"into"} (votes, reports and rejections of both sources go to the other tag). 409 TAG_EXISTS for a name another tag has.
  • A chart's JSON has tags: the IDs of its official tags, the most voted first. GET …/charts?tag=<id> filters by an official tag. The game's catalog (GET …/game/catalog) has tags, the official ones as {"id","names"}.

The website shows a chart's tags with their votes under its categories and offers 「标签」 to a signed-in player (web/src/kit/tags.tsx): every tag with how many songs have it, a box that finds one or names a new one, and a flag to report. The chart list filters by one official tag at a time, a row of chips under the categories'. The reports and the catalog are at 标签管理 /manage/tags (web/src/players/pages/tags.tsx), in the menu for either source's managers.

Announcements

What the site's administrator has to tell every visitor (internal/profile/httpapi/announcements.go, migration 0014_announcements, table net.announcements): a title of one line (1–80 characters) and a text written in Markdown (up to 4000 characters, empty when the title says it all), in whatever language the administrator writes. The server keeps the text as written; the website shows it as Markdown (web/src/kit/markdown.tsx: react-markdown with GitHub's tables, task lists and bare addresses as links, line ends kept, links opening in a tab of their own) and never runs HTML written in it. The title is plain text. Pinned ones are shown first, then the newest; editing one does not change when it was announced.

  • GET /api/v1/announcements?page=1&pageSize=20 (public; pageSize 1–50) → {"items": [{"id", "title", "body", "pinned", "publishedAt"}, …], "total", "page", "pageSize"}, in the order shown. A page past the end has no items and the same total.
  • POST /api/v1/admin/announcements {"title", "body", "pinned"}, the site's administrator → 201 and the announcement, announced as of now.
  • PUT /api/v1/admin/announcements/<id> with the same body → the announcement as it now reads. DELETE of the same address → 204.
  • 422 ANNOUNCEMENT_INVALID (no title, one too long or of several lines, a text too long or with control characters other than line ends), 404 ANNOUNCEMENT_NOT_FOUND.

Players comment under an announcement as they do under a song (internal/comments, hosted by internal/profile/httpapi/announcement_comments.go; migration 0015_announcement_comments, tables net.comments and net.comment_votes, and net.announcements.comment_count, kept by trigger). The site's administrator may remove a comment; nobody is sent a notice of a comment here (the notices are each song source's, and the site keeps none), a player's comment history and their karma count what they wrote under songs and courses only.

  • GET /api/v1/announcements/<id> (public) → that announcement; each announcement now also carries commentCount.
  • GET /api/v1/announcements/<id>/comments?sort=best&page=1 (public) and POST of {"body", "parentId"?} (a signed-in player) → as a song's comments, each comment with announcementId.
  • GET /api/v1/comments/<id>?sort= (a comment with everything under it), PATCH {"body"}, DELETE, PUT /api/v1/comments/<id>/vote {"value": 1 | 0 | -1} → as the same routes of a song source, for the site's own comments.

The home page shows the first three titles beside the newest charts, over the community's activity (web/src/players/components/announcements.tsx); on a narrow page they come first. With none, or when they cannot be read, the corner is not there. A title opens the announcement over the page (web/src/players/components/announcement-dialog.tsx): what it says on the left, its comments on the right, each scrolling by itself, one under the other on a narrow page. Which one is open, and which comment is singled out, is in the address (?announcement=<id>&comment=<id>), so the way back closes it and a comment's link opens it. /announcements (web/src/players/pages/announcements.tsx) lists them all, each with how many comments it has, and opens them the same way; the Markdown parser is a part of its own that pages load when they first show such a text. The administrator writes them at /manage/announcements (web/src/players/pages/announcements-admin.tsx), with the text as it will read shown under what is typed.

Titles: private and public

A title is private or public (net.titles.visibility, migration 0023_title_review; internal/profile/httpapi/titles.go, title_reviews.go, title_notices.go).

  • Private. A player makes a title (POST /api/v1/me/titles {name, nameTranslations, description, layers}) and it is theirs alone: they hold it at once (a row of net.user_titles, which is no reward) and wear it, change it as they like (PUT /api/v1/me/titles/{id}) and delete it. A player keeps at most five private titles (409 TITLE_LIMIT_REACHED). Nobody else can be given a private title: not by a rule (422 RULE_TITLE_PRIVATE) or a title manager (422 TITLE_PRIVATE). It is not in the catalog; it is seen on its maker's nameplate, which is why the managers see every title and may remove one.
  • Review. To have a title given to others its maker asks for a review: POST /api/v1/me/titles/{id}/reviews {request}, request (1–500 characters) saying how the title should be obtained. The title goes as it is and cannot be changed while the request is pending (409 TITLE_REVIEW_PENDING); the maker may take the request back (DELETE /api/v1/me/title-reviews/{id}). One request at a time for a title. A title manager (TITLE_MANAGER) reads the queue (GET /api/v1/admin/title-reviews?status=pending|decided&page=) and decides: POST /api/v1/admin/title-reviews/{id} {approve, reply, obtain}, approved or returned, either way with a reply to the maker; 409 REVIEW_DECIDED for one decided already.
  • Public. An approved title is public: it is in the catalog with obtain, the words for how it is obtained (the manager's, written from the request), it no longer takes one of its maker's five places, and from then on only the title managers decide who gets it: rules ("Titles by rule", among them passing a fixed 段位 course) and a grant by hand (POST /api/v1/admin/grants). Nothing gives it by itself on approval. Its maker still holds it and no longer changes or deletes it directly (409/403 TITLE_PUBLIC): a change is a review too, POST /api/v1/me/titles/{id}/reviews {request, name, nameTranslations, description, layers}, and the title changes when it is approved. The titles the managers make themselves (PUT /api/v1/admin/titles/{id}, with obtain) have no maker and are public from the start; the same route changes any public title, and DELETE removes any title.
  • Routes for reading. GET /api/v1/titles (public): the public titles, each with visibility, obtain, holders (how many players hold it), ownerName and pending, and the rules. GET /api/v1/me/titles: the titles the player made, each with its latest review, and used of limit places. GET /api/v1/admin/titles: every title.
  • 称号中心. What a player is told about titles (net.title_notices): review_requested to every title manager, review_approved and review_returned to the maker with the manager's reply, title_removed to the maker of a title a manager removed. Nobody is told of what they did themselves. GET /api/v1/me/title-notices?page= (items, total, unread), GET …/unread (count), POST …/read. Each notice's data is what to show as it was then (title, review, and for a request userId, userName).
  • Website. /titles is the catalog: every public title on its band, how it is obtained, how many hold it, which the visitor holds. /me/titles (web/src/players/pages/my-titles.tsx) is the player's own: the plate and the titles held, and the titles made, where one is made, changed, sent for review or its change asked for. /manage/titles has the review queue, every title, what gives titles (rules, by hand) and the Don's parts, a tab each. 称号中心 is a chat among the player's chats (/chats/titles, web/src/kit/title-center.tsx), beside the site's notices, and counts in the bell.

Titles by rule

A rule gives one item: a title, or a part of the 3D Don (see "Parts of the Don to earn"); everything below holds for both. A rule says which in item (title, with titleId; don_item, with donPart and donItem); each kind of item says in rules.target how it is given and how it is held, and nothing else in the package knows it. A rule for a part is made at POST /api/v1/admin/don/items/{part}/{id}/rules with the same body, and the part must be in the catalog.

Besides an administrator's hand, a title is given by rule; a 段位 course gives titles only so (dan_clear; until migration 0028_dan_lock a course named its titles itself, and the migration made those of official courses into rules). The rules are the rewards' (internal/rewards/rules: judging them, and the managers' routes, which the players' part mounts; table net.reward_rules, migrations 0009_title_rules and 0025_reward_rules, which renamed it from net.title_rules and added item). An item may have several rules; meeting any one gives it. Only a public title takes rules. The same rule (the same item and the same conditions) is made once (409 RULE_EXISTS).

kind Met by Fields
chart_clear a score on one chart of a source source, chartId, clear, course?
category_clear scores on count charts of a category of a source; without count, on every chart of it that has a course high enough source, category (the source's category ID), clear, course?, count?
dan_clear an attempt at a fixed 段位 course of a source (see "Fixed 段位 courses"), made since it was fixed, whose verdict is at least clear source, danId, clear (1–6)
charts_uploaded being an owner of count fanmade charts, the only source players upload to: the uploader and every collaborator who joined a chart count it alike (the built-in account never). It names no source; migration 0025 dropped the ones that named the official source, whose charts are all the built-in account's count
site_login being seen signed in on the website
game_login being seen signed in in the game

clear is the lowest crown that counts (1 cleared, 2 full combo, 3 all good), for dan_clear the lowest verdict (1–3 red, 4–6 gold: a pass, with full combo, with all good), course the lowest course (Easy < Normal < Hard < Oni < Edit; none: any). Only scores that still stand (is_latest) on published charts with files count, and only such charts are counted as uploads.

  • When rules are judged. A score that clears: in the score's transaction, the rules of its chart and of its categories, for that player; the score's answer does not say what it earned (see docs/TITLES_PLAN.md, 1.1). Being seen: whenever a signed-in request writes the player's activity (at most once a minute, and the first time they are seen there) and at every sign-in, site_login for a website session and game_login for a game token; where a player was seen is kept on their row (net.users.seen_on_site_at, seen_in_game_at). A change of a source's charts, once saved (an upload, a change of categories, a chart deleted, a collaborator joining a chart): that source's category rules, and for fanmade the upload rules, for everyone (rules.ChartsChanged). A 段位 attempt that passed: in the attempt's transaction, the rules of its course, for that player (rules.DanAttempted). Nothing judges the rules on a clock: what meets a rule without the program seeing it (a change made in the database's console) is given the next time one of these judges that rule. A failure to judge is logged and never fails the score, upload or request; the rule is judged again on the next such occasion.
  • Once. What a rule gave is a row of net.awards with service = 'rule' and request_key = '<rule id>:<user id>'. A rule gives a player its item once: after an administrator takes it back, the same rule does not give it again (a new rule would). A player who already holds the item (by hand, another rule, or a 段位 course before 0028) is passed over and the rule is not used up for them: if they lose the item, the rule gives it when it next finds them meeting it. Rules only give: nothing is taken back when a player stops meeting a rule, or when a rule is changed or deleted. Only a title manager takes an item back, by hand (DELETE /api/v1/admin/grants, DELETE /api/v1/admin/don/grants), or by deleting the title.
  • Those who meet it already. Creating or changing a rule gives its item at once to every player who meets it. The sign-in rules go by seen_on_site_at and seen_in_game_at; for the players seen before 0025 kept them, a website session or an earlier site_login award counts as the website, a score or an earlier game_login award as the game.
  • GET /api/v1/titles, public → titles, rules and categories: every rule with its item, titleId or donPart and donItem, the fields above, for a chart rule chart (id, title, titleTranslations, gone when it is no longer published), and for a dan_clear rule dan (id, title, code, fixed, gone when it was deleted: while it is gone or not fixed the rule gives nothing); categories is each source's category IDs in the order of their bits, what a category rule may name. GET /api/v1/don/items lists the rules of Don parts.
  • POST /api/v1/admin/titles/{id}/rules (TITLE_MANAGER) with the fields of the kind → 201 {"rule", "granted"}, granted being how many players got the item at once. 422 RULE_INVALID, RULE_CHART_NOT_FOUND, RULE_DAN_NOT_FOUND, RULE_DAN_NOT_FIXED (a rule names only a fixed course), RULE_TITLE_PRIVATE; 409 RULE_EXISTS.
  • PUT /api/v1/admin/rules/{id} (TITLE_MANAGER) with the same body: the rule's conditions change, its item does not → 200 {"rule", "granted"}. 404 RULE_NOT_FOUND, and the problems of making one.
  • DELETE /api/v1/admin/rules/{id} (TITLE_MANAGER).
  • POST /api/v1/admin/titles/{id}/rules/preview and POST /api/v1/admin/don/items/{part}/{id}/rules/preview (TITLE_MANAGER) with the body of a rule → {"meeting", "giving"}: how many players meet those conditions now, and how many of them making the rule would give the item at once. Nothing is made. The problems are those of making one.

The website shows each title's rules in the catalog (/titles) and makes, changes and deletes them in the reward centre (/manage/rewards/rule, web/src/players/pages/reward-rule.tsx: the conditions are filled in as one sentence, web/src/players/components/rule-sentence.tsx, with what saving would do counted first; the wording is web/src/players/reward-rules.ts, the names of the categories in the four languages under rules.categories; the category IDs come from categories).

Fixed 段位 courses

A 段位 course's maker may fix it (migration 0028_dan_lock; internal/songs/httpapi/dan_changes.go): from then on its songs and conditions change only by a request that a manager of its source approves (FANMADE_MANAGER, OFFICIAL_MANAGER), and only a fixed course may be named by a rule that gives items for passing it (dan_clear), which counts only the attempts made since the course was fixed. A change the managers approve is their own: the course stays fixed from when it was, and the attempts before the change still count. What a pass of it means cannot change behind the rule's back. Its name, colour, 段位 badge and which songs are hidden stay the maker's to change. A course's rewards holds only dan, the 段位 an official course stands for.

Each source has the routes, under /api/v1/sources/<source>/ (and /api/v2/sources/<source>/):

  • POST …/dans/{id}/fix (its maker or a manager; every song must be playable, 422 DAN_NOT_PLAYABLE; 409 DAN_FIXED, DAN_CHANGED) → the course, with fixedAt. DELETE …/dans/{id}/fix (a manager): no longer fixed; a request waiting is withdrawn, and its rules give nothing until it is fixed again.
  • PUT …/dans/{id} on a fixed course takes the songs and conditions only as they are (409 DAN_FIXED).
  • POST …/dans/{id}/changes {songs, exams, request} (its maker or a manager): the songs and conditions it should have, and why (1–500 characters). One waits at a time (409 DAN_CHANGE_PENDING); 409 DAN_NOT_FIXED, 422 DAN_CHANGE_EMPTY. GET …/dans/{id}/changes lists them, newest first; DELETE …/dans/{id}/changes/{change} withdraws the one waiting.
  • GET …/dan-changes (a manager): the requests waiting, oldest first, each with its course as it is now. POST …/dan-changes/{change}/decision {approve, reply}: approving gives the course the songs (which must still be blocks the charts have) and conditions asked for (fixedAt stays as it is); returning needs a reply. The maker is sent dan_change_result ({approved, reply}), which cannot be muted.
  • Table dan_changes in each source (songs as [{chartId, course, side, hidden}], exams, request, status pending/approved/returned/withdrawn, reviewer_id, reply); dan_courses.fixed_at.
  • Website: the course page shows whether it is fixed, fixes or unfixes it, lists the requests, and shows what passing it gives by rule (from the title catalog). The editor of a fixed course sends a change of songs or conditions as a request, with a reason, and saves the rest. Managers decide at /manage/dans (web/src/players/pages/dan-changes.tsx), each source's managers its own.

Rewards

What a player was given (a title, by any of the three ways; a 段位 badge that gets better), told the same way to the website and the game and for every request (internal/rewards, migration 0010_rewards). No answer's body says what was given; the score's answer does not either.

  • The header. Every answer to a request whose player is known carries X-Pending-Rewards: <n>, the rewards not seen yet: from both sources and the players' part, on the old domains too, file downloads included. Without a signed-in player there is no header. The count is read as the answer starts, after the handler ran, so the answer to the request that gave something already counts it. If the count cannot be read the header is left out.
  • Fetching. GET /api/v1/me/rewards (website session) or GET /api/v1/game/rewards (game token) → {"rewards": [{"id","kind","data","createdAt"}]}, the unseen ones, oldest first, at most 50. Then POST …/seen {"ids": [...]} (the website with its CSRF token) → {"marked": n}; ids of others' rewards, or of seen ones, are passed over.
  • Kinds. title: data.title (the title as it was when given: id, name, nameTranslations, description, obtain, style, layers, visibility, ownerId; a reward given before titles had layers has style only), data.service (fanmade, official, rule, admin, or null) and data.courseTitle. dan: index, verdict, and gold, combo as the emblem is drawn. A client draws the kinds it knows and marks the others seen with the rest.
  • Where rewards come from. Triggers in the database, one per thing that can be given: a row added to net.user_titles, a row of net.user_dans added or with a better verdict. The code that gives titles or badges knows nothing of rewards. A title taken back before it was seen is taken out of the unseen rewards. A new kind of reward is a new trigger, and one entry in the website's dialog.
  • Kinds, continued. don_item: data.part, data.itemId, data.service, data.courseTitle; when fetched, the app's Describe hook adds data.name (by language) and data.picture (the mirror's address for a visitor it serves) from the catalog, which the database does not hold. The stored reward does not change.
  • Counting. The count is a query on the partial index of unseen rewards. While the server listens on a connection (Store.Run, started by app.Start), each player's count is kept in memory and dropped when the database says that player's rewards changed (LISTEN net_rewards, notified by a trigger on net.rewards for every insert, delete or seen). A request other than GET or HEAD counts afresh, so the answer to the request that gave something is never stale. A count read across a change is not kept (a generation number), counts live 5 minutes at most, and while not listening every answer counts.
  • Pruning. Seen rewards are deleted 90 days after being seen (rewards.Retention), hourly.
  • An answer with nothing written still carries the header: Announce sets it after the handler returns, before the server writes its 200.
  • The old domains serve both routes too (app.withRewards), for a game whose server has no site address.
  • The parts. internal/requester carries who a request is from: signin.RecordActivity, where every signed-in request is recorded, notes it; rewards.Store.Announce, wrapped around the whole site in internal/app, reads it. The routes are given each part's own sign-in check (Require of the players' part for the website, of a source for the game). On the website, web/src/kit/rewards/ is the store (both API clients and the frame's first request hand it their answers) and the dialog the frame mounts.

Messages

Players writing to each other (internal/chat, migration 0006_chats; the routes in internal/profile/httpapi/chats.go). The website's notification center became a messages page (/chats, web/src/kit/chat-center.tsx): the chats with other players, and the site's own notices as one chat among them, 系统通知 (/chats/system). The notices are not stored as chats: each source still keeps its own (notifications, /api/v1/sources/<source>/me/notifications…), and the website asks both and shows them together, as it did before (web/src/kit/notification-center.tsx). /notifications goes to /chats/system.

  • What is kept. net.chats (id, pair, created_at, last_message_at): one chat for each two players (pair is their ids, the smaller first, joined by :); net.chat_members (chat_id, user_id, read_seq); net.chat_messages (seq, chat_id, sender_id, body, created_at), seq counting over all chats; net.chat_blocks (user_id, blocked_id). A message is 1–2000 characters, without the blank around it. Nothing is deleted or edited, and nobody but the two members reads a chat through the API.
  • Blocking. While either of two players has blocked the other, neither can write in their chat (403 CHAT_BLOCKED). The blocked one is not told why.
  • Routes, all for the signed-in player: GET /api/v1/chats (the chats written in, the latest first, at most 200, and cursor), POST /api/v1/chats {"userId"} (the chat with a player who has been here, made if there is none; 404 USER_NOT_FOUND, 400 CHAT_SELF), GET /api/v1/chats/unread ({"count","chats","cursor"}), GET /api/v1/chats/{id}, GET …/{id}/messages?before=<seq>&limit=<1–100> (oldest first, and more), POST …/{id}/messages {"body"} (201), POST …/{id}/read {"seq"}, PUT …/{id}/block {"blocked"}. A chat is {"id","peer":{"id","nickname","avatarUrl"},"lastMessage","unread","readSeq","peerReadSeq","blocked","canWrite","createdAt"}. Marking read does not count against the 40 writes a minute.
  • Live. GET /api/v1/chats/updates?after=<cursor> answers at once with the messages after the cursor, or waits up to 25 s for one or for something else in the player's chats (a read, a block: "changed": true): {"messages","cursor","changed"}. The waiting is in this process (chat.Hub), so it holds while the site runs as one instance. The website keeps one such request open per page, only while the page is shown (web/src/kit/chat.ts); a hidden page reads its count once a minute.

The reward centre: what the managers give

Besides the rules, the title managers give by hand (internal/rewards/grants, migration 0037_reward_grants). Each act of giving is one grant, a row of net.reward_grants: who gave, what (titles and parts of the Don, up to 20 at once), to whom, a note for the managers, whether the players are told, and when it was taken back.

  • To whom (audience). players: up to 500 named by ID. everyone: every player there is at that moment (the built-in account is none). holders: who holds a given item. condition: who meets a rule's conditions now (the same conditions a rule takes; rules.Meeting). A grant is for the players there are when it is made; whoever comes later is a rule's.
  • What it writes. One award of the service admin per player and item given (awards.grant_id, request_key = 'grant:<grant>:<place of the item>:<user>'), from which user_titles or user_don_items is written. A player who holds an item already is passed over and gets no award for it; given on the grant counts, per item, the players who got it.
  • Telling. What is given is a reward by the tables' triggers, as before; a grant with notify false makes none (the two functions read it through the award).
  • Taking back. DELETE on a grant removes what its awards gave from those who still have it by them (a locked part off its player, as taking one part back does) and stamps the grant; the grant and its awards stay as the record. What a passed-over player held before stays theirs.
  • Before 0037. The awards the managers had given became grants: migration 0036's one grant to everyone, each other award a grant of its own. POST /api/v1/admin/grants and POST /api/v1/admin/don/grants (one player, one item) still answer as they did and make a grant each.
  • Routes (TITLE_MANAGER). GET /api/v1/admin/rewards → items: how each public title, and each part of the Don that is locked, held or given by a rule, stands (holders, rules, locked). GET /api/v1/admin/rewards/holders?kind=title&titleId=… or ?kind=don_item&part=…&id=… (q, page) → holders (each with how: grant, rule, dan, lock, other), total, pageSize, wearing. POST /api/v1/admin/reward-grants/preview {items, audience} → {players, items: [{give, skip}]}, giving nothing. POST /api/v1/admin/reward-grants {items, audience, notify, note} → 201 {id, players, given}. GET /api/v1/admin/reward-grants?page= → grants, total, and rules (what each rule has given so far). GET /api/v1/admin/reward-grants/{id}/players. DELETE /api/v1/admin/reward-grants/{id} → {taken}; 409 GRANT_REVOKED.
  • Website. /manage/rewards (web/src/players/pages/rewards.tsx, the logic in web/src/players/rewards.ts): one library of everything that can be given; for the item chosen its lock, its rules and its holders; and a tab of what was given. /manage/rewards/grant gives (reward-grant.tsx), /manage/rewards/rule makes or changes a rule.

Parts of the Don to earn

Every part of the 3D Don's catalog may be worn by anyone unless an administrator locks it (internal/donitems, migration 0011_don_items). A locked part is worn only by players who own it.

  • Tables. net.don_item_locks (part, item_id): the locked parts. net.user_don_items (user_id, part, item_id, award_id, acquired_at): what each player owns, with the award that gave it (none when given on locking). Parts are cos, head, body, puchi, paint; number 0 (taken off, or none) is never locked or owned. The catalog is the bucket's, so item_id has no foreign key; the routes check it against the catalog.
  • Locking gives the part to everyone wearing it at that moment, so nobody's Don changes; it is not a reward. Unlocking leaves owners as they are.
  • Wearing. PUT /api/v1/me/don answers 403 DON_ITEM_LOCKED (with items) for a locked part the player does not own among what the look puts on: the costume, or the head and the body, and the puchichara and the makeup. A part only stored (the costume while wearing a head and a body) is not checked.
  • Giving. By an administrator (POST/DELETE /api/v1/admin/don/grants {userId, part, id}, service admin) or by a rule. Taking a part back takes it off the player too, if it is locked. A part given (not on locking) is a reward of the kind don_item, by trigger, like a title.
  • Routes. GET /api/v1/don/items (public): {locked, rules}. GET /api/v1/me/don/items: {owned}. PUT /api/v1/admin/don/locks/{part}/{id} {locked} → {given}. The administrators are TITLE_MANAGER, as for titles.
  • Website. web/src/players/don-items.ts reads them; the dressing room shows a locked part the player does not own greyed, with a lock and how it is earned, and does not pick it; the reward centre (/manage/rewards) locks, gives and takes back, and makes the rules that give a title or a part.

The 3D Don

OurTaikoPlay draws each player's 3D Don (its Chara3D, ported from YataiDON). The models are not in this repository or the game: which parts there are is the database's (net.don_items, migration 0034_don_items), and their files are in the public bucket under 3dchara/items/ (https://distrib.ourtaiko.org/3dchara/items/), each named by its content: <SHA-256>.<extension>. Nothing there is ever replaced; another model or picture is another hash on the part's row.

  • Parts. A row of net.don_items is one part: its kind (part: cos, head, body, puchi, paint, background) and number (item_id), which looks, locks, owned parts, rules and games name it by and which never change (a trigger); name_translations ({"ja","en","zh",…}); its file's hash, extension (glb; png or otanim for a puchichara; png for makeup) and size; and its icon's icon_hash and icon_size (a PNG; a background must have one). Number 0 of cos, head and body is the plain Don's piece; the other kinds have no 0 (it means none). net.don_base_files holds the three files every Don shares (animations, face, faceAnimations) the same way. The migration wrote the parts published until then (179 costumes, 140 heads, 163 bodies, 213 puchichara, 57 makeup) from the bucket's old 3dchara/catalog.json, each file checked; that catalog and the files at their old paths (3dchara/cos/30.glb) stay in the bucket, unread and no longer kept up. A lock, an owned part and a rule hold their part by foreign key, and a trigger holds a look to parts there are (don_look_fits); a part cannot be deleted while a Don wears it.
  • Adding a part. tools/3dchara/items.py add <out> <part> <file> [--icon …] [--name ja=…] puts the file and icon into <out> under their hashes and prints the request; tools/3dchara/publish.sh <out> uploads them (needs aws login); then POST /api/v1/admin/don/items with that request (an administrator of titles and items; the admin page's Don tab takes it pasted) adds the row: {"part","id"?,"name":{…},"file":{"sha256","size","extension"},"icon"?:{"sha256","size"}}, 201 with the part as the catalog lists it. Without id it takes the next number of its kind; 409 DON_ITEM_EXISTS, 422 DON_ITEM_INVALID. The files go up before the row: nothing is uploaded through the site. items.py folder <folder> <out> names every file of a folder in the old layout by its hash (how the files published before 0034 got their names); catalog.py still writes a local folder's catalog.json, which the dev page and the game's DonPreview draw from.
  • Catalog. GET /api/v2/don/catalog answers every part from the database in the shape the bucket's catalog had: {"version":1, "base":{"animations","face","faceAnimations"}, "defaultColors":{"p1","p2"}, "items":{"cos","head","body","puchi","paint","background":[{"id","name":{"ja",…},"file":{"path","size","sha256"},"icon"?}]}}, every path under the distribution root (3dchara/items/<hash>.glb). A puchichara's file is a two-frame PNG or an animated .otanim (made with spine2otanim; format and tool in the otanim folder beside this repository, SPEC.md); an .otanim comes with an icon, which the dressing room shows instead of the file. The server keeps what it read for 15 seconds (a part added through the site is seen at once) and lets the answer be cached for a minute.
  • Makeup (paint, YataiDON's chara_paint_index, the cabinet's メイク): its file is a face sheet like the shared face (YataiDON's Models/paint/paint_<id>000.png, ids 1–57; 0 is no makeup and has no file). The Don draws it instead of the plain sheet, on face plates a third larger (YataiDON PAINT_PLANE_SCALE); a head or costume with no face plate of its own shows no makeup.
  • Background (background, ours, not YataiDON's): its file is a still model in the Don's own space (metres, +Y up, front +Z, the Don's feet at the origin) with no skin, worn with any outfit; 0 is none. It shares the Don's depth, so the Don is hidden where it stands behind it. It needs an icon: its file is no picture for the dressing room to show. The rules for the model, and how the game draws it as a layer of its own, are in OurTaikoLogs/OurTaikoNet/DON_BACKGROUND.md.
  • Data. net.don_looks (user_id, costume, cos_id, head_id, body_id, puchi_id, paint_id, background_id, colors, updated_at), migrations 0003_don_looks, 0007_don_paint (paint_id, default 0) and 0033_don_background (background_id, default 0). No row is the plain Don (costume 0); colors null is the seat's colours. (feat/story's migration was also numbered 0003: whichever of the two is deployed second must be renumbered, since a database only runs versions above its newest.)
  • Version 1 gives the catalog's paths relative to 3dchara/ with baseUrl (and mirrorBaseUrl/mirrorPaths for a mainland visitor; the mirror fetches a file it does not have from the canonical root by itself). Readable from any website.
  • GET /api/v2/users/{id}/don (the game, no session) and GET /api/v2/me/don (session) → {"look":{"costume","cos","head","body","puchi","paint","background","colors":["#RRGGBB"×3]|null},"files":[{"kind","id","3dCharaPath","size","sha256"}]}: the files the look needs (the costume, or the body and the head, the puchichara, the makeup and the background; a game from before backgrounds ignores the kind it does not know); version 1 gives each file's url. Without a catalog files is empty.
  • The website. Each player's page has a Don tab (web/src/players/pages/user-don.tsx, loaded on demand): a live 3D preview for everyone, and for the player themself the dressing room in three tabs: the outfit (a whole costume, or a head and a body, switched inside the tab), the puchichara, and the makeup (the tab shows only when the catalog has makeup; each sheet's first face on the Don's face colour), each an icon list; below the tabs the three colours, and Save. The preview is web/src/kit/don3d (@sitekit/don3d), the game's Chara3D ported to three.js; web/dev/don3d.html (not in the build; pnpm dev, then /dev/don3d.html?grid=1) draws the game's preview shots for comparing with the game.
  • PUT /api/v1/me/don (session and CSRF) with a look (paint or background left out is 0): every number must be in the catalog, also the ones not worn now (so switching between a costume and a head and body keeps both), colours #RRGGBB (stored upper case) or null; 422 DON_LOOK_INVALID; answers as GET.

The nameplate art

The website and the game draw nameplates, title bands and 段位 emblems from the same art, unchanged: the Nijiiro skin's global/nameplate plus OurTaikoPlay's own 段位 rings and rank texts. It lives only in the public bucket under nameplate/ (the game keeps no copy since 2026-11-15; it fetches the prefix at sign-in and caches it) (https://distrib.ourtaiko.org/nameplate/), listed by nameplate/catalog.json ({"version":1,"files":{"shadow","outline","bands","rainbow","danBackground","danRing{Silver,Gold,Rainbow}","danText","danTextGold","badge1p","badge2p":{"path","size","sha256"}}}). tools/nameplate/publish.sh <folder of the 12 PNGs> writes the catalog and uploads (files first, catalog last, then clears /nameplate/* on CloudFront). The backend reads it for GET /api/v2/nameplate-art/catalog, answering files with paths under the distribution root (nameplate/shadow.png); version 1 answers the bucket's relative paths with baseUrl, and mirrorBaseUrl/mirrorPaths (every file) for a mainland visitor. Clients verify bytes and fall back to the canonical root on mirror failure.

web/src/kit/nameplate-art-source.ts reads that catalog once per page load, downloads each file, verifies its bytes and supplies shared blob URLs; DanEmblem (web/src/kit/components/nameplate-art.tsx), the 段位 ring with the rank shown by itself, is drawn from it. Released game versions read these files, so they stay as they are.

Title layers

A title looks the way OurTaikoPlay's layered nameplate draws it: a band, an effect over it and an icon on its end (NameplateLayers). The pictures are the set the game's Tools/nameplate-samples/lumen bakes from the arcade nameplate's timeline into its set/ folder; the game does not carry it but downloads it from the bucket, as the site does. It holds each layer as an .otanim drawn on the whole 408x96 plate, and the plate's own parts and layouts. tools/nameplate/publish-lumen.sh <that folder> uploads them to nameplate/lumen/<folder>/<name>-<hash>.otanim (a changed file gets a new name) and then nameplate/lumen.json: {"version":1,"catalog":{"states","titles","aiTitles","unclipped",…},"files":{"band/lumen-title-gold":{"path","size","sha256"},…}}, the catalog being the game's own (composition/catalog.json), catalog.json and its PNGs untouched.

  • Parts. Every part a title can be made of is a row of net.title_items (db/migrations/0029_title_items), under a number of its own (id): its type (band, effect, icon) and name (unique within its type), kind (player: cut for a player's plate; ai: cut for the AI plate's other shape), source (arcade: from the arcade's set; custom: made for this game), name_translations, and hash, its file's SHA-256, which is its name in the bucket: nameplate/items/<hash>.otanim (the parts of the set published on 2026-11-26 were copied there on 2026-11-27). net.title_presets holds the looks a maker starts from (the arcade's titles and the ones added since, and the AI plate's own of the same names by kind), offered in the order of their ids. The migration wrote both from the set published then; a new part is a new row and a file under its hash. A part keeps its type and name (a trigger refuses to change them): a new picture is a new hash on its row. GET /api/v1/title/items gives every part (id, type, name, kind, source, nameTranslations, hash) and every preset (id, name, kind, layers), to any website; the site's title form picks from it. GET /api/v1/nameplate/set (internal/profile/httpapi/nameplate_set.go) is everything a plate is drawn from, to any website: layout, the plate's own layouts (states, ranks, blank, badges, bandBackingClip), which is a file of this repository (nameplate_layout.json, the arcade plate as the game's tool baked it, with the hashes of the plate's six pictures), and files, every picture by name (composition/<name> and each part's <type>/<name>) to its hash. The site draws from it; lumen.json and the files under nameplate/lumen/ stay as they are for the games already released, which read nothing else.
  • Titles. net.titles names its parts by foreign key: band_id, effect_id and icon_id, numbers of title_items; a number says nothing of a part's type, so a trigger (title_parts_fit) sees that a band is a band. A title's parts are read by joining them (layerJoins), names and hashes at once, and a statement that writes a title reads it back the same way (written). A title has a band (the plain wood one unless it says), and may have no effect or icon. effect_overflow is its maker's choice of drawing the effect over the whole plate instead of cutting it to the band (false without an effect); the titles from before keep what lumen.json's unclipped gave them. net.title_reviews, which holds a title as it is asked to be, has the same columns. A title's JSON carries them as layers: {band, effect, icon, effectOverflow, ids: {band, effect, icon}, hashes: {band, effect, icon}}: the parts spelt <type>/<name> as before, for the games that find a picture by that name; ids, their numbers; and hashes, where each one's picture is. A request picks the parts by layers.ids and says layers.effectOverflow; nothing else of layers is read, and creating or changing one (PUT /api/v1/admin/titles/{id}, POST/PUT /api/v1/me/titles…) takes layers instead of style: whoever makes a title picks each layer, a player for a private title as a manager for a public one. A part must be one there is, of the layer it is picked for and of the kind player (TITLE_PART_UNKNOWN otherwise), and a body without layers.ids.band is refused (TITLE_INVALID). The names the parts once had on the title itself (band_item, effect_item, icon_item, db/migrations/0022) went with 0030_drop_title_item_names, one release after nothing read them.
  • style stays for the game versions released before the layers, which draw one of six bands and read nothing else. Titles made before keep theirs, and the migration gave each the layers of the set's title of the same name (wood for teal and wood2, which it has none of). A new or changed title gets the six's band nearest its own (legacyStyle: gold, purple and rainbow by name, else wood).
  • A player still wears one title of those they hold (PUT /api/v1/me/nameplate); its layers are how their plate looks.
  • Website. web/src/kit/nameplate-layers.ts reads GET /api/v2/nameplate/set and each picture once from nameplate/items/<hash>.otanim (the visitor's root, then the canonical one), checking its hash; plateSpecs is the game's PlateComposition (a layout's rows in order: the band and its effect in the title's row, an effect cut to the band's shape unless its title says it overflows (effectOverflow; the site no longer reads the set's unclipped, titles or aiTitles), the icon over the outline). web/src/kit/nameplate-renderer.ts draws every plate on a page with one WebGL 2 context into each plate's own canvas, on one clock: a plate out of sight is not drawn, a still one once, and none move when motion is reduced. NameplateArt is the whole plate, TitleBandArt a title on its band alone: the element is exactly the band (what the plain band covers of the plate's canvas), its effect and icon may stand out of it, and the name sits where the plate's layouts put the title on the band; both scale with their size, the text is HTML in the layout's boxes, and without WebGL 2 or the set the text shows alone. web/src/players/components/title-layers-picker.tsx picks a title's layers in /me/titles and /manage/titles from the parts and presets of GET /api/v1/title/items (those of the kind player), all at once from a preset or one by one, and whether the effect overflows the band.

Regional resource distribution

A mainland China visitor (by country alone, DON_GEOIP_DB and trusted proxies; no probe or catalog comparison) reads public files from the mirror https://static.sakura-bot.cn/ourtaiko/, everyone else from the canonical CDN. Version 2 leaves that choice to the client, which asks /api/v2/distribution/source once (see "API versions"); version 1 makes it in its answers: song files (TJA, audio, preview clip, cover, background, MP4) in resource manifests, file redirects and the game's folder covers, the 3D Don's files and reward icons, and the Don and nameplate catalogs' mirrorBaseUrl. A moved song file carries fallbackUrl, and ?origin=1 keeps the canonical address. No API route reads a cover (PUT/DELETE remain). See regional deployment and OSS/ESA policy for configuration, lazy back-to-origin and rollout.

Built-in fonts

The website's settings sheet offers, besides the bundled default (Roboto Flex, then the system's CJK fonts), the built-in fonts listed in web/src/kit/font.ts. They live in the public bucket under fonts/<font>/<version>/ (fonts/misans/4.003/MiSans-VF.ttf, fonts/noto-sans-sc/a85815a/NotoSansSC-VF.ttf, the latter shared with OurTaikoEdit's web version), stored Brotli-compressed (Content-Type: font/ttf, Content-Encoding: br, Cache-Control: public,max-age=31536000,immutable, metadata sha256 of the stored bytes) and never replaced in place: a new version goes in a new folder and the list in font.ts changes with it. A chosen font is fetched from the visitor's root (the mirror for mainland visitors, then the canonical root) without holding up the page, read with FontFace, and put first in the site's font stack (--font-chosen in styles.css) once it has arrived; the choice is kept in the browser (ourtaiko-net-font). Chart pictures drawn by TJARenderer keep their own font stack.

The chart editor

The website's /edit page and every chart's edit page (/<source>/charts/<id>/edit) show OurTaikoEdit's web version (the chart editor, its own repository) inside the site's frame, in an iframe of the bare editor at /edit/app/ (package internal/edit; the page side is web/src/kit/editor-frame.tsx).

OurTaikoEdit publishes each build to the public bucket as a never-changed edit/<build id>/ and names the current one in edit-nightly.json. /edit/app/ reads that manifest (again after a minute; the last build read is kept when a read fails), takes the build's index.html and adds a <base> pointing at the build's folder on the visitor's root (the mirror for mainland visitors, as in Regional resource distribution). The editor's files come from there with CORS; only the page is this site's, so the editor's projects (the browser's IndexedDB) belong to this origin. /edit/app redirects to /edit/app/; any other /edit/app/… is 404.

On a chart's edit page the website hands the chart (its TJA and audio) to the editor and stores what the editor saves through the same review and replacement as the update page (postMessage, ?embed; the messages are listed in OurTaikoEdit's src/OurTaikoEdit.Browser/wwwroot/main.js).

Local development

The backend and the website run side by side on this machine:

scripts/dev.sh                # the backend on http://127.0.0.1:8090
(cd web && pnpm dev)          # the website on http://127.0.0.1:5173, passing /api on

Open http://127.0.0.1:5173 (that address, not localhost: the backend accepts changes only from the origin it is told, APP_ORIGIN, or one of APP_OTHER_ORIGINS for a request that came to that host).

scripts/dev.sh reads .env in this directory, which git ignores. What it needs:

Variable For local development
DATABASE_URL The local database, for example postgres:///ourtaiko_net_dev?host=/tmp&sslmode=disable (made by db/import.sh, or empty after -init)
LISTEN_ADDR, APP_ORIGIN 127.0.0.1:8090 and http://127.0.0.1:5173
APP_OTHER_ORIGINS Usually empty. More addresses of the same site, comma-separated: a request to one of their hosts is answered in it (sign-in, the origin of writes, full addresses). Production uses it for the address in mainland China (deploy/README.md)
STORAGE_DIR Where uploaded files go, for example .data
TJAPARSER_BIN A build of TJAParser v0.18.0, for example kept under .data/tools/
DEV_USER_ID 32 lowercase hex digits. With no account center configured, signing in signs in as this player, who may manage everything. Only accepted on a loopback address

Multi-Enso is off unless these are set as well, in .env or before the command:

Variable For local development
MULTIPLAY_LISTEN_ADDR Where the gRPC service listens, for example 127.0.0.1:50061. With DEV_USER_ID only a loopback address is accepted
MULTIPLAY_PUBLIC_URL What the game is told to dial: http://127.0.0.1:50061 (clear text). Needed locally, as the default is APP_ORIGIN, the website
MULTIPLAY_MIN_PLAYERS 1 to play a round alone; the default is 2
MULTIPLAY_LISTEN_ADDR=127.0.0.1:50061 MULTIPLAY_PUBLIC_URL=http://127.0.0.1:50061 MULTIPLAY_MIN_PLAYERS=1 scripts/dev.sh
curl http://127.0.0.1:8090/api/v1/game/multiplay   # {"url":"http://127.0.0.1:50061","protocol":1,"maxMembers":5}
go run ./tools/multiplay-smoke                     # a whole round alone, every message printed
go run ./tools/multiplay-smoke -do probe           # no session: must answer UNAUTHENTICATED AUTH_REQUIRED
go run ./tools/multiplay-smoke -do token           # the game session of the development user
go run ./tools/multiplay-smoke -do bot -room 12345 -token <another account's session>

Without an account center, the game session of DEV_USER_ID is the SHA-256, in hex, of ourtaiko-dev-game: followed by that ID; it is what POST /api/v1/sources/fanmade/game/login gives the game for any name and password, and it opens Multi-Enso as it opens the /game/ routes. tools/multiplay-smoke (see the top of its main.go) plays the part of a game: round opens a private room and goes through one round alone, which needs MULTIPLAY_MIN_PLAYERS=1; bot enters a room and plays along in every round, as a second player for a game under test. A second player needs a second account, which a server with only DEV_USER_ID does not have: the same account entering a room again replaces its first connection.

The script starts the local PostgreSQL if it is not running and puts ffmpeg on PATH. A database filled from production holds the songs but not their files, which are in the bucket: covers and audio of those songs do not load locally, while anything uploaded locally does.

The plan, the decisions behind it and the work log are in the private notes repository, under OurTaikoNet/.

The database in one paragraph

ourtaiko_net has three schemas. fanmade and official each hold one song source: its charts, files, dan courses, comments, playlists, scores, exactly the tables the old sites had. net holds what the site has once: players, sign-in, roles, titles and nameplates. net.scores and net.dan_attempts are parents over the two sources' tables, so a player's plays across both sources are one query while each source's scores keep their foreign key to that source's charts. See db/README.md.

License

OurTaikoNet (the backend and the website under web/) is free software under the GNU Affero General Public License, version 3 or (at your option) any later version; see LICENSE. As the AGPL asks of a program used over a network, the website links to this source from its settings (About).

The website's frame (the top bar, the side menu and the settings sheet) follows the layout of Moesekai, which is under the AGPL-3.0. web/src/TJARenderer keeps its own MIT license (web/src/TJARenderer/LICENSE).

About

Taiko Fanmade Community

Topics

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Contributors

Languages