No Description
Andrew Sellers c80d82ca1c Make go-gettable 4 months ago
.vscode Added initial ideas and code 4 months ago
api Make go-gettable 4 months ago
config Add token lookup 4 months ago
db Make go-gettable 4 months ago
permissions Make go-gettable 4 months ago
vendor Vendor the libraries with dep 4 months ago
.gitignore Get some basic show/index tests working, fix bugs 4 months ago
Gopkg.lock Vendor the libraries with dep 4 months ago
Gopkg.toml Vendor the libraries with dep 4 months ago
README.md Make go-gettable 4 months ago
curl_examples.txt Fix an update bug, add more examples 4 months ago
main.go Make go-gettable 4 months ago
openapi.yaml Add rank sorting 4 months ago

README.md

Product Service

By Andrew Sellers andrew@andrewcsellers.com

The Product service allows for anonymous users to view and filter products that are set to visible. Logged in users can create, edit, and delete products that correspond to their allowed vendors. Logging in uses tokens from an identity service (not in scope).

API Documentation is in the openapi.yaml file.

Features

  • Set Name, Model Name, Manufacturer, Price, Weight of Products, and up to 5 Category Levels of Products.
  • Products can be hidden from public view using the Visible attribute.
  • Users are restricted to only editing specific Manufacturers.
  • Support users can edit all products.
  • UUID identifier based on product info

Getting up to Speed

You’ll want to know a basic level of how DynamoDB works. Data is stored in that, and there’s a simplistic shell on top of it that should make the API somewhat easier to write. The main package really just calls Init functions on sub-packages and setups up any config variables it needs to. Well, and handling interrupts so the api server will do a graceful shutdown.

You’ve got 4 different sub packages

  • api: Uses the Echo library to serve responses from the products table.
    • Router and serving code is in api.go
    • Handlers are in products.go
    • Filtering code is interesting, it can read JSON or query params into filters.
  • config: Global variables that do things like control which mode (dev, prod, test) the app is in, what port to listen on, keys, etc.
  • db: Handles the dynamodb bits without making the rest of the app have to know about how that works
    • Query code is in product_query.go
    • The code that maps between dynamodb data and products is in db/db.go.
    • Non-Query dynamodb methods are in product.go
  • permissions: Looks up permissions for tokens, has some built-in tokens for dev and test modes.

Setting up

You’ll need 4 DyanmoDB tables for everything, named Products, ProductsDev, ProductsTest, and ProductsIntegration. Primary Key is “ID”, which is a binary key. Manufacturer, Category1, Category2, Model could deserve indexes for production tables.

You can set the Access and Secret keys using the AWSACCESS/AWS_ACCESS_KEY and AWSSECRET/AWS_SECRET_KEY environment variables, otherwise this will try to use the .aws credentials. Default region is us-east-2, but that can be set by the AWSREGION environment variable.

You’ll want a token host to handle editor tokens. It should respond with a json object that has a scopes attribute, where scopes is a space separated string. For every manufacturer=x item in the scopes attribute, the token will provide editing of products with that manufacturer. Or you can set a support_user scope that will allow editing all manufacturer’s products.

Expected Other Services

Product Search

Elasticsearch based service that can do keyword searches on product info.

Reviews/Ratings

Keeps up with normal user reviews and calculated ratings for the product

Sales Statistics

Calculates the sales rank for products and pushes it to this service.

Shopping Cart Service

Keeps track of which items a user is planning to buy, also lets the purchase the items.

Inventory Service

Keeps up with what products are in stock and where

Category Service

Handles the trees of Categories