badboyd / wager-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wager App

Using Docker

Verify docker build using integration tests

It will use docker-copose.test.yaml and Dockerfile.test to run integration tests.

Run following command to run integration test using docker.

  • docker-compose -f docker-compose.test.yaml up --build --abort-on-container-exit --force-recreate

    • OR using make: make docker-verify

Run

  • At root of project, run docker-compose up or docker-compose up -d in detach mode.
    • OR using make: make docker-run
  • Note: Recreate volumes if database is not created in container while docker up: docker-compose up -V

Without Docker

How to set up and run locally without docker.

Prerequisites

  • Golang version 1.6 and above
  • Postgres version 14 and above

For development

  • Install mockery v2 latest version as per doc
    • Required for generating mocks from interfaces for writing new unit tests.
    • Not needed to run application

Setup

  1. Make changes to .env values as per your config and requirements.
  2. Setup Database
    1. For first time, create a postgres database and put credentials in .env file.
    2. Also create table using ./data/init_database.sql
  3. Verify setup by running integration tests
    • go test ./integration_tests/ -tags=integration
      • OR run make integration-test

Run

  • Run application from root go run main.go
    • OR make run

By build

  1. go build -o wager-app OR make build
  2. ./wager-app

Architecture

Directory Structure

./ Root

  • ./main.go: entry point for app.
  • ./app_errors/: errors/error codes communicated to outside world.
  • ./dto/: data transfer objects communicated to outside world.
  • ./data/: data resources for app. Ex initial db data, migrations etc.
  • ./integration_tests/: integration tests to verify sanity of app in any environment. Build/deployment should not happen on failure
  • ./internal/: packages within app scope and should not be exposed to outside.
    • ./internal/config/: app configurations and related operations.
    • ./internal/db/: database related operations.
    • ./internal/handlers/: rest request handlers.
    • ./internal/integrations/: other services/3rd party integrations.
    • ./internal/services/: service layer to handle business logic.

About


Languages

Language:Go 97.6%Language:Makefile 1.1%Language:Dockerfile 0.9%Language:Shell 0.5%