Shelftara Documentation 1.0.0

Installation

Install Shelftara on your own server

Shelftara is a single Go binary with an embedded asset bundle and an embedded template set. Nothing else is required to run it: there is no front-end build, no package manager and no external service other than MySQL. The installation creates the schema itself on the first start.

Requirements

ComponentMinimumNotes
Go toolchain1.23 or newerOnly needed on the machine that builds the binary. The go.mod of this release declares go 1.26.0, so build with a Go 1.26 toolchain to stay on the version the release was compiled with.
MySQL8.0Or MariaDB 10.6 or newer. The schema uses utf8mb4 and the connection is opened with parseTime=True and loc=UTC.
Web servernginx, Apache or CaddyRecommended in front of the binary for TLS, compression of the static assets and the X-Forwarded-* headers. The binary also serves the site on its own.
Disk1 GBFor the database, the uploads and the logs. The uploads grow with the pictures of the catalogue.
Memory512 MBThe connection pool opens at most 60 connections and keeps 10 idle.
Service accountan unprivileged userSee file permissions. The server never needs root.

Path A — the one-click installer

The repository ships install.sh, an installer for Debian and Ubuntu. It prepares a whole server in one pass: it checks the prerequisites, creates the system account and the directories, creates the database and its user, compiles the binary, writes the configuration, registers the systemd unit, installs the nginx site and checks that the installation answers.

sudo bash install.sh --domain shop.example.com --email you@example.com \
  --admin-email admin@example.com --admin-password 'a-strong-password'

The script may be run several times on the same machine: every step looks at what is already there before it changes it. The password of the database is generated when it is not given, and the credentials of the administrator are written in /etc/shelftara/admin-credentials.txt.

OptionWhat it does
--dir <path>The directory of the installation. /opt/shelftara by default.
--db-name <name>The name of the database. shelftara by default.
--db-user <name>The user of the database. shelftara by default.
--db-pass <password>The password of the database user. A random one is generated when the option is missing.
--domain <name>The domain of the installation, for example shop.example.com.
--email <address>The address of the operator. It becomes the support address of the installation.
--admin-email <address>The address of the platform administrator.
--admin-password <password>The password of the platform administrator.
--port <port>The port the server listens on. 8080 by default.
--binary <path>A binary that is already built, used with --no-build.
--no-buildDoes not compile the sources; it installs the binary given with --binary.
--skip-databaseDoes not create the database and does not touch its user.
-h, --helpPrints the same list on the screen.

The installer writes the configuration in /etc/shelftara/shelftara.env, registers /etc/systemd/system/shelftara.service and installs /etc/nginx/sites-available/shelftara.conf. The deployment guide of the repository describes that layout in more detail.

Working on a laptop

For a local workstation, the repository also ships scripts/dev-up.sh. It starts a local MariaDB when none is running, creates the database and the user, builds the binary, creates the storage folders and starts the server in the background. It is the fastest way to see the product without touching a production machine.

cd /path/to/shelftara
./scripts/dev-up.sh
# shelftara health: 200
For development, not for production

The script starts the database as the mysql system user and leaves the server in a detached session. Use it to look at the product. For a real installation, follow path A or path B.

Path B — manual build and service

This is the installation we recommend on a real server. It takes five minutes and it leaves you with a binary, a service and a reverse proxy.

1. Create the account and the directory

sudo useradd --system --home /opt/shelftara --shell /usr/sbin/nologin shelftara
sudo mkdir -p /opt/shelftara/{bin,storage/uploads,logs}
sudo chown -R shelftara:shelftara /opt/shelftara

2. Build the binary

Build it on a machine with Go and copy the result, or build it directly on the server when a toolchain is available. The binary embeds the templates and the static assets, so it must not be separated from its own internal/web/views and internal/web/static folders — it does not need them at runtime.

go build -trimpath -ldflags "-s -w" -o bin/shelftara ./cmd/shelftara
sudo install -m 0755 bin/shelftara /opt/shelftara/bin/shelftara

3. Create the database

CREATE DATABASE shelftara CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'shelftara'@'127.0.0.1' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON shelftara.* TO 'shelftara'@'127.0.0.1';
FLUSH PRIVILEGES;

4. Write the configuration

The server reads a .env file from the working directory, from the directory of the executable, from its parent directory, or from the file named by ENV_FILE. Real environment variables always win over the file, which is what a container platform or a systemd unit relies on.

sudo tee /opt/shelftara/.env > /dev/null <<'EOF'
APP_NAME=Shelftara
APP_ENV=production
APP_DEBUG=false
APP_URL=https://inventory.example.com
BASE_URL=https://inventory.example.com
DOMAIN=inventory.example.com
PORT=8080
APP_SECRET=6f2a9c4e1b8d3075a6e2f4c9b1d83075

DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=shelftara
DB_PASSWORD=a-strong-password
DB_NAME=shelftara

SESSION_COOKIE=shelftara_session
CSRF_COOKIE=shelftara_csrf
COOKIE_SECURE=true
SESSION_TTL_HOURS=720

STORAGE_DIR=/opt/shelftara/storage
UPLOAD_DIR=/opt/shelftara/storage/uploads

SEED_DEMO=false
DEMO_MODE=false

CURRENCY=USD
LOCALE=en
TIMEZONE=UTC
DATE_FORMAT=2006-01-02
STORE_ENABLED=true

FRAME_OPTIONS=SAMEORIGIN
FRAME_ANCESTORS=

MAIL_DRIVER=log
MAIL_FROM=no-reply@inventory.example.com

AI_PROVIDER=local
AI_ASSISTANT=true

SUPPORT_EMAIL=support@example.com
EOF

5. Run it once to create the schema

cd /opt/shelftara
sudo -u shelftara ./bin/shelftara
# Shelftara is listening on :8080

The first start creates the 116 tables, writes the four default plans and the fifteen module definitions, creates the platform administrator and, when SEED_DEMO=true, fills the demo workspace. Stop the process with Ctrl+C and continue with the service below.

Path C — containers

No container image ships with 1.0.0

The repository of this release contains no Dockerfile and no compose file, so there is nothing to pull. The binary is a plain Linux executable with a static template bundle, so a container image is a two-line file; write it next to your own infrastructure:

FROM golang:1.26 AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o /out/shelftara ./cmd/shelftara

FROM gcr.io/distroless/static-debian12
COPY --from=build /out/shelftara /shelftara
WORKDIR /app
ENV PORT=8080 STORAGE_DIR=/app/storage UPLOAD_DIR=/app/storage/uploads
EXPOSE 8080
ENTRYPOINT ["/shelftara"]

Mount a volume on /app/storage, pass the configuration as environment variables and put your own reverse proxy in front of the container. The server binds to the port given by PORT and does not need any other port.

The configuration file

The table below is the complete list of the variables the server reads. It is built from internal/config/config.go, which is the single place where the configuration is resolved. The configuration page explains each line in more detail, and the .env.example file of the repository is a commented template of the same list.

VariableDefaultWhat it does
APP_NAMEShelftaraThe name of the product shown in the interface.
APP_ENVproductionThe mode of the installation. development and testing switch the cookies to the insecure mode unless COOKIE_SECURE is set explicitly.
APP_DEBUGfalseWhen true, the server logs every request and prints the SQL statements.
APP_URLhttp://localhost:PORTThe address of the installation.
BASE_URLthe value of APP_URLThe public address used for the canonical links of the marketing pages.
DOMAINlocalhostThe main domain. A host such as acme.example.com resolves the workspace acme when DOMAIN is example.com.
PORT8080The TCP port the server listens on.
APP_SECRETshelftara-development-secret-change-meThe secret of the installation. Replace it with a long random string.
DB_HOST127.0.0.1The address of the MySQL server.
DB_PORT3306The port of the MySQL server.
DB_USERrootThe user that opens the connection.
DB_PASSWORDemptyThe password of the database user.
DB_NAMEshelftaraThe name of the database.
SESSION_COOKIEshelftara_sessionThe name of the session cookie.
CSRF_COOKIEshelftara_csrfThe name of the CSRF cookie.
COOKIE_SECUREtrueSends the cookies only over HTTPS. Forced to false in the development and testing modes.
SESSION_TTL_HOURS720The lifetime of a session, in hours. Thirty days by default.
STORAGE_DIRstorageThe storage root of the installation.
UPLOAD_DIRstorage/uploadsThe folder that holds the uploaded files. It is created when it is missing.
SEED_DEMOfalseFills the demo workspace on the first start.
DEMO_MODEfalseReserved for a later release; it is read but nothing in 1.0.0 changes its behaviour.
CURRENCYUSDThe currency used by the panel and by the assistant.
LOCALEenThe locale given to a workspace when it is created.
TIMEZONEUTCThe time zone given to a workspace when it is created. All timestamps are stored in UTC.
DATE_FORMAT2006-01-02The Go layout of the dates. Read but not applied by the templates of 1.0.0.
STORE_ENABLEDtrueRead but not applied by 1.0.0; the storefront of a workspace is opened per workspace in its store settings.
FRAME_OPTIONSSAMEORIGINThe value of the X-Frame-Options header. The value none sends no header.
FRAME_ANCESTORSemptyThe frame-ancestors directive of the content security policy. Empty sends no policy.
MAIL_DRIVERlogThe transport of the outgoing mail. No transport is wired in 1.0.0.
SMTP_HOSTemptyThe SMTP server.
SMTP_PORT587The SMTP port.
SMTP_USERemptyThe SMTP user.
SMTP_PASSWORDemptyThe SMTP password.
MAIL_FROMno-reply@shelftara.testThe sender address of the outgoing mail.
AI_PROVIDERlocalThe provider of the assistant. The assistant of 1.0.0 answers from your own database and never calls an external service.
ANTHROPIC_API_KEYemptyThe key of the external provider. Not used by 1.0.0.
AI_MODELclaude-sonnet-5The model of the external provider. Not used by 1.0.0.
AI_ASSISTANTtrueThe flag of the assistant. The assistant answers from your own data in 1.0.0.
ANALYTICS_IDemptyThe identifier of an analytics property. Read but not applied by 1.0.0.
SUPPORT_EMAILsupport@shelftara.testThe address shown to the visitors of the marketing pages.
ENV_FILEnot setThe path of an alternative .env file, tried before the usual locations.
ADMIN_EMAILadmin@shelftara.testThe address of the platform administrator created on the first start. It is read from the process environment, not from the .env file.
ADMIN_PASSWORDShelftaraAdmin1The password of the platform administrator. Also read from the process environment.
Two variables come from the environment only

ADMIN_EMAIL and ADMIN_PASSWORD are read with a direct call to the process environment, so a line in the .env file has no effect on them. Export them in the shell, or declare them in the systemd unit, before the first start.

export ADMIN_EMAIL=operator@example.com
export ADMIN_PASSWORD=a-strong-password
./bin/shelftara

Running it as a service

Put the unit in /etc/systemd/system/shelftara.service. It reads the configuration from the .env file of the installation, restarts the server when it stops and lets the service write only inside the storage and the log folder.

[Unit]
Description=Shelftara server
Documentation=file:/opt/shelftara/README.md
After=network-online.target mysql.service
Wants=network-online.target

[Service]
Type=simple
User=shelftara
Group=shelftara
WorkingDirectory=/opt/shelftara
EnvironmentFile=/opt/shelftara/.env
ExecStart=/opt/shelftara/bin/shelftara
Restart=on-failure
RestartSec=5
KillSignal=SIGTERM
TimeoutStopSec=20
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/shelftara/storage /opt/shelftara/logs

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now shelftara
sudo systemctl status shelftara
sudo journalctl -u shelftara -f

The server handles SIGTERM and SIGINT: it stops accepting requests and closes the connections within fifteen seconds, so systemctl stop and a rolling upgrade are clean.

Set the administrator before the first start

Add Environment=ADMIN_EMAIL=operator@example.com and Environment=ADMIN_PASSWORD=... to the [Service] section before you enable the unit, or create the administrator from the login page afterwards and change the default password.

The reverse proxy

The proxy must forward the original Host header: Shelftara reads it to find the workspace of a request when the workspaces use subdomains. It must also forward the X-Forwarded-* headers, so that the address and the scheme of the visitor survive the hop.

server {
    listen 80;
    server_name inventory.example.com *.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name inventory.example.com *.example.com;

    ssl_certificate     /etc/letsencrypt/live/inventory.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/inventory.example.com/privkey.pem;

    # the body limit of the server is 64 MB, keep the two in step
    client_max_body_size 64m;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;

        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host  $host;
        proxy_set_header X-Forwarded-Port  $server_port;

        proxy_connect_timeout 10s;
        proxy_read_timeout    120s;
        proxy_send_timeout    120s;
    }

    # the assets of the interface are embedded in the binary and never change
    # without a new release
    location /assets/ {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        expires 30d;
        add_header Cache-Control "public";
    }
}
What the server does with the forwarded headers

Host drives the tenant resolution and must reach the application unchanged. The session and the audit log store the address that Fiber reports through c.IP(); the server of 1.0.0 does not rewrite it from X-Forwarded-For, so when the application and the proxy run on the same host the recorded address is the address of the proxy. Put the two on the same host, or extend the configuration of your own reverse proxy, when you need the address of the visitor in the audit log.

If you terminate TLS elsewhere, set COOKIE_SECURE=true only after the cookies really travel over HTTPS, otherwise the browser drops the session cookie.

File permissions

PathOwnerModeWhy
/opt/shelftara/bin/shelftararoot:root0755The binary is written by the administrator and only read by the service.
/opt/shelftara/.envroot:shelftara0640It holds the database password. The service account must be able to read it, nobody else.
/opt/shelftara/storageshelftara:shelftara0750The root of the uploaded files.
/opt/shelftara/storage/uploadsshelftara:shelftara0750The pictures of the catalogue and the other uploads. The server creates it when it is missing.
/opt/shelftara/logsshelftara:shelftara0750The output of the service when you redirect it to a file.

The application only ever writes inside UPLOAD_DIR. With ProtectSystem=strict and the two ReadWritePaths lines of the unit above, the rest of the file system stays read-only for the service.

A relative UPLOAD_DIR is resolved against the working directory of the process, which is why the systemd unit sets WorkingDirectory=/opt/shelftara.

The demo seed

Set SEED_DEMO=true in the .env file and start the server once. The seed creates a workspace named demo — a coffee roastery called Northwind Supply Co. — with:

  • 24 products across 5 categories and 4 brands, with barcodes, costs, prices, tax rates and stock levels;
  • 2 warehouses, 4 units of measure and a supplier and a customer list;
  • 45 days of invoices, purchases, payments, expenses and deposits;
  • three users: an owner, a cashier and a manager;
  • an online store with a coupon, an order and a review;
  • records for every business module: CRM leads, a rental contract, restaurant tables and an order, bookings, assets, employees, couriers, a shipment and a bill of materials.
RoleAddressPassword
Ownerowner@demo.testShelftaraDemo123
Managermanager@demo.testShelftaraManager1
Cashiercashier@demo.testShelftaraCashier1
Platform operatoradmin@shelftara.testShelftaraAdmin1

The seed never runs twice: if the workspace already has products, the server leaves it alone. To remove the demo afterwards, set SEED_DEMO=false and delete the workspace from /platform/tenants.

Verifying the installation

  1. curl -s http://127.0.0.1:8080/healthz must answer {"status":"ok","app":"shelftara",...}.
  2. curl -I https://inventory.example.com/ must return 200 through the proxy.
  3. Open /login, sign in with the platform administrator and create a workspace under /platform/tenants.
  4. Sign in as the owner of the new workspace and check that the dashboard opens with the figures of an empty workspace.
  5. Open /store on the subdomain of the workspace and confirm that the shop answers.

The quick start page continues from the third step with the catalogue, the register and the first order.

Upgrading and backing up

Take a dump of the database before every upgrade, stop the service, replace the binary and start it again. The schema is migrated by GORM at the start: new columns and new tables are added, nothing is dropped.

mysqldump --single-transaction --routines --triggers shelftara > shelftara-$(date +%F).sql
sudo systemctl stop shelftara
sudo install -m 0755 bin/shelftara /opt/shelftara/bin/shelftara
sudo systemctl start shelftara
journalctl -u shelftara -n 50

Copy the storage/uploads folder with the dump: the pictures of the catalogue live on the disk, the rest lives in the database.