||3 years ago|
|.vscode||3 years ago|
|api||3 years ago|
|config||3 years ago|
|db||3 years ago|
|permissions||3 years ago|
|vendor||3 years ago|
|.gitignore||3 years ago|
|Gopkg.lock||3 years ago|
|Gopkg.toml||3 years ago|
|README.md||3 years ago|
|curl_examples.txt||3 years ago|
|main.go||3 years ago|
|openapi.yaml||3 years ago|
By Andrew Sellers email@example.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.
- 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.
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
Elasticsearch based service that can do keyword searches on product info.
Keeps up with normal user reviews and calculated ratings for the product
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.
Keeps up with what products are in stock and where
Handles the trees of Categories