game tracker api


A RESTful API built with Node.js, Express, and TypeScript to track your video game collection and backlog. Features clean layered architecture, Swagger documentation, and Joi validation.

Languages

Technologies

0 1 March 17, 2026

# README.md

๐ŸŽฎ Game Tracker API

A RESTful API for tracking your video game collection and backlog, built with Node.js, Express, and TypeScript.

Based on this awesome repository by Marcio Zabeu. Created with love (and knowledge).

๐Ÿ“‹ Table of Contents


โœจ Features


  • Game Collection Management: Add, view, search, and delete games from your collection
  • Status Tracking: Track your gaming progress with states: backlog, playing, completed
  • Multi-Platform Support: Track games across classic platforms (NES, SNES, Mega Drive, GameBoy, PS1, N64)
  • Input Validation: Comprehensive request validation using Joi schemas
  • Swagger Documentation: Interactive API documentation with Swagger UI
  • Clean Architecture: Layered architecture with Controllers, Services, and Repositories
  • TypeScript Support: Full type safety with TypeScript
  • Graceful Shutdown: Proper server shutdown handling

๐Ÿ›  Tech Stack


TechnologyPurpose
Node.jsRuntime environment
Express 5Web framework
TypeScriptType-safe JavaScript
SequelizeORM for database operations
PostgreSQLRelational database
JoiRequest validation
SwaggerAPI documentation
DockerDatabase containerization

๐Ÿ“ Project Structure


game-tracker-api/
โ”œโ”€โ”€ postgresql/
โ”‚   โ””โ”€โ”€ compose.yaml          # Docker Compose for PostgreSQL
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app.ts                # Express application setup
โ”‚   โ”œโ”€โ”€ server.ts             # Server entry point
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”œโ”€โ”€ database.ts       # Sequelize database configuration
โ”‚   โ”‚   โ”œโ”€โ”€ env.ts            # Environment variables
โ”‚   โ”‚   โ””โ”€โ”€ swagger.ts        # Swagger documentation setup
โ”‚   โ”œโ”€โ”€ controllers/
โ”‚   โ”‚   โ””โ”€โ”€ game/             # Game controller (request handling)
โ”‚   โ”œโ”€โ”€ docs/
โ”‚   โ”‚   โ””โ”€โ”€ game.docs.yaml    # OpenAPI/Swagger documentation
โ”‚   โ”œโ”€โ”€ helpers/
โ”‚   โ”‚   โ””โ”€โ”€ apiError.ts       # Custom API error handler
โ”‚   โ”œโ”€โ”€ middlewares/
โ”‚   โ”‚   โ”œโ”€โ”€ error.ts          # Global error middleware
โ”‚   โ”‚   โ”œโ”€โ”€ logger.ts         # Request logger middleware
โ”‚   โ”‚   โ””โ”€โ”€ validation/       # Validation middlewares (body, param, query)
โ”‚   โ”œโ”€โ”€ repositories/
โ”‚   โ”‚   โ””โ”€โ”€ game/             # Game data access layer
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ””โ”€โ”€ game/             # Game routes definition
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ”‚   โ””โ”€โ”€ game/             # Joi validation schemas
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ game/             # Business logic layer
โ”‚   โ””โ”€โ”€ types/
โ”‚       โ””โ”€โ”€ game/             # TypeScript type definitions
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ README.md

๐Ÿ“ฆ Prerequisites


  • Node.js v18 or higher
  • npm or yarn
  • Docker (for PostgreSQL database)

๐Ÿš€ Getting Started


1. Clone the Repository

git clone https://github.com/your-username/game-tracker-api.git
cd game-tracker-api

2. Install Dependencies

npm install

3. Start PostgreSQL with Docker

cd postgresql
docker compose up -d

This will start a PostgreSQL container with:

  • Database: game_tracker_db
  • User: admin
  • Password: admin123
  • Port: 5432

4. Configure Environment Variables

Create a .env file in the root directory:

PORT=3000
NODE_ENV=development

# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=game_tracker_db
DB_USERNAME=admin
DB_PASSWORD=admin123

5. Start the Development Server

npm run dev

The server will start on http://localhost:3000 with hot-reload enabled.

6. Access API Documentation

Open your browser and navigate to: http://localhost:3000/api-docs

๐Ÿ”Œ API Endpoints


Games

MethodEndpointDescription
GET/gamesGet all games
POST/gamesAdd a new game
DELETE/games/:idDelete a game by ID
GET/games/searchSearch games with filters
PATCH/games/:id/statusUpdate game status

Request/Response Examples

Add a New Game

POST /games
Content-Type: application/json

{
  "title": "Super Mario World",
  "year": 1990,
  "platform": "SNES",
  "genre": ["Platformer", "Adventure"],
  "status": "backlog"
}

Search Games

GET /games/search?platform=SNES&status=playing

Update Game Status

PATCH /games/:id/status
Content-Type: application/json

{
  "status": "completed"
}

Game Statuses

StatusDescription
backlogGames you own but haven't started
playingGames you're currently playing
completedGames you've finished

Supported Platforms

  • NES
  • SNES
  • Mega Drive
  • Gameboy
  • PS1
  • N64

๐Ÿ” Environment Variables


| Variable | Description | Default | |-|-|| | PORT | Server port | 3000 | | NODE_ENV | Environment mode | local | | DB_HOST | PostgreSQL host | localhost | | DB_PORT | PostgreSQL port | 5432 | | DB_NAME | Database name | - | | DB_USERNAME | Database user | - | | DB_PASSWORD | Database password | - |

๐Ÿ“š API Documentation


Interactive API documentation is available via Swagger UI at /api-docs when running in development mode.

You can also access the raw OpenAPI specification at /docs.json.

๐Ÿ— Architecture Overview


The project follows a layered architecture pattern:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Routes                           โ”‚
โ”‚         (Define endpoints & middlewares)            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Controllers                         โ”‚
โ”‚     (Handle HTTP requests/responses)                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Services                           โ”‚
โ”‚         (Business logic & validation)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                Repositories                         โ”‚
โ”‚            (Data access layer)                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Principles

  • Separation of Concerns: Each layer has a single responsibility
  • Dependency Injection: Services and repositories are injected via factory functions
  • Type Safety: Full TypeScript support with strict types
  • Validation: All inputs validated at the middleware level using Joi

๐Ÿ“ TODO / Roadmap


  • Integrate PostgreSQL: Replace in-memory storage with Sequelize models connected to PostgreSQL
  • Create Docker Image: Add Dockerfile for the API and multi-container docker-compose setup
  • Add More Operations:
    • Get single game by ID (GET /games/:id)
    • Update game details (PUT /games/:id)
    • Bulk operations (add/delete multiple games)
    • Pagination support for list endpoints
    • Sorting and advanced filtering
  • IGDB Integration: Integrate with the IGDB API to:
    • Auto-fill game metadata (title, genres, platforms, cover art) by searching IGDB
    • Validate game data against IGDB records on creation
    • Sync additional game info (summary, release dates, ratings, screenshots)
  • Additional Features:
    • User authentication & authorization
    • Game ratings and reviews
    • Screenshots/cover art storage
    • Export/import game lists
    • Statistics dashboard (games by status, platform, etc.)
  • Testing:
    • Unit tests with Jest
    • Integration tests
    • E2E tests
  • CI/CD:
    • GitHub Actions pipeline
    • Automated testing on PR
    • Deployment automation

๐Ÿ‘ค Author


Leonardo Silvatti