Skip to content

The Hello Sekai E-Commerce is the full-stack web app that provides a player with a player role to buy anything from shop. But the admin role can create, get, update, or enable/disable item.

License

Notifications You must be signed in to change notification settings

Rayato159/hello-sekai-shop-microservices

Repository files navigation

⚔️ Hello Sekai Shop Microservices

📝 Architecture

arch_v3.png

📦 Packages

go get github.com/labstack/echo/v4
go get github.com/labstack/echo/v4/middleware
go get github.com/go-playground/validator/v10
go get github.com/joho/godotenv
go get go.mongodb.org/mongo-driver/mongo
go get github.com/golang-jwt/jwt/v5
go get github.com/stretchr/testify
go get github.com/IBM/sarama

📃 Start App in Terminal

go run main.go ./env/dev/.env.auth
go run main.go ./env/dev/.env.item
go run main.go ./env/dev/.env.player
go run main.go ./env/dev/.env.inventory
go run main.go ./env/dev/.env.payment

🍃 MongoDb

Start Docker Compose for Kafka

docker compose -f docker-compose.db.yml up -d

Enter into a db container

docker exec -it <db_name> bash

Migration

dev

go run ./pkg/database/script/migration.go ./env/dev/.env.player && \
go run ./pkg/database/script/migration.go ./env/dev/.env.auth && \
go run ./pkg/database/script/migration.go ./env/dev/.env.item && \
go run ./pkg/database/script/migration.go ./env/dev/.env.inventory && \
go run ./pkg/database/script/migration.go ./env/dev/.env.payment

prod

go run ./pkg/database/script/migration.go ./env/prod/.env.player && \
go run ./pkg/database/script/migration.go ./env/prod/.env.auth && \
go run ./pkg/database/script/migration.go ./env/prod/.env.item && \
go run ./pkg/database/script/migration.go ./env/prod/.env.inventory && \
go run ./pkg/database/script/migration.go ./env/prod/.env.payment

🦋 Kafka Command

Start Docker Compose for Kafka

docker compose -f docker-compose.kafka.yml up -d

Enter into the Kafka container

docker exec -it kafka-1 bash

Create a topic

./opt/bitnami/kafka/bin/kafka-topics.sh --create --topic inventory --replication-factor 1 --partitions 1 --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-topics.sh --create --topic payment --replication-factor 1 --partitions 1 --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-topics.sh --create --topic player --replication-factor 1 --partitions 1 --bootstrap-server localhost:9092

Add topic retention

./opt/bitnami/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name inventory --alter --add-config retention.ms=180000
./opt/bitnami/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name payment --alter --add-config retention.ms=180000
./opt/bitnami/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name player --alter --add-config retention.ms=180000

See all topics list

./opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Describe topic

./opt/bitnami/kafka/bin/kafka-topics.sh --describe --topic inventory --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-topics.sh --describe --topic payment --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-topics.sh --describe --topic player --bootstrap-server localhost:9092

Write a message into the topic

./opt/bitnami/kafka/bin/kafka-console-producer.sh --topic inventory --bootstrap-server localhost:9092 
./opt/bitnami/kafka/bin/kafka-console-producer.sh --topic payment --bootstrap-server localhost:9092 
./opt/bitnami/kafka/bin/kafka-console-producer.sh --topic player --bootstrap-server localhost:9092

Write a message with key into the topic

--property "key.separator=:" --property "parse.key=true"

Read a message on that topic

./opt/bitnami/kafka/bin/kafka-console-consumer.sh --topic inventory --from-beginning --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-console-consumer.sh --topic payment --from-beginning --bootstrap-server localhost:9092
./opt/bitnami/kafka/bin/kafka-console-consumer.sh --topic player --from-beginning --bootstrap-server localhost:9092

Delete topic

./opt/bitnami/kafka/bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic inventory
./opt/bitnami/kafka/bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic payment
./opt/bitnami/kafka/bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic player

🍰 Generate a Proto File Command

player

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    modules/player/playerProto/playerProto.proto

auth

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    modules/auth/authProto/authProto.proto

item

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    modules/item/itemProto/itemProto.proto

inventory

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    modules/inventory/inventoryProto/inventoryProto.proto

🐳 Docker Build

docker build -t rayato159/hello-sekai-shop:latest -f build/auth/Dockerfile .

About

The Hello Sekai E-Commerce is the full-stack web app that provides a player with a player role to buy anything from shop. But the admin role can create, get, update, or enable/disable item.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published