Giter Site home page Giter Site logo

snackinventory's Introduction

SnackInventory is a lightweight inventory system used to track current snack counts in your home.

Overview

The idea is to keep track of snacks as they enter and exit your cupboard. This project consists of several pieces:

  • Backend gRPC service that acts as an interface above storage.
  • CLI for interacting with the backend easily.
  • A web UI for browsing the current state of the backend, and updating values as appropriate.
  • A raspberry Pi daemon, that listens to a barcode scanner and increments inventory count.

SnackInventory architecture

On initial scan, barcodes need their metadata (name & brand) filled in manually. This is cumbersome, but seamless on repeat orders of the same product.

Server Usage

The backend server acts as an interface between the user (CLI & UI) & storage. On launch, flags specific to the used storage interface must be given. Passwords are read from stdin to avoid having '--password' in shell history.

Ex: go run src/backend/server/server.go --sql_user=$USER --sql_address=127.0.0.1:3306 < ~/sql_pass.txt

Storage Model

The primary backend for the SnackInventory server is SQL. When a SQL implementation is used, an arbitrary database name can be given. Inside that database, tables "SnackRegistry" and "Locations" are assumed present.

Schema

SnackRegistry: barcode VARCHAR(20) PRIMARY KEY, name VARCHAR(255)

LocationRegistry: name VARCHAR(30)

Setup

SnackInventory is a Golang gRPC service. Setup requirements are mostly that Golang, protoc, and gRPC genrules are installed. Below instructions assume Golang is already installed for the system.

Linux / Ubuntu

Install Cobra, which powers the CLI for interacting with the backend:

  • go get -u github.com/spf13/cobra/cobra

Install protoc genrules for Go & gRPC:

  • go get google.golang.org/protobuf/cmd/protoc-gen-go
  • go install google.golang.org/protobuf/cmd/protoc-gen-go
  • go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
  • go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
  • go get google.golang.org/grpc
  • go install google.golang.org/grpc
  • sudo apt-get install protobuf-compiler

With those installed, everything should be compilable.

  • git clone $SnackInventoryURL
  • cd SnackInventory
  • go get ./...

Alternatively, the package should be installable via:

  • go get github.com/rmbarron/SnackInventory
  • go install github.com/rmbarron/SnackInventory

but that flow has not been tested yet.

MariaDB

SnackInventory primarily uses MariaDB as its backing DB. To set up a serving instance:

  • sudo apt install mariadb-server
  • sudo mysql_secure_installation - Locks down core vulnerabilities (like root user permissions)
  • sudo mysql - enter interactive DB shell for setup
  • CREATE DATABASE SnackInventory;
  • USE SnackInventory;
  • CREATE TABLE SnackRegistry ( barcode VARCHAR(20) PRIMARY KEY, name VARCHAR(255));
  • CREATE TABLE LocationRegistry ( name VARCHAR(30) PRIMARY KEY);
  • GRANT ALL PRIVILEGES ON SnackInventory.* TO '$USER'@'$NETWORK' IDENTIFIED BY '$PASSWORD' WITH GRANT OPTION;
  • FLUSH PRIVILEGES;

To allow remote connections (rather than just localhost connections):

  • Comment out bind-address = 127.0.0.1 in /etc/mysql/mariadb.conf.d/50-server.cnf
  • Restart the mariadb service: sudo systemctl restart mariadb.service

Recompiling Protos

Any changes to messages / RPCs require recompiling the generated proto code. Currently, this requires cloning into a github.com/$USER/SnackInventory/ dir. Then, from the root dir (containing githug.com), run:

  • protoc -I=github.com/$USER/SnackInventory/src/proto/snackinventory/ --go_out=./ --go-grpc_out=./ ./github.com/$USER/SnackInventory/src/proto/snackinventory/snackinventory.proto

snackinventory's People

Contributors

rmbarron avatar

Watchers

James Cloos avatar  avatar Matthew B avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.