game-library is a web application for exploring and rating games.
game-library consists of:
- current service is responsible for fetching, storing games data and providing it to UI
- game-library-auth - authentication and authorization
- game-library-ui - UI service
- game-library-infra - infrastructure and deployment configurations
- Introduction
- Installation
- Usage
- Tech Stack and Integrations
- Configuration
- Documentation
- Examples
- Contributing
- List of Make commands
- License
Prerequisites: go, Docker, Make
To set up the service, follow these steps:
-
Clone the repository:
git clone https://github.com/OutOfStack/game-library.git cd game-library -
Set up the database:
make drunpg # runs postgres in docker container make migrate # applies migrations # optionally make seed # applies test data
-
Install and run dependencies:
make drunredis # runs redis in docker container -
[Optional] Set up fetching games data:
- Get credentials from IGDB API to run background tasks that fetch and update games
- Get S3 compatible storage, for example AWS S3 or Cloudflare R2 for uploading game images
- Get an API key from OpenAI for automatic game moderation functionality
-
[Optional] Launch auth service for using handlers that require authentication
-
Create the
app.envfile based on./app.example.envand update it with your local configuration settings. -
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.
After installation, you can use the following Make commands to develop the service:
make test: Runs tests.make generate: Generates proto files, 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.
- Data storage with PostgreSQL.
- Caching with Redis.
- Background task for fetching and updating games data using IGDB API.
- Game image upload and storage with S3-compatible services (Cloudflare R2).
- Automatic game moderation using OpenAI API.
- gRPC for internal service-to-service communication.
- Tracing with OTLP exporter (Jaeger).
- Log management with Graylog.
- Metrics collection with Prometheus.
- Code analysis with golangci-lint.
- CI/CD with GitHub Actions and deploy to Kubernetes (microk8s) cluster.
- The service can be configured using
app.envor environment variables, described insettings.go - CI/CD configs are in
./github/workflows/ - k8s deployment configs are in
./k8s
API documentation is available via Swagger UI. To generate the documentation, run:
make generateThe service exposes a gRPC endpoint for internal service-to-service communication.
Endpoint: localhost:9000 (APP_GRPC_ADDRESS environment variable in app.example.env)
Protobuf Definition: api/proto/infoapi/v1/infoapi.proto
Testing with grpcurl:
# list services
grpcurl -plaintext localhost:9000 list
# describe service
grpcurl -plaintext localhost:9000 describe infoapi.v1.InfoApiService
# call CompanyExists method
grpcurl -plaintext -d '{"company_name": "Nintendo"}' -emit-defaults localhost:9000 infoapi.v1.InfoApiService/CompanyExistsEndpoint 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.
Commit message and release rules are documented in CONTRIBUTING.md.
build builds app
build-mng build manage app
run runs app
test runs tests for the whole project
generate generates proto files, docs for swagger UI and mocks for testing
lint runs golangci-lint
cover outputs tests coverage
drunpg runs postgres server in docker container
migrate applies all migrations to database (reads from config file)
rollback rollbacks last migration on database (reads from config file)
seed seeds test data to database (reads from config file)
dbuildapi builds app docker image
dbuildmng builds manage app docker image
drunapi runs app in docker container
drunredis runs redis in docker container