An Internet-of-Things (IoT) application written in Go using MongoDB that adds smart functionality to my kitchen. Goal is to utilize a barcode scanner and scale on my Raspberry Pi to automatically track the groceries I have stored to quickly tell me what recipes I can cook and when items will expire.
Its goals are to:
- Quickly identify what recipes I can make from the food I have stocked.
- Reduce/prevent food waste by alerting (via Twilio SMS) and creating a shopping list (as a Trello card) when items are nearing their expiration dates. Food items are defined as JSON documents in a MongoDB database.
Presently, Forage can handle the following:
- Ingredient expiration: know which of the ingredients in your kitchen will expire and how soon.
- Recipe availability: know which recipes you can cook tonight from what you have available.
- Shopping list curation: see which ingredients need replacing, without risk of forgetting.
- SMS alerting: be reminded of when its time to go grocery shopping.
- adlio/trello: Trello API client
- twilio/twilio-go: Twilio API client
- mongo-driver: MongoDB driver
- sirupsen/logrus: Logging
- gorilla/mux: HTTP router/multiplexer
See go.mod
for details.
FORAGE_CONTEXT_TIMEOUT
:FORAGE_INTERVAL
:FORAGE_LOOKAHEAD
: the amount of time the Expiration job checks ahead for expiring items.FORAGE_TIME
: the time of day at which the Expiration job is scheduled to execute.FORAGE_TIMEZONE
: the timezone in which this instance is hosted.LISTEN_SOCKET
: the socket upon which to listen for incoming connections.LOGRUS_LEVEL
: the log granularity threshold (e.g.DEBUG
,INFO
,WARN
,ERROR
).MONGO_URI
: the database connection string.TRELLO_MEMBER
:TRELLO_BOARD
: the Trello board upon which to place the shopping list card.TRELLO_LIST
: the Trello list upon which to place the shopping list card.TRELLO_LABELS
: the Trello labels to be added to the shopping list card.TRELLO_API_KEY
:TRELLO_API_TOKEN
:TWILIO_ACCOUNT_SID
:TWILIO_AUTH_TOKEN
:TWILIO_PHONE_FROM
: the Twilio phone number assigned to this instance of Forage from which to send SMS messages.TWILIO_PHONE_TO
: the recipent phone number for SMS messages from Twilio.
<configure & source environment variables>
go build
./forage
Easy as 1,2,3.
- Comprehensive testing
- Clear readability
- Detailed logging
api/
: Code that defines the REST API and background job(s).api_test.go
: Primary test file, containing unit tests for every case in HTTP handlers and their supporting functions.api.go
: Primary API handler and background job functions.listen.go
: Code for the listening/serving of HTTP requests.mocks.go
: Defines various mock functions and test variables for use inapi_test.go
.
clients/
: Code for interfacing with 3rd-party APIs.mongo.go
: MongoDB interface.trello.go
: Trello interface.twilio.go
: Twilio interface.
config/
: Definition of global configuration (including client interface definitions) as well as an abstract MongoDB interface to enable mocking.operations/
: Various scripts intended to be run manually.populate.js
: Script to populate MongoDB with documents describing each ingredient & recipe being tracked.
tests/
: Unit tests and mocks.utils/
: Miscellaneous helper code.vendor/
: Vendored dependencies.
- Write your code, following the current style
- Write your tests & ensure complete coverage
- Submit a pull request and I'll review it :)