This Project is being developed by GG-Team
Project Structure and Explanation is below:
-docs
-sql
-swagger
-templates
-env
-etc
-cfg
-tpl
-src
-business
- domain
- entity
- usecase
-cmd
-handler
-utils
-config
-
docs
This files contain
sql
file that store all of our migration file. Next isswagger
where we can access/debug our API. For now, just ignoretemplates
file. -
env
For the sake of simplicity, we using
docker-compose
to make our enviroment same when developing. You can run it with$ cd env | docker compose up -d
or if you using
docker-compose
$ cd env | docker-compose up -d
In the docker compose file, there are
redis
andmysql
. If you already havemysql
in your machine, just comment it, and run thedocker compose
command to avoid conflict with your local db. -
etc
This is where we store our config file as a
.json
. You can use theconf.template.json
to construct your config. -
src
The main source code of the project. You can see the
business
folder contain some files. I recommend you to familliar with these files, because you will see/edit them a lot in the future.domain
as name implies a source code to handling in the domain layer. If you not familiar with this term, imagine amodel
in Laravel. That is thedomain
. Their function is to "talking" with our storage (i.e database)entity
is where we store all the type of our object in here. People often said it asdata transfer object
ordto
in short. Many name, but same function.usecase
is where the main logic of our source code. Its function is pretty similliar tocontroller
in Laravel.The other folder are
cmd
andhandler
. As the name implies,cmd
folder only have ourmain.go
. In the other hand,handler
is the folder where we define all the routes and their respective handler function. -
utils
This is where we read the config file from before and insert the environment variable to our source code.
-
Make sure you have golang installed on your machine
-
Run the docker compose to run some container like Redis and MySQL DB
-
Make your config file
-
If you running on windows OS, makse sure to install
make
command API on your system. This will make your life easier. After that, you can run command:$ make swaggo
this command will install
swaggo
a package to make an interface to access your endpoint in back end services. -
Start the app with command (Linux or MAC) / in windows, you can read reference how to have
make
command either usingWSL
orgit bash
$ make run
-
The app is running on port
8080
(Default). If running, you will something like this on your terminal:
- You can access the swagger endpoint in
{host}:{port}/swagger/index.html
- CADDY_HOST_NAME --> Domain Name for Caddy
- DATABASE_DRIVER --> Database driver for example: MySQL or Postgres
- DATABASE_HOST --> Database Host or IP Address
- DATABASE_NAME --> Database Name
- DATABASE_PASSWORD --> Database Password
- DATABASE_PORT --> Database Port
- DATABASE_USER --> Database User
- DEPLOY_FILE --> Deploy Folder in VPS Host
- DISCORD_AVATAR --> Discord Avatar for CICD Notification
- DISCORD_USERNAME --> Discord Username for CICD Notification
- DISCORD_WEBHOOK --> Discord Webhook for CICD Notification
- DOCKERHUB_TOKEN --> Dockerhub token
- DOCKERHUB_USERNAME --> Dockerhub username
- ENV_MODE --> ENV Mode for App (debug)
- HOST --> What is the host for VPS (localhost)
- PORT --> What is the port for (8080)
- REDIS_HOST --> What is the redis host
- TOKEN_GITHUB --> Github Token
- VPS_HOST --> What is the VPS IP Address
- VPS_PASSWORD --> What is the VPS Password
- VPS_PORT --> What is the SSH Port for VPS
- VPS_USERNAME --> What is the SSH Username for VPS