cyberwo1f / go-example-api-with-mongo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golang Example API with MongoDB

Test

This repository is a template showing the basic architecture and file system for developing APIs using MongoDB in the Go language.

The architecture references the following design patterns to maintain loose coupling, domain management efficiency, and tuning cost performance.

  • DDD
  • clean architecture

This is not a solution for every need, but only a basic architecture. It should be rearranged as needed depending on your needs, but note that the relationships between entities, repositories, persistence, and other injections, as well as the scope of responsibility and processes for each package, should be maintained.

How to run

Setup environment

Make sure that you have direnv installed to configure local environment variables. Please look at the direnv GitHub for installation. Copy the .envrc.example file and set the environment variables, then enable direnv.

$ cp .envrc.sample .envrc
$ vi .envrc
$ direnv allow

And then, start the server and the MongoDB by running the command below:

$ docker-compose up

If you want to run go test

$ docker-compose -f docker-compose.test.yml up -d

API Interfaces

Func Method Path Description
GetUsers GET /user/list get list by all users
GetMessages GET /message/list/:user_id get all messages for specified user id

About


Languages

Language:Go 92.9%Language:Shell 3.7%Language:Dockerfile 3.4%