Skip to content

This project will use Gin, GORM, MySQL (RDS), Redis (EC2), api-gateway, Lambda, S3, VPC, IAM to complete a simple to-do list.

License

Notifications You must be signed in to change notification settings

Frankie0702111/go-todolist-aws

Repository files navigation

Project description

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

Contents

Software requirements

Project plugins

How to build project

1.Clone GitHub project to local

git clone https://github.com/Frankie0702111/go-todolist-aws.git

2.Set up Docker information, such as database, Redis, Server

cd /go-todolist-aws
cp .env.example .env
vim .env

3.Build docker image and start

# Create docker image
docker compose build --no-cache

# Run docker
docker compose up -d

# Stop docker
docker compose stop

4.Set up basic information, such as database, Redis, AWS, JWT

cd /config
cp config.go.example config.go
vim config.go

5.Generate db migrations

# 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

6.Build Swagger API documentation

make swagger

7.Demo : Run authentication unit and integration tests

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

Folder structure

├── 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

Folder definition

  • 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

About

This project will use Gin, GORM, MySQL (RDS), Redis (EC2), api-gateway, Lambda, S3, VPC, IAM to complete a simple to-do list.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published