Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Overview

Documentation of StrichRListe.

For Admins

Deployment and configuration are documented in deployment and config respectively.

For Users

API Documentation is located at API.

For Developers

The development workflow and specifics are documented at development.

Deployment

Currently the only officially supported deployment method is through a container.

Docker/Podman

Releases of StrichRListe are available as a OCI image for linux/amd64 and linux/arm64.

Available registries:

Supported tags:

  • latest: latest tagged release
  • {major}: latest tagged minor release within this major version
  • {major}.{minor}: latest tagged patch release in this minor version
  • {major}.{minor}.{patch}: exact version

The config and database in the containers is located in /strichrliste/data.

Compose

Compose example:

services:
  strichrliste:
    image: fregrem/strichrliste:latest
    ports:
      - "3000:3000"
    restart: always
    volumes:
      - "./data:/strichrliste/data"

Podman Quadlet

Quadlet Example:

[Unit]
Description=Reimplementation of strichliste with some extras
After=network-online.target

[Container]
Image=docker.io/fregrem/strichrliste:latest
AutoUpdate=registry
PublishPort=3000:3000
Volume=%h/strichrliste:/strichrliste/data

[Service]
Restart=on-failure

[Install]
WantedBy=default.target

Config

Configuration is possible through both environment variables and a config file. Environment variables take precedence over the config file.

All available options are shown and described in the example config file.

Environment

Config variables start with STRICHRLISTE_. Nested options are separated with double underscores (__).

# Port to bind to.
STRICHRLISTE_PORT=3000

# Set the upper balance limit for accounts in cents.
STRICHRLISTE_BOUNDARIES__ACCOUNT_UPPER=20000

File

The config file is read from data/config.toml.

In the container it is located at /strichrliste/data/config.toml

Example

# Address to bind to.
url = "0.0.0.0"

# Port to bind to.
port = 3000

# Directory the frontend files are located in.
frontend_dir = "frontend"

# Set the timeout a transaction can be undone in seconds. If `false`, users are always allowed to
# undo. To disable undo, set to `0`.
undo_timeout = 600

# Set the duration a user will remain as active after their last interaction (transaction/edit).
# If `false`, users are always active.
user_timeout = 86400

# Set the used currency for the instance. Mainly used for frontend.
currency = "euro"


# Set boundaries for accounts, transactions and the inventory.
[boundaries]
# Set the upper balance limit for accounts in cents. `false` is equal to the upper i32 limit.
account_upper = 20000

# Set the lower balance limit for accounts in cents. `false` is equal to the lower i32 limit.
account_lower = -10000

# Set the (positive/negative) monetary transaction limit. `false` is equal to the i32 limit.
transaction = 10000

# Set the maximum allowed stock. `false` is equal to the upper i32 limit.
#
# If both this and 'inventory_lower' are `false`, all articles are reported as infinitely available
# through faking an override.
inventory_upper = 1000

# Set the minimum allowed stock. `false` is equal to the lower i32 limit.
#
# If both this and 'inventory_upper' are `false`, all articles are reported as infinitely available
# through faking an override.
inventory_lower = 0


# Set options for the backend storage.
[storage]
# Set used storage method.
# Possible values: sqlite
driver = "sqlite"

# If needed, set file location for the storage.
file = "data/database.db"


# Set which features are enabled for the instance.
[capabilities]
# Toggles the builtin frontend. Frontend related information will still be available through the
# api.
frontend = true

# Toggles the article system. Also disables `compensations` if disabled.
articles = true

# Allows to rebalance articles without money transfer.
# `articles` has to be enabled for the feature to work.
compensations = true

# Toggles the inventory system.
inventory = true

# Toggles the ability to optionally set per article inventory boundaries.
inventory_override = true

# Toggles the possibility to set a custom price when filling up articles.
custom_purchase_price = true

# Toggles the possibility for users to directly send money between them.
user_transactions = true


# Sets default options for the frontend.
# Frontend options are passed one to one to the frontend and aren't used by the backend.
[frontend]
# Should the article section on a users page be automatically opened.
auto_open_articles = true

# Values that should be set in the deposit section on a users page.
deposit = [
    100,
    200,
    500,
    1000,
    2000,
]

