Overview
d-sports-api (package name:d-sports-pwa) is the live application: a Progressive Web App that provides the full fan engagement experience. It is both the production backend and the web client.
- Default port: 3004
- Run:
infisical loginonce, thenbun dev - App version: 0.2.0
Tech stack
Every
dev / db:* / build script runs through infisical run --env=<env>. You do not copy .env files by hand.Features
- Locker room — Social feed, posts, comments, reactions, likes, drafts, lineup attachments, follows, per-post get/update/delete
- Gamification — Quests, points, achievements, leaderboards, Frontline Pass, daily quiz sessions
- Fan Rep — Append-only
RepLedgerEntrywith Fan, Club, and Player sources - Digital collectibles — Rarity-tiered collectibles, pack opening, inventory, featured showcase
- Shop — Product catalog, cart, RevenueCat and crypto checkout, D-Sports Cash
- Wallet — Custodial Thirdweb wallets, PIN gates, server-side transaction signing
- Interactive games — Team-selected catalog (daily spin, guess-the-player, live games) plus the Game Engine for Pick’em, Trivia, air hockey, and the locker-singularity idle ledger
- Team manager dashboard — Collectible creation, bulk upload, packs, analytics, revenue
- Admin — Impersonation, roles (SuperAdmin, Admin, TeamManager), user management
What changed since last docs sync
- OpenAPI is 252 paths, synced from
d-sports-apimain(e9a8d95). New published surfaces: HQ starred teams,GET /api/teams/{id}, the locker-singularity idle ledger, and wallet attestation at/api/wallets/{address}/attestation(the path value is the wallet database id).PUT /api/packs/{id}/purchaseis in the spec as removed (410); confirm withPOST /api/checkout/crypto/verify.GET /api/user/allstays out of this spec until d-sports-api#738 merges. - HQ stars (
/api/me/starred-teams) are bookmarks, not follows, with a 50-club cap. - Binder PIN is a short-lived token:
POST /api/binders/{id}/verify-pinreturns{ granted, token, expiresIn: 300 }. Sendx-binder-pin-tokenonGET /api/binders/{id}or PIN binders return403 PIN_REQUIREDwithout shelves. - Sports catalog, team search, slug lookup, roster, and leaderboard join/leave are in OpenAPI.
TeamFollowstays social-only. POST /api/locker-roompersistslineupand allows attachment-only posts.authorTeamId(aliaspostAsTeamId) is distinct from the about-tagteamIdand returns403when unauthorized.- Marketplace pack listing rejects
processingpurchases with409 PACK_NOT_LISTABLE. Nativelistings/minealiasesme/listings. - Unknown
/api/*paths return JSON404, not the HTML app 404. - Secrets moved to Infisical. HashiCorp Vault is no longer the documented local path.
- Prisma is 7.9.1.
- Custodial wallets sign on the server.
POST /api/wallets/private-keyis deprecated and PIN-gated. - Fan Rep is a first-class ledger.
dsportsDirectRepsumsrepType = Directrows from admin grants.
Getting started
- Clone the repository and install dependencies (
bun install). - Run
infisical loginonce sobun devandbun db:*can inject secrets. - Pull and generate Prisma:
bun db:pullthenbun db:gen. - Run
bun dev— app is at http://localhost:3004.
docs/ folder. Do not copy in-repo AGENTS.md into this site.
API
This app is the primary API surface for the D-Sports platform. The API reference covers endpoints and usage. The generated spec is synced from the API repo’sopenapi.json — do not edit api-reference/openapi.json by hand.
Season 0.5 leaderboard infrastructure
- Points events are scoped in
PointsHistoryby both leaderboard and season. - Season reset/wipe behavior is unchanged.
- Legacy Season 0 rows with null scoping are intentionally preserved for backward compatibility.
Leaderboard scoring behavior
- Team boards compute totals from
PointsHistoryrows filtered by both activeseasonIdand the teamleaderboardId. - The global board computes totals from
PointsHistoryrows filtered by activeseasonIdonly (cross-board season aggregate). - New point writes (quests, onboarding, daily actions, backfill scripts) include
seasonIdandleaderboardIdwhere available. - Some historical/backfill paths can intentionally write
leaderboardId: nullwhen a board cannot be determined yet. - Legacy Season 0 rows with null season/board scope remain in storage and are intentionally excluded from Season 0.5+ scoped calculations.
API contract notes
GET /api/leaderboard?leaderboardId=<id>resolves and scores a specific board.GET /api/leaderboard?teamId=<teamId>resolves (or creates) that team board, then scores it.GET /api/leaderboard(no params) returns global leaderboard scoring for the active season.- This release does not introduce season reset/archiving behavior changes, and does not remove
LeaderboardEntry.pointsyet (planned Season 2 cleanup).
Gamification deep dives
Gamification docs hub
Architecture and behavior across quests, points, leaderboards, rewards, and achievements.
Fan Rep
Ledger-backed Fan, Club, and Player Rep totals and earn rules.
Games
Public team mini-game catalog and play-route coverage.
Game Engine
Modular daily mini-games: client, server, and how you add a game.
Backend coverage status
What is documented vs missing across non-admin backend domains.
Backend domain deep dives
Auth and onboarding
Session/auth boundaries, mobile exchange, profile lifecycle, and onboarding.
Social and locker room
Posts, comments, reactions, follow graph, and per-post CRUD.
Commerce and purchases
Catalog, checkout, purchases, dsports-cash, and entitlement flows.
Collectibles and packs
Pack lifecycle, featured collectibles, inventory, and minting paths.
Wallet and web3
Custodial wallets, PIN gates, and server-side signing.
Moderation and reporting
User-facing report intake and moderation model lifecycle.
Platform and infrastructure
Streams, sync routes, backfills, and non-admin operational patterns.
Backend coverage status
Track what is documented, partial, or not yet documented.
Admin and team management surfaces (public-safe)
Admin and team management
RBAC model, route map, and public-safe implementation guidance.
Teams and leagues pipeline
Canonical data sync, webhook flow, and downstream API behavior.
Compliance and legal: pack opening odds
Compliance and legal docs
Backend implementation and policy-alignment guidance for randomized pack disclosures.
Ecosystem overview
See how d-sports-api fits with the site, native app, and Mic’d Up.
