Technology stack¶
This document records the technologies, direct third-party dependencies, development tools, hosted services, and external data sources currently selected for the Sport Analytics Tool.
The purpose is to make the project reproducible and auditable. package.json files define the direct JavaScript dependencies selected by the team, while package-lock.json is the authoritative record of the exact versions installed by npm ci.
Stack boundaries¶
The project deliberately keeps the product applications separate:
React frontend
|
| HTTPS requests to the handwritten API
v
Express backend API
|
+--> Supabase Auth for managed identity verification
|
+--> PostgreSQL for application data
|
+--> Private Azure Blob Storage through managed identity
Azure Service Bus --> Node.js worker --> PostgreSQL and private Azure Blob Storage
The frontend may communicate directly with Supabase Auth for managed sign-in and session handling. Application-domain data must pass through the handwritten Express API; generated Supabase Data API endpoints are not used as the application API.
Languages and runtimes¶
| Technology | Project version / requirement | Purpose | Motivation |
|---|---|---|---|
| TypeScript | 5.5.4 |
Primary application language across the frontend, backend, worker and shared packages. | One typed language across all workspaces allows schemas and types to be shared, catches interface errors before runtime, and fits the Node.js/React ecosystem already selected. It is pinned because the current @typescript-eslint version supports TypeScript below 5.6. |
| JavaScript / Node.js | Node.js ^20.19.0 or >=22.12.0; hosted CI and Azure use Node.js 22 LTS |
Executes build tooling, the backend API and the asynchronous worker. | Matches the supported Vite 7 runtime floor while retaining the repository's Node 20/22 family support; hosted CI and Azure remain on Node.js 22 LTS. |
| Python | Project baseline: Python >=3.10 |
Builds the MkDocs documentation and runs the Cricsheet acquisition script. | Python is used only for documentation/data-support tasks; the product applications remain TypeScript/Node.js. The Cricsheet downloader uses only the Python standard library. |
| SQL | PostgreSQL SQL | Defines migrations, constraints and database queries. | Plain SQL keeps schema changes explicit, reviewable and portable between PostgreSQL hosts. |
Frontend¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| React | ^18.3.1 |
Component-based web user interface. | Selected in the initial scaffold for a non-monolithic frontend. No formal framework comparison is currently recorded. |
| React DOM | ^18.3.1 |
Renders React components in the browser. | Required runtime companion to React for the web application. |
| React Router DOM | ^7.18.2 |
Client-side routing and navigation. | Provides route matching and navigation without coupling routing logic to individual components. |
| Vite | ^7.3.6 |
Development server and production frontend build. | Keeps the established Vite workflow while moving off the Vite 5/esbuild advisory path through a controlled supported migration rather than npm audit fix --force. |
@vitejs/plugin-react |
^4.7.0 |
React support in Vite. | Connects the selected React frontend to the Vite build pipeline. |
@supabase/auth-js |
^2.112.1 |
Managed browser authentication and session handling. | Uses only the Supabase Auth client rather than the full supabase-js bundle, because the browser never calls Supabase data endpoints; application data still uses the handwritten API. |
@sport-analytics/contracts |
0.1.0 |
Shared request/response schemas and TypeScript types. | Prevents the frontend and backend from independently redefining the same contracts. Its exact version matches the local workspace package, as enforced by syncpack. |
| Three.js | ^0.185.1 |
Procedural homepage hero enhancement. | Adds one isolated, lazy-loaded 3D delivery-to-statistic metaphor without models, textures, post-processing, backend data or a general UI-animation dependency. |
| Swagger UI React | ^5.33.0 |
Interactive OpenAPI explorer. | Renders the backend-owned OpenAPI 3.1 contract inside the React application without generating endpoints or maintaining a duplicate frontend specification. |
yaml |
^2.9.1 |
Browser-side parsing of the served OpenAPI YAML document. | Parses the authoritative /openapi.yaml response so the explorer can apply implementation-status presentation rules before handing the document to Swagger UI. |
| Fontsource brand families | ^5.3.0 |
Self-hosted approved interface typography. | Packages only Barlow Condensed, IBM Plex Sans and IBM Plex Mono so the approved font roles do not depend on a third-party runtime font request. |
Backend API¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| Express | ^4.21.1 |
Handwritten HTTP API, routing and middleware. | Satisfies the requirement for a separately implemented backend and handwritten API. No formal backend-framework comparison is currently recorded. |
@supabase/supabase-js |
^2.112.1 |
Validates Supabase access tokens on protected backend requests. | Uses the same managed identity platform as the frontend without trusting browser-only claims. |
pg |
^8.22.0 |
PostgreSQL driver and connection pooling. | Keeps database access provider-neutral and communicates with PostgreSQL directly instead of generated Supabase data endpoints. |
| Zod | ^3.23.8 |
Runtime validation and schema-derived TypeScript types. | Shared validation at the API boundary reduces drift between declared types and runtime payload validation. |
| CORS | ^2.8.5 |
Cross-origin request policy. | Explicitly limits which browser origins may call the API. |
| Helmet | ^8.0.0 |
Secure HTTP response-header defaults. | Adds established defensive HTTP headers instead of reimplementing them manually. |
| Pino HTTP | ^10.3.0 |
Structured HTTP request logging. | Produces machine-readable request logs and supports redaction of sensitive headers such as Authorization. |
| dotenv | ^17.4.2 |
Loads ignored local backend environment files. | Keeps local configuration outside committed source while preserving a simple developer setup. |
| Multer | ^2.0.2 |
Parses bounded multipart file uploads for the privileged legacy import route. | Uses established multipart middleware with explicit application limits instead of maintaining a custom multipart parser. Normal submitter uploads use the staged batch pipeline. |
@azure/identity |
4.13.1 |
Supplies DefaultAzureCredential for production Blob access. |
Uses the Azure Container Apps managed identity without Blob account keys, connection strings, SAS tokens, or another application-held storage secret. |
@azure/storage-blob |
^12.27.0 |
Streams retained object bytes to private Azure Blob Storage. | Implements the accepted ADR-011 provider behind the backend-owned ObjectStore boundary. |
@sport-analytics/contracts |
0.1.0 |
Shared API schemas/types. | Keeps backend responses and validation aligned with the shared contract boundary. |
@sport-analytics/batch-processing |
0.1.0 |
Shared batch reference resolution and package processing. | Keeps the staged-batch logic identical in the API and the worker instead of maintaining parallel implementations. |
@sport-analytics/object-storage |
0.1.0 |
Provider-independent streaming object-store interface. | Lets the backend compose the Azure Blob adapter in production and the filesystem adapter locally behind one boundary. |
Asynchronous worker¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| Node.js / TypeScript | Node.js 22 / 5.5.4 |
Separate long-running ingestion process. | Preserves the repository language and an independent failure/deployment boundary. |
@azure/service-bus |
7.9.5 |
Peek-lock job receipt, renewal and settlement. | Implements accepted ADR-010 without connection strings; the managed identity receives from the dedicated queue. |
@azure/identity |
4.13.1 |
Local Azure CLI and deployed managed-identity authentication. | Keeps queue and Blob credentials out of source and environment variables. |
@azure/storage-blob |
^12.27.0 |
Private staged-container access and readiness checks. | Uses the same approved Azure provider as the backend storage adapter. |
pg |
^8.22.0 |
Direct pooled access to authoritative PostgreSQL. | Supports durable checkpoints and idempotent transactions added by worker-processing issues. |
| Zod | ^3.23.8 |
Startup configuration and deployment-probe validation. | Fails invalid or insecure runtime configuration before consuming jobs. |
@sport-analytics/contracts |
0.1.0 |
Shared submission-event schema used to validate each staged delivery. | Applies the same contract as the synchronous API path. |
@sport-analytics/batch-processing |
0.1.0 |
Shared batch reference resolution and package processing. | Guarantees the worker and backend resolve references with one implementation. |
@sport-analytics/object-storage |
0.1.0 |
Provider-independent streaming object-store interface. | Lets the worker read staged packages and write releases through Azure Blob in production or the filesystem locally. |
Shared contracts¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| Zod | ^3.23.8 |
Runtime schemas and TypeScript type derivation. | Allows the same contract definition to be consumed by frontend, backend and tests without storing business logic in the package. |
| TypeScript | inherited from root | Builds the package and emits declarations. | Makes the contracts package usable as a typed workspace dependency. |
Shared server packages¶
| Package | Declared version | Direct runtime dependency | Purpose | Motivation / notes |
|---|---|---|---|---|
@sport-analytics/batch-processing |
0.1.0 |
@sport-analytics/contracts 0.1.0 |
Authoritative batch reference resolver and package-processing logic. | Server-side code that must behave identically in the HTTP API and the separately deployed worker; it must not import from apps/. |
@sport-analytics/object-storage |
0.1.0 |
none | Streaming object-storage interface with opaque keys. | Keeps provider URLs and credentials out of application code; each application composes the Azure Blob or development-only filesystem adapter around it. |
Both packages are built with the repository TypeScript version and tested with Vitest. Their exact versions match the local workspace packages, as enforced by syncpack.
Database and authentication services¶
| Technology / service | Current selection | Purpose | Motivation and alternatives |
|---|---|---|---|
| PostgreSQL | Supabase-hosted PostgreSQL | Persistent application data, event provenance, accounts, scopes, derived statistics and release metadata. | ADR-003 selected PostgreSQL on Supabase for provisioning speed and team familiarity while preserving a standard connection-string boundary. Azure Database for PostgreSQL and Neon were considered as hosting alternatives. |
| Supabase database hosting | Paid-plan Supabase project; session pooler on port 5432 | Hosts PostgreSQL with enough capacity for the planned event dataset. | The project moved away from the storage-constrained original project. The Data API is disabled so generated data endpoints are not available. ADR-005 records the migration decision and its alternatives. |
| Supabase Auth | Managed Supabase Auth; Google is the initial OAuth provider | Sign-up/sign-in lifecycle, OAuth, sessions and token issuance. | ADR-004 selected Supabase Auth after Firebase was superseded, avoiding a second identity platform while preserving the handwritten API boundary. Auth0 and custom authentication were also considered. |
| Supavisor session pooler | Port 5432 | Reliable PostgreSQL connectivity from developer machines and deployment environments. | ADR-003 rejected the direct connection because IPv4 could not be assumed and rejected transaction-mode pooling because prepared statements are required. |
node-pg-migrate |
^9.0.0 |
Applies ordered SQL migrations. | ADR-003 selected explicit SQL migrations and rejected Drizzle Kit at this stage because it would introduce a schema-generation/ORM direction that had not been chosen. |
ADR-005 records the database host and authentication service as separate Supabase project concerns at the time of that decision. If the team later consolidates them into one project or changes account ownership/tier, that change must be recorded separately rather than silently rewriting the historical ADR.
Testing and verification¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| Vitest | ^4.1.11 |
Frontend, backend, worker and shared-package tests. | One test runner across TypeScript workspaces reduces duplicated configuration; v4 is compatible with the retained Node 20 line and uses the newer Vitest pool/coverage architecture. |
embedded-postgres |
^16.14.0-beta.17 |
Default disposable PostgreSQL 16 integration-test runtime. | Runs the real database integration suite on demand without Docker, administrator rights, or a hosted test database. |
| Docker / Docker Compose | Docker Desktop or compatible Compose runtime | Provisions the disposable local PostgreSQL integration-test environment. | Gives each developer an isolated, reproducible database without a hosted test project or shared credentials while keeping normal development independent from Docker. |
| PostgreSQL container image | postgres:16 |
Runs the repository-managed local integration-test database. | Uses the same PostgreSQL major version as CI so local database behaviour closely matches the automated pipeline. |
| React Testing Library | ^16.0.1 |
React component behaviour tests. | Encourages testing through user-observable component behaviour rather than implementation details. |
@testing-library/jest-dom |
^6.6.3 |
DOM-specific assertions. | Improves readability of frontend tests. |
| jsdom | ^25.0.1 |
Browser-like DOM environment for Vitest. | Allows React tests to run without launching a full browser. |
| Supertest | ^7.0.0 |
HTTP assertions against the Express application. | Exercises API behaviour through HTTP without requiring a separately deployed server. |
| Playwright | @playwright/test ^1.62.1 |
Browser end-to-end testing. | Verifies actual navigation and user flows in a real browser engine. |
@axe-core/playwright |
^4.12.1 |
Automated accessibility checks. | Integrates the compatible axe-core engine with Playwright for repeatable detection of serious accessibility violations in browser-level verification. |
@vitest/coverage-v8 |
^4.1.11 |
Test coverage reporting. | Kept on the same major/minor line as Vitest so Issue #578 can build repository-wide coverage on the current V8 remapping behaviour. |
| Ajv | ^8.20.0 |
JSON Schema validation in backend contract tests. | Validates real API responses against the OpenAPI document and the analytics-query JSON Schema, so the published contract cannot drift from the implementation. |
ajv-formats |
^3.0.1 |
Standard string formats for Ajv. | Adds the date-time, uuid, uri and similar formats used by the OpenAPI schemas. |
| Pino | ^9.14.0 |
Logger instance in backend logging tests. | Lets tests capture the structured log lines the backend emits through pino-http and assert what is and is not logged. |
| Lighthouse | ^12.8.2 |
Frontend performance, accessibility and best-practice audits. | Provides repeatable npm run test:lighthouse measurements against representative routes instead of manual browser audits. |
chrome-launcher |
^1.2.1 |
Starts the headless Chrome instance Lighthouse audits. | The supported launcher for running Lighthouse programmatically from repository scripts. |
source-map |
^0.6.1 |
Maps CPU-profile frames back to TypeScript sources. | Used by scripts/profile-route-cpu.mjs so route profiles point at original source lines rather than compiled output. |
Code quality and build tooling¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| ESLint | ^8.57.1 |
Static linting. | Enforces shared code-quality rules before review. |
@typescript-eslint/parser |
^7.18.0 |
Parses TypeScript for ESLint. | Required for TypeScript-aware linting. |
@typescript-eslint/eslint-plugin |
^7.18.0 |
TypeScript lint rules. | Extends ESLint with TypeScript-specific checks. |
eslint-plugin-react-hooks |
^4.6.2 |
React Hooks lint rules. | Detects invalid Hook usage and missing dependency patterns. |
| Prettier | ^3.3.3 |
Repository formatting. | Gives the team one deterministic formatting command and avoids style-only review debates. |
.editorconfig |
repository configuration | Basic editor-independent whitespace/line-ending rules. | Keeps common formatting behaviour consistent even when team members use different editors. |
cross-env |
^10.1.0 |
Cross-platform environment variables in npm scripts. | Keeps database/test scripts usable on Windows and Unix-like systems. |
tsx |
^4.23.7 |
Executes TypeScript backend and worker development and support scripts directly. | Avoids a separate manual compile step for local scripts and watch mode. |
| npm workspaces | npm >=10 |
Monorepo dependency and script orchestration. | Allows the frontend, backend, worker and three shared packages to share one lock file while remaining separate packages. |
| Knip | ^6.32.2 |
Detects unused files, dependencies, exports and types. | Finds monorepo maintenance issues that ordinary builds, tests and lint rules do not expose. |
| syncpack | ^15.3.3 |
Validates dependency-version consistency across npm workspaces. | Prevents package-version drift as contributors change frontend, backend and shared dependencies. |
| dependency-cruiser | ^18.2.0 |
Validates the monorepo source dependency graph and architecture boundaries. | Automates circular-dependency detection and the documented frontend/backend/contracts boundaries rather than relying only on manual Pull Request review. |
| Local CI and Git hook | npm run ci:local, npm run ci:docker, .githooks/pre-push |
Reproduces the change-aware hosted CI plan before a push. | Gives faster feedback than waiting for Gitea Actions; the pre-push hook is optional and installed with npm run hooks:install. See Local CI. |
API documentation tooling¶
| Technology / dependency | Declared version | Purpose | Motivation / notes |
|---|---|---|---|
| OpenAPI | docs/api/openapi.yaml |
Machine-readable public API contract. | Gives API consumers a version-controlled specification independent of implementation code. |
| Redocly CLI | ^2.46.0 |
Lints the OpenAPI specification. | Makes API contract validation part of npm run check. |
Documentation tooling¶
| Technology / dependency | Version / requirement | Purpose | Motivation / alternatives |
|---|---|---|---|
| MkDocs | installed through mkdocs-material requirements |
Builds the public documentation site from Markdown. | Keeps documentation version-controlled alongside the code. Docusaurus and mdBook were course-suggested alternatives; no formal comparison is currently recorded. |
| Material for MkDocs | >=9,<10 |
Documentation theme, navigation and search integration. | Adds a readable documentation UI without requiring the team to build a docs frontend. |
| Cloudflare Pages | hosted service | Publicly hosts the generated MkDocs site/ output. |
Already deployed and independently accessible; avoids an account-gated documentation platform. |
| Wrangler | ^4.119.0 |
Deploys the generated documentation site to Cloudflare Pages. | Provides a repeatable CLI deployment command suitable for local use and future automation. Because it is invoked through the documented npx wrangler command rather than imported by source, the root Knip workspace has a dependency-specific exception for it. Wrangler is not used to deploy the React frontend or Express backend. |
Deployment, collaboration and CI/CD¶
| Technology / service | Purpose | Motivation / notes |
|---|---|---|
| Git | Version control. | Required project history and traceability mechanism. |
| Gitea | Repository hosting, issues, Pull Requests, project board and milestones. | University-hosted collaboration platform used as the authoritative project record. |
| GitHub Flow adapted for Gitea | Branch/PR methodology. | Selected over Git Flow to keep review and traceability without permanent develop/release branches. See docs/git-methodology.md. |
| Gitea Actions | Continuous integration and change-aware deployment workflows. | Keeps automated checks and deployment definitions in the same repository. |
| Azure Container Apps | Hosts the Express backend API and asynchronous worker. | The supported backend and worker paths use immutable ACR images, Bicep, managed identities and Key Vault references. Historical Azure App Service is not current hosting. |
| Cloudflare Pages | Hosts the React frontend and public documentation. | Serves independently deployed static Vite and MkDocs output through Wrangler-based workflows. |
External data and integrations¶
| Source / service | Current use | Notes |
|---|---|---|
| Cricsheet | Historical event-level T20/IT20 JSON data source. | Downloaded by scripts/download_cricsheet_t20.py; generated bulk data remains ignored. Cricsheet is a historical file/data source rather than the course-required runtime external API integration. |
| Google OAuth | Identity provider through Supabase Auth. | Provides the initial managed OAuth sign-in path. OAuth client secrets remain in provider dashboards and are never committed. |
| Open-Meteo | Runtime external weather API integration. | Selected in ADR-008 and called server-side by the Express backend through GET /api/v1/weather. It requires no API key. Provider failures are isolated to the weather feature through validation, timeout and error handling. |
| Anthropic Claude | Runtime language-model translation for natural-language analytics queries. | Claude Haiku 4.5 (claude-haiku-4-5-20251001), selected in ADR-017 and called server-side through POST /api/v1/natural-language-queries. It requires a server-only API key held in Key Vault. Provider failures are isolated to this feature: an absent key disables natural-language querying and nothing else. |
Anthropic Claude: what is sent, what it costs and why it was selected¶
The natural-language query feature is the project's one language-model integration, and it is the only third-party service that receives text a user typed. The complete decision is ADR-017; the disclosure below is the summary this document is required to carry.
Purpose. Translation only. The model converts a question into a query definition that must satisfy a closed contract. It computes no statistic: a validated definition is answered from the published statistics by existing hand-written code. The contract, not the provider, decides what the platform will act on.
Data sent. Exactly four things, asserted by a test that fails if a fifth appears:
- the query-definition contract's own schema description;
- a fixed sentence framing the next message as data;
- the reader's question text, between delimiters; and
- since #868, the caller's earlier questions and the definitions they were read as, as prior context.
No cricket data, identifier, column name, table name, SQL statement, credential, account detail or information about who asked is sent. A test runs a forbidden-token list over a request built with a maximum-length conversation. The question text itself is the one substantive privacy consequence and is disclosed to the reader before they submit a question.
Spending limit. A dedicated Anthropic Console workspace for this project with a $10 monthly spend limit, and an API key scoped to that workspace. The limit is the control rather than a forecast: it caps the blast radius of a loop, a leaked key or a load test at $10 instead of at the account balance. At roughly $0.0060 a question that is about 1,670 questions a month. Both the limit and the workspace-scoped key must exist before the feature is enabled in a deployed environment.
Reason for selection. Claude Haiku 4.5 at $1/$5 per million tokens was chosen over cheaper
candidates — Gemini 3.1 Flash-Lite and OpenAI GPT-5 Nano were both priced lower — because cost is not
the binding constraint against a $10 ceiling, and the alternatives each required a new cloud project,
billing setup and a second credential path. An existing team member's Anthropic account removed
payment and account-setup risk, which at this point in the project was a schedule risk rather than a
cost one. The model supports the native structured-output mode the closed contract needs. Switching
provider is one environment variable: LLM_MODEL carries the identifier and no sampling parameter is
sent, with Claude Sonnet 5.5 recorded as the named fallback.
Type-only support packages¶
The following direct packages provide TypeScript declarations for JavaScript libraries or runtimes. They do not add separate runtime behaviour:
@types/react ^18.3.12@types/react-dom ^18.3.1@types/three ^0.185.4@types/swagger-ui-react ^5.18.0@types/cors ^2.8.17@types/express ^4.17.21@types/node ^22.9.0@types/pg ^8.20.4@types/multer ^2.0.0@types/supertest ^6.0.2
Version policy¶
package-lock.jsonis committed and defines the exact JavaScript dependency graph used bynpm ci.- Developers must use
npm cifor clean-clone verification and CI-equivalent checks. - Direct dependencies must not be added without a clear project purpose.
- Significant technology changes require a Gitea issue and, where they affect architecture, a decision record.
- New third-party code/services must be added to this document and to the relevant specialist documentation.
- Dependency upgrades must be tested before merge.
Editor and operating-system policy¶
No IDE or operating system is required by the repository. The setup guide provides Windows PowerShell and Unix-like command equivalents where the command differs. Team members should record the OS, terminal/shell, editor/IDE and exact tool versions used during onboarding verification so the team can identify environment-specific problems without making one editor a project dependency.
AI tooling¶
AI usage is governed separately by the course AI policy and the repository AI evidence process. The root README records the repository-level AI code-generation, inline-editing and code-review declarations, while task-level tool/model/purpose records and transcripts are stored under evidence/ai/.
AI Declaration¶
The preceding document was planned, generated, reviewed and edited with the assistance of ChatGPT-Web[GPT-5.6 Sol]. The issue #314 Three.js and self-hosted font dependency records were updated with the assistance of Codex[GPT-5.6 Sol]. The Anthropic Claude provider record was added with the assistance of Claude-Code[Claude Opus 5 (1M context)] under issue #817, summarising ADR-017 rather than restating the integration. The Azure Blob Storage and managed-identity dependency records were updated with the assistance of Codex[GPT-5]. The asynchronous worker runtime and Service Bus dependency records were updated with the assistance of Codex[GPT-5]. The Issue #364 current-state technology wording was reviewed and edited with the assistance of ChatGPT-Web[GPT-5.6 Sol]. The Issue #297 Multer dependency record was reviewed and added with the assistance of ChatGPT-Web[GPT-5.6 Sol]. The Issue #660 Swagger UI React and YAML dependency records were reviewed and added with the assistance of ChatGPT-Web[GPT-5.6 Sol]. The Issue #888 current hosting-stack entries were corrected with the assistance of Codex[GPT-5]. The Issue #890 Azure managed-identity attribution was corrected with the assistance of Codex[GPT-5]. The Issue #879 review reconciled every declared dependency range with the workspace manifests, added the shared server packages and the undocumented testing and profiling tools, and repaired the Node.js table row with the assistance of Claude-Web[Claude Opus 5.5].