# Values that should be set in the dispense section on a users page.
dispense = [
    100,
    200,
    500,
    1000,
    2000,
]

# Percentage of random sounds being used, from 0 to 1.
random_sounds = 0.02

# Info shown on cash payment site
cash_info = "register cash payments"

API

StrichRListe API (0.11.0)

AGPL-3.0-or-later

StrichRListe API to access all functions of the server Base path of all api functionality is located at /api


Paths

GET /

Info

Response at the root level of the api

Responses
  • 200: string (text/plain)

GET /article

Get all articles

Responses
  • 200: Article (application/json)
  • 500: string (text/plain)

POST /article

Create article

Request

CreateArticle (application/json)

Responses
  • 201: Article (application/json)
  • 500: string (text/plain)

GET /article/label/{label}

Get articles by label

Responses
  • 200: array of Article (application/json)
  • 500: string (text/plain)

GET /article/search/{term}

Search article

Responses
  • 200: array of Article (application/json)
  • 500: string (text/plain)

GET /article/{article}/compensation

Get all compensations for a specific article

Responses
  • 200: Compensation (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

POST /article/{article}/compensation

Compensate Inventory

Request

CreateCompensation (application/json)

Responses
  • 201: Compensation (application/json)
  • 400: string (text/plain)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /article/{id}

Get single article

Responses
  • 200: Article (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

POST /article/{id}

Update article

Request

CreateArticle (application/json)

Responses
  • 200: Article (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

DELETE /article/{id}

Deactivate article

Responses
  • 200: Article (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /article/{id}/transaction

Get all article transactions

Responses
  • 200: array of Transaction (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /compensation

Get all compensations

Responses
  • 200: array of Compensation (application/json)
  • 500: string (text/plain)

GET /compensation/{id}

Get compensation

Request a specific compensation by id.

Responses
  • 200: Compensation (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /settings

Settings

Get all settings that can be used for the frontend.

Responses

GET /transaction

Get all transactions

Responses
  • 200: array of Transaction (application/json)
  • 500: string (text/plain)

POST /transaction

Create transaction

Request

CreateTransaction (application/json)

Responses
  • 201: Transaction (application/json)
  • 500: string (text/plain)

GET /transaction/{id}

Get single transaction

Responses
  • 200: Transaction (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

DELETE /transaction/{id}

Undo transaction

Responses
  • 200: Transaction (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /user

Get all users

Responses
  • 200: array of User (application/json)
  • 500: string (text/plain)

POST /user

Create user

Request

CreateUser (application/json)

Responses
  • 201: array of User (application/json)
  • 500: string (text/plain)

GET /user/search/{term}

Search users

Responses
  • 200: User (application/json)
  • 500: string (text/plain)

GET /user/{id}

Get single user

Responses
  • 200: User (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

POST /user/{id}

Update user

Request

CreateUser (application/json)

Responses
  • 200: User (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

DELETE /user/{id}

Delete user

“Deletes” the user. User is set to deleted, but actual data is kept.

Responses
  • 200: User (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

GET /user/{id}/transaction

Get all user transactions

Responses
  • 200: array of Transaction (application/json)
  • 404: string (text/plain)
  • 500: string (text/plain)

Components

Article

Everything about an article in storage and while working with it.

propertytypedescriptiondefault
activebooleanIs the article active.-
barcodesstring[]Optional barcode mainly to be used in barmode in the frontend.-
createdintegerTimestamp of the article creation-
idintegerUnique id, gets allocated by the storage backend.-
inventoryintegerStock of the article-
inventory_overrideInventoryInventory boundary override for this article.-
labelsstring[]Optional labels for sorting in the frontend.-
namestringArticle name, only one article with the same name can be active at the same time.-
pricesPrice[]Versioned price information for the article-
usage_countintegerHow often has the article been bought.-

Boundaries

Describes all configured limits for actions and objects.

propertytypedescriptiondefault
account_lowerintegerSet the lower balance limit for accounts in cents.
No value equals i32::MIN.
-10000
account_upperintegerSet the upper balance limit for accounts in cents.
No value equals i32::MAX.
20000
inventoryInventorySets the type of override for inventory boundaries-
transactionintegerSet the (positive/negative) monetary transaction limit.
None equals i32::MAX/i32::MIN.
10000

Capabilities

Describes all toggleable features for the instance.

propertytypedescriptiondefault
articlesbooleanToggles the article system.
Also disables compensations if disabled.
true
compensationsbooleanAllows to rebalance articles without money transfer.
articles has to be enabled for the feature to work.
true
custom_purchase_pricebooleanToggles the possibility to set a custom price when filling up articles.true
frontendbooleanToggles the builtin frontend. Frontend related information will still be available through
the api.
true
inventorybooleanToggles the inventory system.true
inventory_overridebooleanToggles the ability to optionally set per article inventory boundaries.true
user_transactionsbooleanToggles the possibility for users to directly send money between them.true

Compensation

External representation of a compensation. Compensations are used to allow changing the inventory of an Article without affecting a user.

propertytypedescriptiondefault
amountintegerAmount of articles that are compensated-
articleintegerArticle the compensation applies to-
createdintegerTimestamp of the compensations creation-
idintegerUnique id-
reasonCompensationReasonReason the compensation has to be done-

CompensationReason

Reason the compensation has to be done

  • bar: Bar transaction used to pay article
  • shrinkage: Compensate for missing articles noticed during inventory taking
  • enlargement: An article is bought without a user taking credit
  • buy: An article is bought without a user taking credit (e.g. cash payments)
  • error: Compensation for error in prior compensation

string “bar”|“shrinkage”|“enlargement”|“buy”|“error”

CreateArticle

Representing needed values to crate/update a new Article. When updating, all values have to be filled out with their new values, even when not changing them.

propertytypedescriptiondefault
activeboolean-
barcodesstring[]Optional barcode mainly to be used in barmode in the frontend.-
costintegerCost of the article in cents.-
inventory_overrideInventoryInventory boundary override for this article.-
labelsstring[]Optional labels to tag an article-
namestringArticle name, only one article with the same name can be active at the same time.-
purchase_priceintegerThe amount of money a user receives when filling up the article. If unset, defaults to
cost. Can be overridden by the user if
custom_purchase_price in Capabilities is true.
-

CreateCompensation

Representing values needed to create a new Compensation.

propertytypedescriptiondefault
amountintegerAmount of articles that are compensated-
reasonCompensationReasonReason the compensation has to be done-

CreateTransaction

Representing the possible information for creating a new Transaction.

propertytypedescriptiondefault
amountintegerIf article given functions as article amount, if not as cents.
Negative article amount means filling up the article.
-
articlestringOptional article, if given changes how the amount works.-
commentstringOptional comment to the transaction. Can be shown in frontend.-
purchase_overridePurchaseOverrideUser override for purchase_price of an Article. Only allowed if
custom_purchase_price in Capabilities is true in the Settings.
-
recipientstringSet if users send money between them.-
userstringMain user affected by the transaction.-

CreateUser

Struct representing the needed possible values for a Users creation. All other values are calculated/generated. When updating all values have to be filled out.

propertytypedescriptiondefault
emailstringOptional email of the user.-
namestringUsername-

Currency

Available currencies, used for the frontend.

string “euro”

Frontend

Config usable for a frontend

propertytypedescriptiondefault
auto_open_articlesbooleanShould the article section on a users page be automatically opened.true
cash_infostringInfo shown on cash payment siteregister cash payments
depositinteger[]Values that should be set in the deposit section on a users page.[100, 200, 500, 1000, 2000]
dispenseinteger[]Values that should be set in the dispense section on a users page.[100, 200, 500, 1000, 2000]
random_soundsnumberPercentage of the random sounds being used, from 0 to 1.0.019999999552965164

Inventory

Sets the type of override for inventory boundaries

One of:

string “infinite” or:

propertytypedescriptiondefault
boundInventoryBoundCustom override. If a value isn’t set, it counts as i32::MAX/i32::MIN.-

InventoryBound

Upper and lower bounds for bound in Inventory.

propertytypedescriptiondefault
lowerintegerLower inventory limit, unset equals to i32::MIN.-
upperintegerUpper inventory limit, unset equals to i32::MAX.-

Price

Versioned price information for Articles

propertytypedescriptiondefault
costintegerCost of the article-
createdintegerTimestamp of the creation of this price version-
purchase_priceintegerThe amount of money a user receives when filling up the article. If unset, defaults to
cost. Can be overridden by the user if custom_purchase_price in the Capabilities is true.
-
versionintegerVersion of the Price information-

PurchaseOverride

Struct used for overriding the set purchase price of an article when filling.

propertytypedescriptiondefault
unitintegerUnit of the override, as in amount of the product costing value.-
valueintegerValue of the override-

Settings

Representing the backend config with the necessary info for a frontend or user

propertytypedescriptiondefault
boundariesBoundariesBoundaries for accounts, transactions and the inventory.-
capabilitiesCapabilitiesWhich features are enabled for the instance.-
currencyCurrencyUsed Currency for the instance. Mainly used for frontend.euro
frontendFrontendDefault options for the frontend.
Frontend options are passed one to one to the frontend and are otherwise ignored by the backend.
-
undo_timeoutintegerSet the timeout a transaction can be undone in seconds. If no value is set users are always
allowed to undo. If set to 0, undo is disabled.
600
user_timeoutintegerTime a user will be set as active after their last interaction (transaction/edit).86000

Transaction

Struct representing everything about a single transaction.

propertytypedescriptiondefault
amountintegerIf article given functions as article amount, if not as cents.
Negative article amount means filling up the article.
-
articleintegerOptional article, if given changes how the amount works. Requires price_version to be
set
-
commentstringOptional comment to the transaction. Can be shown in frontend.-
createdintegerTimestamp of the transactions creation-
deletedbooleanHas the transaction been undone.-
idintegerUnique id, gets allocated by the storage backend.-
isdeletablebooleanShows if the transaction can be undone by a user.-
price_versionintegerVersion of the article price, has to be set if article is set.-
purchase_overridePurchaseOverrideUser override for purchase_price of an Article. Only allowed if
custom_purchase_price in Capabilities is true in the Settings.
-
recipientintegerSet if users send money between them.-
userintegerMain user affected by the transaction.-

User

Everything about an user in storage and while working with it.

propertytypedescriptiondefault
activebooleanHas the user been active over a certain time, set in the Settings with user_timeout.-
balanceintegerCurrent balance of the user in cent-
createdintegerTimestamp of the users creation-
deletedbooleanHas the user been deleted? Deletion is only reversible with direct database access.-
emailstringOptional email of the user.-
idintegerUnique id, gets allocated by the storage backend.-
modifiedintegerTimestamp of the last modification to the user (transaction/edit)-
namestringUsername-

Development

General Workflow

The project is built and developed with make.

To build and start the server in debug mode run make dev. This builds everything necessessary and runs the backend binary. By default the server runs on 0.0.0.0:3000.
For frontend javascript development make js can be used while the server is running.

Checks / Tests

The whole project can be checked with make check.

For just the frontend checks biome ci can be used. This is enough if working on the frontend and much faster than running all backend checks.

Currently tests are only used for the backend, and are run with make test.

Layout

Backend (src/, tests/, build.rs)

src/:

  • api.rs / api/: contains all api related functions
  • config.rs: contains the config definition and code to load the config
  • entity.rs / entity/: contains the definition and code for all components
  • error.rs: internal and external error definition
  • lib.rs: core library exposing definitions and functions
  • main.rs: binary entry point, containing the server and api
  • money.rs: definition for different money types
  • storage.rs / storage/: code for the storage backend

tests/: contains all backend tests

build.rs: dynamically integrates git hash for debug builds

Frontend (frontend/, assets/, biome.json)

frontend/: contains all frontend code as it is served
assets/: contains all assets used in the frontend

biome.json: config file for biome

Docs (docs/)

docs/:

  • book.toml: mdbook configuration
  • src/: markdown source code of the documentation
  • theme/: custom theme/favicon declaration for mdbook
  • mdbook-oasma: mdbook preprocessor to integrate API.md
  • API.md: from openapi.json generated API documentation

Contrib (contrib/)

Contains standalone useful scripts for development or deployment.

contrib/:

  • migrate.py: migrate from a strichliste instance to strichrliste \
  • release.sh: script used to get the repo ready for a release