Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jyelewis/cola-counter
https://github.com/jyelewis/cola-counter
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/jyelewis/cola-counter
- Owner: jyelewis
- Created: 2023-12-28T05:35:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-28T05:40:08.000Z (about 1 year ago)
- Last Synced: 2024-10-15T22:13:40.387Z (3 months ago)
- Language: TypeScript
- Size: 188 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cola counter
Storage backend for 'Cola counter' IoT project.Provides a REST API, a web-interface and an MQTT interface to store and retrieve cola counts.
[Just let me read the code](https://github.com/jyelewis/cola-counter/blob/main/src/modules/fridge/fridge.service.ts)
[See this e2e test for example usage over HTTP](https://github.com/jyelewis/cola-counter/blob/main/test/fridge.e2e-spec.ts)
## Data model
```mermaid
classDiagram
class Fridge {
string name
number numStockedCans
}class StockEvent {
String fridgeName
Date date
number numCansAdded
}
StockEvent --> Fridge
```## API
### REST
`GET /healthcheck` - returns "OK" if the server is healthy`GET /fridges/:fridgeName` - returns a specific fridge, creates it if it doesn't exist
`POST /fridges/:fridgeName/stock-events { numCansAdded: -1 }` - adds/removes cans from a fridge
`GET /fridges/:fridgeName/stock-events` - returns list of recent stock events
### MQTT
TODO## Getting started
### Running locally
1. Install [Node.js](https://nodejs.org/en/)
2. Install [Docker](https://www.docker.com/)
3. Run `npm start`
4. API will be available at http://localhost:3000
5. To stop the server, press `Ctrl+C`, to stop third party deps, run `npm stop`### Deploying to AWS
1. Follow the above steps to install dependencies
2. Ensure you have your AWS CLI configured & authenticated
3. `npm run deploy`
4. Get your API URL from the output of the above command, or AWS Lambda console## Tech stack
### Cloud infrastructure
- [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) as compute platform
- [AWS Lambda Function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html) as REST API server
- [AWS CloudFront](https://aws.amazon.com/cloudfront/) as CDN
- [AWS IoT Core](https://aws.amazon.com/iot-core/) as MQTT interface
- [AWS DynamoDB](https://aws.amazon.com/dynamodb/) as database### Language & tools
- [TypeScript](https://www.typescriptlang.org/)
- [NestJS](https://docs.nestjs.com/) as project framework
- [DynamoFlow](https://github.com/jyelewis/dynamoflow) as DynamoDB ORM
- [Prettier](https://prettier.io/) as code formatter
- [ESLint](https://eslint.org/) as code linter
- [Docker](https://www.docker.com/) to run external dependencies locally