- ORM --> gorm https://github.com/go-gorm/gorm
- Database --> postgresql https://www.postgresql.org/
- Framework --> gin https://github.com/gin-gonic/gin
- Cache --> redis https://redis.io
- Stucture --> kafka
- Type_api --> resful
- Devops --> dev ( heroku ) --> prod ( aws google-cloud)
- Target --> voucher
- Env manager --> Viper
system/
cmd/
server/
main.go
internal/
app/
app.go
handler/
voucher.go
model/
voucher.go
repository/
util/
database.go
vendor/
.env
.env.example
.gitignore
go.mod
go.sum
README.md
Here's what each component of the project structure does:
- cmd
- cmd/server/main.go: This is the main entry point for the application, and is responsible for starting the Gin web server and handling HTTP requests.
- Internal
-
internal/app/app.go: This file contains the code for initializing the Gin web framework and setting up middleware, such as logging or authentication.
-
internal/handler/voucher.go: This file contains the code for handling HTTP requests related to vouchers, such as redeeming a voucher or retrieving information about a voucher.
-
internal/model/voucher.go: This file contains the Go struct for representing a voucher, with fields for the voucher code, expiration date, and redemption status.
-
internal/repository/voucher.go: This file contains the code for interacting with the PostgreSQL database to retrieve, create, and update vouchers.
-
internal/util/database.go: This file contains the code for connecting to the PostgreSQL database and executing SQL queries.
- Vendor
- vendor/: This directory contains the dependencies for the project, managed using Go's built-in go mod tool.
-
.env: This file contains environment variables for the application, such as the database connection details.
-
.env.example: This file provides an example of the environment variables that should be defined in the .env file.
-
.gitignore: This file specifies files and directories that should be ignored by Git.
-
go.mod and go.sum: These files are generated by Go's go mod tool and manage the dependencies for the project.
-
README.md: This file provides a high-level overview of the project, including instructions for building and running the application.