- π What is this API ?
- π¨ Installation
- π Build
- π³ Docker
- π― Tests
- βοΈ Code analysis and consistency
- π Releases & Changelog
- β¨ Misc commands
- π Documentation
- Β©οΈ License
- β€οΈ Contributors
Goat It API is the headless backend that stores and serves the quiz content β questions and question themes β for the Goat It game.
To install this project, you will need to have on your machine :
π Click on the badges above to go to the corresponding website.
- Node.js β the required floor is declared in package.json (
engines.node) and the version used by CI and tooling is pinned in configs/node/.node-version. - pnpm β the exact version is declared in package.json (
packageManager). - MongoDB β a reachable instance; a local server on port
27017is enough, and the optional Docker command below starts one. - Docker β optional for development (the MongoDB command below) and required for the acceptance-test MongoDB and the Docker image builds.
Then, install the dependencies and Husky hooks :
# Install dependencies and Husky hooks
pnpm install# Create your local environment file
cp env/.env.example env/.envenv/.env is git-ignored and is loaded when NODE_ENV is unset. Replace the three authentication placeholders with your own values:
API_KEY_HMAC_SECRETβ at least 32 charactersADMIN_API_KEYandGAME_API_KEYβ at least 24 characters each
Start a MongoDB instance and keep MONGODB_HOST/MONGODB_PORT pointed at it. For example:
# Start a local MongoDB for development (port 27017)
docker run -d --name goat-it-mongodb -p 27017:27017 mongo:9The example file uses MONGODB_HOST=0.0.0.0, a bind-style address; if your MongoDB only listens on loopback, set MONGODB_HOST=127.0.0.1. Do not point the dev server at the disposable acceptance-test container.
# Run the app in dev mode
pnpm run start:devThe API listens on http://localhost:3000 (SERVER_PORT) and serves the Swagger UI at http://localhost:3000/docs.
The dev server compiles with SWC and executes the output through the tsx/esm loader, so the path aliases and extensionless imports resolve on Node ESM.
The API is built using SWC to provide faster and more reliable builds, and runs as native ESM ("type": "module"). The build also runs tsc-alias to resolve the path aliases and append the .js extensions ESM requires.
To build the app for production, run the following command :
# Build the app
pnpm run build
# Run the app in production mode
pnpm run start:prodProduction mode reads the process environment only: env/.env is not loaded (ignoreEnvFile), so export the required variables before pnpm run start:prod.
This app is Docker ready!
The Dockerfile is available at the root of the project. It uses a multi-stage build to optimize the image size and performance.
# Build the app using Docker on linux/arm64
pnpm run docker:build:linux/arm64
# Build the app using Docker on linux/amd64
pnpm run docker:build:linux/amd64Run these five commands in this order before opening a PR. CI runs the same gates, with lint in check mode and the CI mutation profile.
pnpm run lint:fix
pnpm run typecheck
pnpm run test:unit:cov
pnpm run test:mutation
pnpm run test:acceptanceThe acceptance gate needs the disposable MongoDB: run pnpm run docker:acceptance-tests:start before the sequence (see Acceptance tests below).
This project uses Vitest for unit tests and is covered by 100% of its code.
All related test files are located in the src/ directory, alongside the code they test, suffixing the file name with .spec.ts.
# Run unit tests
pnpm run test:unit
# Run unit tests in watch mode
pnpm run test:unit:watch
# Run unit tests in coverage mode β used in CI pipelines
pnpm run test:unit:covThis project uses Cucumber for acceptance tests.
All related files scenarios and features are located in the tests/acceptance directory.
The suite needs the disposable MongoDB container:
# Start the acceptance-test MongoDB
pnpm run docker:acceptance-tests:start
# Run acceptance tests
pnpm run test:acceptancepnpm run docker:acceptance-tests:stop stops the container and keeps its volume; pnpm run docker:acceptance-tests:reset discards the volume and starts a fresh MongoDB.
This project uses Stryker for mutation testing with 100% coverage (mutation score).
# Run mutation tests
pnpm run test:mutation
# Run mutation tests without incremental file (can be longer)
pnpm run test:mutation:forceThis project uses Oxlint and ESLint for code linting and formatting with over 500 rules activated.
# Run code linting with both Oxlint and ESLint
pnpm run lint
# Run code linting with Oxlint only
pnpm run lint:oxlint
# Run code linting with ESLint only
pnpm run lint:eslint
# Run code linting with Oxlint and ESLint and fix issues
pnpm run lint:fix
# Inspect ESLint configuration
pnpm run lint:eslint:inspect-configMultiple tools are set up to maintain the best code quality and to prevent vulnerabilities :
You can check the CodeQL analysis report here.
SonarCloud summary is available detailed metrics.
Releases on the main branch are generated and published automatically by :
It uses the conventional commit strategy.
Each change when a new release comes up is listed in the Changelog.
Also, you can keep up with changes by watching releases via the Watch GitHub button at the top of this page.
pnpm run script:create-branchpnpm run script:create-pull-requestpnpm run script:clean-pr-description <pr-number>This script removes numbered diffhunk links (e.g., [[1]](diffhunk://...)) from a PR description. These links are automatically generated by GitHub Copilot but can clutter the summary. A GitHub Actions workflow automatically runs this script when PRs targeting develop are opened or edited.
- Architecture and file-placement conventions β where every file belongs, how it is named and what may depend on it.
- JSDoc guide β JSDoc scope, concise-TSDoc style, examples and enforcement.
- API contract β HTTP surface, DTO and error conventions, Swagger and the published schemas package.
- Data model β MongoDB collections, fields, indexes, references and migration posture.
- Domain logic β question and question-theme domain rules, invariants and error contracts.
- Performance β indexing, query patterns, pagination and payload bounds.
- Internationalization β
Accept-Languagepipeline, locales, fallback and translation completeness. - Security β authentication, validation, CORS, secrets, disclosure and known limitations.
- Dependencies β scoped overrides, duplicate-major inventory and dependency-audit policy.
- Privacy β data inventory, logging and telemetry PII policy, retention and legal posture.
- Operations β health/readiness contract, container health check, graceful shutdown and post-deploy verification.
- CI/CD, branching and release workflow β branches, commits, hooks, pull requests, CI and deployment.
- Release procedure β step-by-step maintainer checklist for publishing a version.
- Package scripts β every
pnpm runscript, grouped by purpose, with internal hook/CI-only entries marked. - Bruno collection β API collection setup and usage.
- Unit tests β Vitest conventions per file type.
- Acceptance tests β Cucumber, fixtures, payloads and steps.
- Faketories β shared test-data factories.
- Mocks β typed unit-test mock factories.
The tests/**/README.md files are short pointers to these guides.
This project is licensed under the MIT License.
There is no contributor yet. Want to be the first?
Don't hesitate to browse the issues and pull requests to see what's coming up next.
If you want to contribute to this project, please read the CONTRIBUTING.md file for guidelines and our Code of Conduct.