Skip to content

Zen-Railz/Backend

Repository files navigation

Go Report Card CircleCI

ZenRailz Backend Logo

Overview

This is the backend repository of our application.

Domain Description
Repository GitHub
Language Go
Framework Gin
Hosting Heroku with Docker
Database Heroku Postgres
Continuous Integration CircleCI
Test Gingko
Gomega
gotestsum
Formatter gofmt
Dependency Injection Wire

Preparation

Installation of dependencies

go mod download

Development

The development of this project is on a windows machine. Steps described in the following sections will be based on windows commands.

Setup - Local Environment

  1. Ensure that port number is set in the environment variable. The local server will be listening on this port.
SET PORT=3000
  1. Ensure that database url is set in the environment variable.
SET DATABASE_URL=<uri>
  1. Run the project from the root directory.
go run main.go

Dependency Injection

As dependency injection is one of the most important design principles to reduce tight-coupling among components, we made use of Google's code generation tool, Wire, to achieve this.

To generate the dependency graph, run in the root directory

wire ./...

Test

Testing Locally

As we are using the Ginkgo testing framework, we can run all the tests in this module with any of the below commands in the root folder.

ginkgo ./...

or

go test -v ./...

To view test files, turn on the visibility of _test.go files in the .vscode/settings.json file by setting the config to false, or simply comment it.

{
  "files.exclude": {
    // "**/*_test.go": true
  }
}

Deployment

  1. Create a docker file
  2. Create a circleci yml file
  3. Push code to code repository