Giter Club home page Giter Club logo

golang-boilerplate's Introduction

Golang Backend

The backend is developed by domain-driven design pattern.

Golang Backend has:

  • API: It's serve HTTP server with GraphQL

Git Branch Strategy

In this repository, we would like to apply the trunk based development for the Git strategy. However, in this POC, both releases or any merge request will be merged to the main branch will deploy only to the same server.

The name branch for all pull requests must be follow this list:

  • feature/** (Create a new feature)
  • bugfix/** (Create a new bugfix for a feature or item)
  • v1.0.0 (Use semantic versioning to create a new releases version)

There is no hotfix branch due to this POC not having scope for the production environment.

Get Started

Local Development

Software & Hardware requirements

  • We prefer to use the *nix Operating System to run all systems
  • You must install the Docker Desktop and Docker Compose on yourlocal desktop to spin up all systems with 1 command
  • Change your Docker Desktop resource capacity to at least 8GB RAM and 4 vCPU

Database Migrations [Optional]

  • Install atlas-go CLI first.
  • Create new migrations
atlas migrate new migrations_name
  • Dry run to verify before execute up:
make migratedbdryrun
  • Execute up migrations by:
make migratedb

Generate Entgo & GraphQL with Go Generate

  • Install gqlgen first
  • Learn about entgo
  • To generate new schema or update graphql resolver,... use:
make gen

Run Application by Docker-Compose

  • Start docker and run docker-compose by use your terminal
docker-compose up
  • Clean up everything created by docker-compose by use your terminal
docker-compose down
docker volume prune -y
  • The docker-compose will bootstrap a required database to working with source code includes:
    • Database: backend_db
      • username: backend_user
      • password: backend_password

Run Applicationn in your terminal

  • You need to setup all required software before running the application
  • Please run migrations before running the application
  • Run the backend_api:
cd backend
# Build application
make build
# Run api
./server api

How to test

Project Structure

  • cmd: It contains cobra command to build CLI command to execute run a server. For example: ./server api to run API and ./server worker to run Worker.

  • config: It contains all config structures which are parsed from the config.yaml file.

  • database: It contains all database migrations. Please setup migrate tool to uses it.

  • graphql: It contains all code generated by gqlgen for GraphQL Server. You can figure it here.

  • internal: It contains all internal interfaces/apis can shared for different packages. For example: Keycloak, Logger, Mailer, PostgreSQL, RabbitMQ, etc. It also contains utility functions.

  • model: It contains all domain models.

  • resolver: It contains all resolvers generated by gqlgen to resolve the GraphQL schemas.

  • service: It contains all business logic services

  • template: It contains all template files for example HTML.

golang-boilerplate's People

Contributors

davidhotvf 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.