https://github.com/hemantksingh/brew-bar
Event driven app that mirrors order processing in a brew bar based on AWS resources managed via terraform
https://github.com/hemantksingh/brew-bar
api-gateway aws eventdrivenarchitecture rest-api serverless terraform typescript
Last synced: 8 months ago
JSON representation
Event driven app that mirrors order processing in a brew bar based on AWS resources managed via terraform
- Host: GitHub
- URL: https://github.com/hemantksingh/brew-bar
- Owner: hemantksingh
- License: mit
- Created: 2022-07-25T22:46:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-29T01:38:47.000Z (over 3 years ago)
- Last Synced: 2025-02-05T17:14:52.852Z (over 1 year ago)
- Topics: api-gateway, aws, eventdrivenarchitecture, rest-api, serverless, terraform, typescript
- Language: HCL
- Homepage:
- Size: 302 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# brew-bar
Event driven app that mirrors order processing in a brew bar based on AWS resources managed via terraform
- Public gateway used for providing public access for placing Orders, can also plug in to an identity provider for authorizing clients/users.
- To enable clients to register events without changing backend code, you can [send client events](https://aws.amazon.com/blogs/compute/capturing-client-events-using-amazon-api-gateway-and-amazon-eventbridge/) to EventBridge via an API Gateway
- The internal AWS API Gateway performs validation on published events. It [supports](https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html#models-mappings-models) Draft 4 of JSON Schema and plug the schema into an API endpoint in order to reject any requests that don’t conform to the schema.
- The event bus has a rule to dispatch order events to the delivery lambda. You can only create scheduled rules using the default event bus
- EventBridge has a hard limit on the event size at 265 KB

## Build the apps (lambda functions)
The apps are built using `esbuild` and packaged with `zip` as detailed [here](https://docs.aws.amazon.com/lambda/latest/dg/typescript-package.html)
```sh
make build APP=orders
make build APP=delivery
```
## Deploy the stack
The infrastructure and apps are deployed using `terraform`
```sh
# Provision the stack
make stack APPLY=true
# Tear down
make destroy-stack
```
## Get orders
```sh
cd provisioning
curl "$(terraform output -raw orders_api_url)/orders"
```
## Run load tests
- Pre requisites - Install [pipenv](https://packaging.python.org/en/latest/tutorials/managing-dependencies/)
```sh
python3 -m pip install --user pipenv
```
- Run load test
```sh
# get ORDERS_API_ID by loading terraform output
make output
# Terraform out put looks like:
# orders_api_url = "https://e60e2y07o4.execute-api.eu-west-1.amazonaws.com/brewbar
# run the load test
make loadtest ORDERS_API_ID=e60e2y07o4
```