Skip to content

wicaker/multi-saas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MULTI SAAS PROJECT

This project aim to serve multiple saas(software as a service) in the backend side.

Folder Structure

Inspired by: https://dasarpemrogramangolang.novalagung.com/C-project-layout-structure.html

Database Migrations

Thanks to: https://github.com/golang-migrate/migrate

Download to inside the project: curl -L https://github.com/golang-migrate/migrate/releases/download/v4.15.2/migrate.darwin-amd64.tar.gz | tar xvz

Create new migrations file: ./migrate create -ext sql -dir migration {file_name}

Migrations up: ./migrate -path {FILE_PATH} -database "{DATABASE_URL" up

Migrations down: ./migrate -path {FILE_PATH} -database "{DATABASE_URL" down

Run Tests

go test -v ./test/functional/...
go test -v ./cmd/user/userhandler

With coverage:
unit:
go test -coverprofile=coverage.out ./cmd/user/userhandler
go tool cover -html=coverage.out -o coverage.html

Document Database Schema

database schema plan

Thanks to: https://github.com/k1LoW/tbls

Generate Mocks

Thanks to: https://github.com/vektra/mockery

mockery --name={InterfaceName} --output={path}. Example: mockery --name=UserUsecase --output=/cmd/user/mocks

Run Localstack (AWS Service emulator in local)

  • Install aws cli
  • Install docker & docker-compose
  • Run: make docker-compose-localstack
  • If you find Waiting for all LocalStack services to be ready log often, be patient :). It will happen for a while.

Create S3 Bucket

  • export AWS_SECRET_ACCESS_KEY=${ACCESS_KEY_SECRET} AWS_ACCESS_KEY_ID=${ACCESS_KEY_ID}
  • aws --endpoint-url=http://localhost:4566 s3 mb s3://{bucket_name}. Example: aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket
  • aws --endpoint-url=http://localhost:4566 s3api put-object --bucket {bucket_name} --key {folder}. Example: aws --endpoint-url=http://localhost:4566 s3api put-object --bucket my-bucket --key image/user/

Generate Query

We use sqlc to generate go code from sql. You need to install sqlc first.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages