This project will use Gin, GORM, MySQL (RDS), Redis (EC2), api-gateway, Lambda, S3, VPC, IAM to complete a simple to-do list.
I am sorry that this project only shows the code and cannot teach how to set up AWS
- Compilation tools
- Database
- Programming language
- Go: v1.19
- Deveops
- Other
- AWS SDK for go v2
- AWS api-gateway
- Crypto
- Gin
- GORM
- Go-redis
- Golang-jwt
- MySQL
- smapping
- swagger
- testify
- uuid
git clone https://github.com/Frankie0702111/go-todolist-aws.git
cd /go-todolist-aws
cp .env.example .env
vim .env
# Create docker image
docker compose build --no-cache
# Run docker
docker compose up -d
# Stop docker
docker compose stop
cd /config
cp config.go.example config.go
vim config.go
# Up all migration
make migrate-up
# Down all migration
make migrate-down
# Specify batch up or down (If you want to go down to a specific file, it is recommended to open a new folder)
make migrate-up number=1
make migrate-down number=1
make swagger
make go-test
8.Compile the golang project into a binary and compress it into a zip file for the purpose of upload to aws lambda
make build
├── LICENSE
├── Makefile
├── README.md
├── config
│ └── config.go.example
├── controller
│ ├── auth
│ │ ├── authController.go
│ │ └── authController_test.go
│ ├── category
│ │ └── categoryController.go
│ └── task
│ └── taskController.go
├── docker
│ ├── golang
│ │ └── Dockerfile
│ └── mysql
│ ├── Dockerfile
│ └── initdb.d
│ └── init.sql
├── docker-compose.yaml
├── docs
│ ├── docs.go
│ ├── swagger.json
│ └── swagger.yaml
├── go.mod
├── go.sum
├── log
├── main.go
├── middleware
│ ├── cors.go
│ └── jwt.go
├── migrations
│ ├── 20221129000000_create_users_table.down.sql
│ ├── 20221129000000_create_users_table.up.sql
│ ├── 20221129000001_create_categories_table.down.sql
│ ├── 20221129000001_create_categories_table.up.sql
│ ├── 20221129000002_create_tasks_table.down.sql
│ └── 20221129000002_create_tasks_table.up.sql
├── model
│ ├── category.go
│ ├── task.go
│ └── user.go
├── repository
│ ├── authRepository
│ │ ├── authRepository.go
│ │ ├── authRepository_test.go
│ │ └── repository.go
│ ├── categoryRepository
│ │ ├── categoryRepository.go
│ │ └── repository.go
│ ├── redisRepository
│ │ ├── redisRepository.go
│ │ └── repository.go
│ ├── s3Repository
│ │ ├── repository.go
│ │ └── s3Repository.go
│ └── taskRepository
│ ├── repository.go
│ └── taskRepository.go
├── request
│ ├── authRequest
│ │ └── authRequest.go
│ ├── categoryRequest
│ │ └── categoryRequest.go
│ ├── publicRequest.go
│ └── taskRequest
│ └── taskRequest.go
├── router
│ ├── authRouter
│ │ └── authRouter.go
│ ├── categoryRouter
│ │ └── categoryRouter.go
│ ├── router.go
│ └── taskRouter
│ └── taskRouter.go
├── service
│ ├── authService
│ │ ├── authService.go
│ │ ├── authService_test.go
│ │ └── service.go
│ ├── categoryService
│ │ ├── categoryService.go
│ │ └── service.go
│ ├── jwtService
│ │ ├── jwtService.go
│ │ ├── jwtService_test.go
│ │ └── service.go
│ └── taskService
│ ├── service.go
│ └── taskService.go
├── static
│ └── upload.html
└── utils
├── aws
│ └── s3.go
├── gorm
│ └── gorm.go
├── log
│ ├── log.go
│ └── logByDate.go
├── paginator
│ └── paginator.go
├── redis
│ └── redis.go
└── response
└── response.go
- Config
Environment setting
- Controller
Receiving HTTP requests calling requests and services
- Docker
Project configurations
- Docs
Swagger API documentation location
- Log
Location of test log output files
- Middleware
Intermediary layer, responsible for filtering incoming data
- Migration
Create datatable details
- Model
As a returned object
- Repository
Assist service in calling sql query
- Request
Assist controller validation request parameters
- Router
API route locations
- Service
Assist controller with business logic
- Static
Test the API for the presence of CORS issues
- Utils
Modular code placement for project calls