Ini adalah Layered Architecture kalau dilihat secara struktur partisinya
- Sistem eksternal melakukan permintaan (HTTP, gRPC, Messaging, dll) ke delivery, contoh permintaan dari sistem eksternal adalah request HTTP get dari client, request gRPC dari client, baca pesan dari message broker, atau baca cache dari redis
- Delivery akan mengakses model request untuk setiap request yang masuk, dan memanggil model response, untuk mengembalikan response data dari use case ke sistem eksternal
- Delivery akan memanggil use case, didalam use case berisi bisnis logic (transaksi, validasi, dll)
- Use case membuat instance baru dari entity dan mengisi data entity dari request model
- Use case memanggil repository, untuk menyimpan data instance entity yg telah dibuat ke database
- Repository menggunakan data entity untuk melakukan operasi database
- Repository melakukan operasi basis data ke database
- Use case memberikan response yang sesuai berdasarkan model response
- Lalu jika ada data yang perlu dikirim ke sistem eksternal, maka use case akan memanggil gateway, dan gateway akan mengirimkan data ke sistem eksternal
- Gateway juga akan mengaksesl model untuk data yang dikirim ke sistem eksternal
- Gateway akan melakukan permintaan mengirimkan data ke sistem eksternal
- Golang : https://github.com/golang/go
- MySQL : https://github.com/mysql/mysql-server
- Apache Kafka : https://github.com/apache/kafka
- Redis : https://github.com/redis/redis
- Minio : https://github.com/minio/minio
- Elasticsearch : https://github.com/elastic/elasticsearch
- GoFiber (HTTP Framework) : https://github.com/gofiber/fiber
- GORM (ORM) : https://github.com/go-gorm/gorm
- Viper (Configuration) : https://github.com/spf13/viper
- Golang Migrate (Database Migration) : https://github.com/golang-migrate/migrate
- Go Playground Validator (Validation) : https://github.com/go-playground/validator
- Logrus (Logger) : https://github.com/sirupsen/logrus
- Golang Confluent Kafka : https://github.com/segmentio/kafka-go
- Golang Redis : https://github.com/redis/go-redis
- Golang JWT : https://pkg.go.dev/github.com/golang-jwt/jwt/v5#section-readme
- Golang Minio : https://pkg.go.dev/github.com/minio/minio-go/v7#section-readme
- Golang Oauth2 : https://pkg.go.dev/golang.org/x/oauth2#section-readme
- Golang Elasticsearch v8 : https://pkg.go.dev/github.com/elastic/go-elasticsearch/v8#section-readme
Semua konfigurasi add di file config.json
.
Semua api spec ada di folder api-spec
.
Semua database migration ada di folder db/migrations
.
go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
migrate create -ext sql -dir db/migrations create_table_xxx
migrate -database "mysql://root:root@tcp(localhost:3306)/assessment_go_source_code_muhammad_aditya?charset=utf8mb4&parseTime=True&loc=Local" -path db/migrations up
go test -v ./test/
go run cmd/web/main.go