Skip to content

Micro service solution for simple e-commerce system

License

Notifications You must be signed in to change notification settings

ibadi-id/ecommerce

Repository files navigation

Ecommerce Graphql Golang

Micro service solution for simple e-commerce system, dengan menggunakan golang, Graphql dan orm menggunakan Ent

Screenshot:

Alt text

Table of Contents

Technology

  • 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

Installation

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

Folder

Struktur folder ecommerce

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

Documentation

File documentation

Testing : ./documentation/cover.html
Architecture : ./documentation/acrhitecture.drawio
Postman : ./documentation/Ecommerce.postman_collection.json

Routing

Routing API

/query - Endpoint Graphql
/playground - Test Playground Graphql

Example

Example Query

query 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
  }
}

Test

Set environment variable
APP_ENV = test

Check configuration test in ./config/config.test.yml

run:
$ go test ./pkg/adapter/repository/...

Releases

No releases published

Packages

No packages published

Languages