The backend is developed by domain-driven design pattern.
Golang Backend has:
- API: It's serve HTTP server with GraphQL
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.
- We prefer to use the
*nixOperating 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
- 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 migratedbmake gen
- 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
- username:
- Database:
- 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- You can access
- Backend via http://localhost:8000 (GraphQL Playground) and http://localhost:8000/graphql (GraphQL Server)
-
cmd: It contains cobra command to build CLI command to execute run a server. For example:
./server apito run API and./server workerto run Worker. -
config: It contains all config structures which are parsed from the
config.yamlfile. -
database: It contains all database migrations. Please setup migrate tool to uses it.
-
graphql: It contains all code generated by
gqlgenfor 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
gqlgento resolve the GraphQL schemas. -
service: It contains all business logic services
-
template: It contains all template files for example HTML.