game-library

module
v0.0.0-...-90c44de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2025 License: MIT

README

game-library

Introduction

game-library is a web application for exploring and rating games. It consists of three services:

  • current service is responsible for fetching, storing games data and providing it to UI,
  • auth service is responsible for user authentication and authorization,
  • ui service is responsible for UI representation.

Table of Contents

Installation

Prerequisites: go, Docker, Make. To set up the service, follow these steps:

  1. Clone the repository:

    git clone https://github.com/OutOfStack/game-library.git
    cd game-library
    
  2. Set up the database:

    make drunpg # runs postgres in docker container
    make createdb # creates db
    make migrate # applies migrations
    # optionally
    make seed # applies test data
    
  3. Install and run dependencies:

    make drunredis # [Optional] runs redis in docker container
    make drunzipkin # [Optional] runs zipkin in docker container
    make drunglog # [Optional] runs graylog in docker container
    make drunprom # [Optional] runs prometheus in docker container
    
  4. [Optional] Set up fetching games data:

    • Get credentials from IGDB API to run background task that fetches games
    • Get S3 compatible storage, for example AWS S3 or Cloudflare R2 for uploading game images
  5. [Optional] Install auth service for using handlers that require authentication

  6. Create the app.env file based on ./app.example.env and update it with your local configuration settings.

  7. Build and run the service:

    make build
    make run
    

Optional steps are not required for minimal install but required for full functionality.

Refer to the List of Make commands for a complete list of commands.

Usage

After installation, you can use the following Make commands to develop the service:

  • make test: Runs tests.
  • make generate: Generates documentation for Swagger UI and mocks for testing.
  • make lint: Runs golangci-lint for code analysis.

Refer to the List of Make commands for a complete list of commands.

Tech Stack and Integrations

  • Data storage with PostgreSQL.
  • Caching with Redis.
  • Tracing with Zipkin.
  • Log management with Graylog.
  • Background fetching of game data from IGDB.
  • Reuploading game images to Cloudflare R2 storage.
  • Code analysis with golangci-lint.
  • CI/CD with GitHub Actions and deploy to Kubernetes (microk8s) cluster.

Configuration

Documentation

API documentation is available via Swagger UI. For regenerating documentation after swagger description change run:

make generate

Examples

Endpoint that returns 3 games ordered by release date:

curl -X GET "http://localhost:8000/api/games?pageSize=3&page=1&orderBy=releaseDate"

To see other examples of API endpoints, refer to the documentation.

List of Make commands:

Main Commands
build         builds app
build-mng     build manage app
run           runs app
test          runs tests for the whole project
generate      generates docs for swagger UI and mocks for testing
lint          runs golangci-lint
cover         outputs tests coverage
Database Commands
drunpg        runs postgres server in docker container
createdb      creates database on postgres server started by 'dockerrunpg'
dropdb        drops database on postgres server created by 'dockerrunpg'
migrate       applies all migrations to database
rollback      rollbacks last migration on database
seed          seeds test data to database
Docker Commands
dbuildapi     builds app docker image
dbuildmng     builds manage app docker image
drunapi       runs app in docker container
drunzipkin    runs zipkin in docker container
drunredis     runs redis in docker container
drunglog      runs graylog in docker container
drunprom      runs prometheus in docker container

License

MIT License

Directories

Path Synopsis
cmd
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
app/game-library-api/api/mocks
Package api_mock is a generated GoMock package.
Package api_mock is a generated GoMock package.
app/game-library-api/facade/mocks
Package facade_mock is a generated GoMock package.
Package facade_mock is a generated GoMock package.
auth/mocks
Package auth_mock is a generated GoMock package.
Package auth_mock is a generated GoMock package.
middleware/mocks
Package middleware_mock is a generated GoMock package.
Package middleware_mock is a generated GoMock package.
pkg/cache/mocks
Package cache_mock is a generated GoMock package.
Package cache_mock is a generated GoMock package.
pkg/td
Package td contains functions for data testing
Package td contains functions for data testing
taskprocessor/mocks
Package taskprocessor_mock is a generated GoMock package.
Package taskprocessor_mock is a generated GoMock package.
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL