Giter Club home page Giter Club logo

arcadia-backend-test's Introduction

This is the backend for the Arcadia game. It is written in GoLang and uses the Gin framework for HTTP serving.

Prerequisites

Dev:

  1. Go
  2. Reflex
  3. Golangci-lint
  4. Redis
  5. Swagger

Docker:

  1. docker (To contribute you will also need go, swag and golangci-lint)

Setup

proceed sequentially from here and run applicable commands

All Modes:
  1. Clone the Repository.

  2. cp .env.example .env and change values, if necessary.

  3. cp config.example.json config.json and change values, if necessary.

Only for Dev:
  1. Enable git hooks by running git config core.hooksPath .githooks.

  2. Configure .vscode/settings.json to use golangci-lint for linting.

{
   "go.lintTool":"golangci-lint",
   "go.lintFlags": [
   "--fast"
   ],
   "go.lintOnSave": "package",
   "go.formatTool": "goimports",
   "go.useLanguageServer": true,
   "[go]": {
      "editor.formatOnSave": true,
      "editor.codeActionsOnSave": {
         "source.organizeImports": true
      }
   },
   "go.docsTool": "gogetdoc"
}
  1. Run go mod download to download all go dependencies.

  2. Ensure you have a MySQL database running and create a database with the name you specified in .env and config.json.

For Dev in DOCKER:
  1. Uncomment and comment the appropriate lines in docker-compose.yaml

  2. Make changes to .env (set APP_ENV to DEV) and config.json (copy over from DOCKER config).

  3. Follow all subsequent steps in the "Only for Docker" section below.

Only for Docker:

  1. docker compose up --build

  2. Access Adminer at http://localhost:8080/ (or at the ADMINER_EXTERNAL_PORT)

  3. MySQL volumes are present in ./docker_volumes/mysql/ and logs at ./docker_volumes/logs/

  4. Create and restore MySQL dumps with the scripts in ./scripts/

  5. docker compose down to stop all containers

Seeding the Database

  1. To seed the database with dummy data, run make seed or make docker_seed

Build and Run (for Dev only)

  1. Run make watch command to start the backend in development mode. This will automatically restart the backend when you make changes to the code.

  2. Run make build command to build the backend for production and make start to start the binary file (arcadia_server).

Rules for Contributing:

  1. All code should be formatted using make lint or make fix before committing.

  2. Commit messages should be according to Conventional Commits.

  3. Use the Pull Request template when creating a PR.

Testing:

  1. All Testing functions should be of the form <feature>-test.go

  2. Include the test function(s) in run_tests.go

  3. Run make test or make docker_test to run all tests.

Note: Testing in this repo has been made Docker-friendly, so not all best practices for tests may apply (such as filename = *_test.go or using the testing package or go test -v ./...)

OpenAPI Documentation

  1. Specify the URL in which you would like to have the docs in config.SwaggerURL

  2. Write comments above Controllers to make a OpenAPI docs for that route.

  3. Refer swaggo/swag documentation and learn how to write comments above controllers.

  4. Run swag fmt to format the comments

  5. Run swag init to build docs from the comments

arcadia-backend-test's People

Contributors

codx-aks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.