SlotDB
SlotDB is an application designed to store information about property or assets, to be able to query on that information, and implement basic schemas.
Use cases:
- Warehousing — Keep track of warehouse locations, available stock and more.
- Hospitality — Manage inventory of rooms or camping spots, together with availability, price rates, available amenities, current guest etc.
- Restaurants — Keep track of tables and orders.
- Shows and Events — Allocate seating, with information on the guest and what level ticket was purchased.
Installing
Docker
$ docker run -it \
-p 8080:8080
-v $PWD/slotdb.json:/app/slotdb.json \
dev.noccylabs.info/slotdb/slotdb
Debian
$ sudo curl https://dev.noccylabs.info/api/packages/slotdb/debian/repository.key -o /etc/apt/keyrings/gitea-slotdb.asc
$ echo "deb [signed-by=/etc/apt/keyrings/gitea-slotdb.asc] https://dev.noccylabs.info/api/packages/slotdb/debian any main" \
| sudo tee -a /etc/apt/sources.list.d/gitea.list
$ sudo apt update
$ sudo apt install slotdb
Build from source
$ composer install
$ make phar
Configuration
Security
Note
Security is not yet implemented. This section is a draft of how things may work.
Security is configured using an ACL embedded in the JWT. Each entry in the ACL follows the following format:
[groupid#][slot][.prop][/access]
¯¯¯¯¯¯¯¯\¯¯¯¯¯¯\¯¯¯¯¯\ ¯¯¯¯¯¯¯\
\ \ \ Can be either '/rw' (default), '/r' or '/w'
\ \ Property name or wildcard pattern (default: .*)
\ Slot ID or wildcard pattern (default: *)
Group ID
Examples:
ACE | Meaning |
---|---|
/rw , * , */rw |
Read and write everything |
*/r |
Read-only access to everything |
A# |
Read and write everything in group 'A' |
room*.x-* |
Read and write all properties starting with 'x-' on slots starting with 'room' |
.available/rw |
Read and write the 'available' property on all slots, and nothing else |
Using the API
For the full API, see doc/slotdb.openapi.yaml.
Creating some slots
To create slot:
$ curl -XPOST -Hcontent-type:application/json --data \
'[{"slot":"A1","name":"Room A1"},{"slot":"A2","name":"Room A2"}]' \
http://127.0.0.1:8080/api/slotdb/v1/slots
The created slots will be returned.
Creating groups
To create group:
$ curl -XPOST -Hcontent-type:application/json --data \
'[{"group":"A","name":"Building A"}]' \
http://127.0.0.1:8080/api/slotdb/v1/groups
Add members using the special _members
property, and set some properties
while we're at it:
$ curl -XPOST -Hcontent-type:application/json --data \
'{"_members":{"A1":true,"A2":true},"rate":399,"available":true}' \
http://127.0.0.1:8080/api/slotdb/v1/group/A
To remove a member, set it to false
rather than true
.
Updating slots
Set properties:
$ curl -XPOST -Hcontent-type:application/json --data \
'{"available":false}' \
http://127.0.0.1:8080/api/slotdb/v1/slot/A1
Querying slots
Get all slots:
$ curl http://127.0.0.1:8080/api/slotdb/v1/slots
Only get the available slots:
$ curl http://127.0.0.1:8080/api/slotdb/v1/slots?where[]=available:1
Get the slots in a group:
$ curl http://127.0.0.1:8080/api/slotdb/v1/group/A/members
Languages
PHP
98.2%
Makefile
1.2%
Dockerfile
0.6%