Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/opplieam/bb-product-server


https://github.com/opplieam/bb-product-server

Last synced: 1 day ago
JSON representation

Awesome Lists containing this project

README

        

# Buy-Better Product Server

## Table of contents
- [Overview](#overview)
- [Project structure](#project-structure)
- [Dependencies](#dependencies)
- [Developer Setup](#developer-setup)
- [Running Test](#running-test)
- [Running in local cluster minikube](#running-in-local-cluster-minikube)
- [Postman Testing](#postman-testing)

## Overview
Buy Better Product server is a grpc server that responsible for the products related logic.
example `GetProductsByUser` etc.

`NOTE: This project is for learning purpose and not fully complete yet`

## Project structure
```
├── .gen # auto generated by jet-db
│   ├── buy-better-core
├── .github
│   ├── workflows
├── bin # go binary
├── deploy # helm chart
│   ├── bb-product-server # project helm chart
├── cmd
│   └── server # main package for product service
├── internal
│   ├── product # product service handler
│   └── store # database logic
└── k8s
├── base # kustomize base
└── dev # patch kustomize
```

## Dependencies
#### Infrastructure
- docker / docker-compose
- minikube
- kubectl / kustomize
- helm
#### Database tools
- CLI [jet-db](https://github.com/go-jet/jet?tab=readme-ov-file#installation)
#### Testing tools
- CLI [mockery](https://vektra.github.io/mockery/latest/installation/)

## Developer Setup
1. Create environment variable store in `.env` file at root directory
```
DB_DRIVER="postgres"
DB_DSN="postgresql://postgres:admin1234@localhost:5433/buy-better-core?sslmode=disable"
DB_MAX_OPEN_CONNS=25
DB_MAX_IDLE_CONNS=25
DB_MAX_IDLE_TIME="15m"
```
> environment variables must be match with Makefile

2. Visit `Makefile` There are 2 important variables for local development. Feel free to edit.
```
DB_DSN
DB_NAME
DB_USERNAME
CONTAINER_NAME
```

3. Please visit [Buy-Better-Core](https://github.com/opplieam/bb-core-api) and run `make dev-db-up` from there

4. `go run cmd/server` start the service with port `:3031`

## Running Test

`go test ./... -v` Currently, There is unit test only.

## Running in local cluster minikube
Please keep in mind. This project meant to be running with other [service](https://github.com/opplieam/bb-core-api).

`make dev-apply` to apply product service to local cluster

## Postman testing
Please import the proto file from [Buy-Better-Proto](https://github.com/opplieam/bb-grpc)

## Useful Command/Makefile
Please visit `Makefile` for the full command.
- `make jet-gen` generate a type safe from database. run this command everytime there is a change in database schema.
- `mockery` generate a mock file. please visit `.mockery.yaml` for the setting
- `make dev stop` delete the product service resource

## TODO
- Add grpc healthcheck
- Make address as an environment variable