Micro service solution for simple e-commerce system, dengan menggunakan golang, Graphql dan orm menggunakan Ent
Screenshot:
- Clean Architecture
- Go Languange: Build fast, reliable, and efficient software at scale. more
- GraphQL API: Get many resources in a single request and more
- ORM - ENT: Simple, yet powerful ORM for modeling and querying data. more
- Route - Echo: High performance, extensible, minimalist Go web framework more
- Dockerize: Optimized for deployments using Docker
- Hot Reload - Air: Live reload for Go apps. more
Dockerize
run:
$ docker compose build --no-cache
$ docker compose up
Local
prepare mysql db name `ecommerce`
run:
$ go mod tidy
$ make migrate_schema
$ make start
visit http://localhost:9090/playground
├── cmd
│ ├── app
│ └── migration
├── config
├── documentation # Documentation File
├── ent
├── graph
├── migration # Sql Migration File
├── pkg
│ ├── adapter
│ │ ├── controller # Controller
│ │ ├── repository # Specific implementaion of repository
│ │ └── resolver # GraphQL resolvers
│ │
│ │
│ ├── entity
│ │ └── model # Entity of model, (e.g. ent.Customer, ent.Product)
│ │
│ │
│ ├── infrastructure
│ │ ├── datastore # MySQL configuration
│ │ ├── graphql # GrahpQL configuration
│ │ └── router # Echo router
│ │
│ │
│ ├── usecase
│ │ ├── repository # Interface for adapter
│ │ └── usecase # Usecase for application/business logic
Testing : ./documentation/cover.html
Architecture : ./documentation/acrhitecture.drawio
Postman : ./documentation/Ecommerce.postman_collection.json
/query
- Endpoint Graphql/playground
- Test Playground Graphqlquery customers{
customers{
id
name
email
phone
createdAt
updatedAt
}
}
query product{
product(id:1){
name
descriptions
price
sku
stock
createdAt
updatedAt
}
}
mutation createCustomer{
createCustomer(input:{
name:"tester",
phone:"08511234567",
email:"[email protected]"
}){
name
id
email
phone
createdAt
updatedAt
}
}
Set environment variable
APP_ENV = test
Check configuration test in ./config/config.test.yml
run:
$ go test ./pkg/adapter/repository/...