Shelftara Documentation 1.0.0

Configuration

Every environment variable

The configuration of Shelftara is a list of environment variables. The server reads them from the process environment first, then from a .env file, and it uses the default of the table when neither has a value. This page is the complete reference of the release; it is built from internal/config/config.go, the only place where the configuration is resolved.

How the configuration is read

  • The file is looked for in this order: the path of ENV_FILE, the working directory, the directory of the executable, the parent of that directory and the grandparent of it.
  • The repository ships .env.example, a commented template that carries every variable of this page with its default value. Copy it next to the binary and complete the tokens it holds, or let the installer write the file for you.
  • The format is KEY=value, one per line. A value may be wrapped in single or double quotes. A line that starts with # is a comment, and export in front of a key is accepted.
  • A real environment variable always wins over the file. A container platform or a systemd unit can therefore override anything without editing a file.
  • A boolean accepts 1, true, yes and on for true, and 0, false, no and off for false, whatever the case.
  • An empty value is treated as "not set": the default of the table applies.
The variables that do not come from the file

ADMIN_EMAIL and ADMIN_PASSWORD are read directly from 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.

The application

VariableDefaultMeaning
APP_NAMEShelftaraThe name of the product shown in the interface.
APP_ENVproductionThe mode of the installation. The values development and testing force COOKIE_SECURE to false unless it is set explicitly, so that the cookies work on a plain HTTP address.
APP_DEBUGfalseWhen true, the server writes a line per request with the status, the latency, the method and the path, and it prints the SQL statements. Never enable it on a server that is reachable from the internet.
APP_URLhttp://localhost: + PORTThe address of the installation. It is the fallback of BASE_URL.
BASE_URLthe value of APP_URLThe public address of the installation, used for the canonical links of the marketing pages.
DOMAINlocalhostThe main domain of the installation. A host such as acme.example.com resolves the workspace acme when DOMAIN is example.com. The rule is skipped when the value is empty or localhost.
PORT8080The TCP port the server listens on. The server binds on every interface of the machine.
APP_SECRETshelftara-development-secret-change-meThe secret of the installation. Set a long random value. The sessions of 1.0.0 carry their own random identifier and do not use this secret, but it must never be the default on a real server.

The database

The connection string is built from these five values with charset=utf8mb4&parseTime=True&loc=UTC&multiStatements=false. The schema is created and kept up to date automatically when the server starts.

VariableDefaultMeaning
DB_HOST127.0.0.1The address of the MySQL server.
DB_PORT3306The port of the MySQL server.
DB_USERrootThe user that opens the connection. Use a user of its own, with the rights only on the database of Shelftara.
DB_PASSWORDemptyThe password of that user.
DB_NAMEshelftaraThe name of the database. It has to exist before the first start; the helper database.EnsureDatabase can create it.

The pool opens at most sixty connections, keeps ten of them idle and retires them after an hour.

The sessions and the cookies

VariableDefaultMeaning
SESSION_COOKIEshelftara_sessionThe name of the cookie that carries the identifier of the session.
CSRF_COOKIEshelftara_csrfThe name of the cookie that carries the CSRF token. The scripts of the register read this name literally: if you rename the cookie, change the script too, or the register stops working.
COOKIE_SECUREtrueSends the cookies only over HTTPS. It is forced to false in the modes development and testing, unless you set it yourself.
SESSION_TTL_HOURS720The lifetime of a session in hours, and the lifetime of the cookies. Thirty days by default. The expired sessions are purged every thirty minutes.

The storage

VariableDefaultMeaning
STORAGE_DIRstorageThe root of the storage of the installation. A relative path is resolved against the working directory of the process.
UPLOAD_DIRstorage/uploadsThe folder that holds the uploaded files. The server creates it when it is missing, and it is the only folder the application writes in. A relative path is resolved against the working directory of the process.

The modes of the installation

VariableDefaultMeaning
SEED_DEMOfalseFills the demo workspace on the first start: a coffee roastery with 24 products, 45 days of documents, three users and the records of every module. The seed never runs twice: if the workspace already holds products, nothing is written.
DEMO_MODEfalseReserved for a later release. The variable is read in 1.0.0 but no behaviour of the server depends on it.
STORE_ENABLEDtrueReserved for a later release. The shop of a workspace is opened per workspace, in its store settings, and that flag does not change it in 1.0.0.

The locale, the money and the dates

VariableDefaultMeaning
CURRENCYUSDThe currency used by the panel, by the reports and by the assistant.
LOCALEenThe locale that a workspace receives when it is created, either from the registration form or from the platform console.
TIMEZONEUTCThe time zone that a workspace receives when it is created. Every timestamp is stored in UTC and the connection uses loc=UTC, so the zone of the workspace is a matter of display only.
DATE_FORMAT2006-01-02The Go layout of the dates. The variable is read in 1.0.0, but the templates of the release use their own format.

The headers of the security

VariableDefaultMeaning
FRAME_OPTIONSSAMEORIGINThe value of the header X-Frame-Options. The value none sends no header at all, and any other value is sent as it is.
FRAME_ANCESTORSemptyThe origins that may frame the application. When it is not empty, the server sends the header Content-Security-Policy: frame-ancestors <value>. An empty value sends no policy.

Two headers are always sent: X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin.

The mail

VariableDefaultMeaning
MAIL_DRIVERlogThe transport of the outgoing mail. No transport is wired in 1.0.0: the form of the forgotten password records the reset code in the table of the codes and shows the same message whether the address exists or not.
SMTP_HOSTemptyThe address of the SMTP server.
SMTP_PORT587The port of the SMTP server.
SMTP_USERemptyThe user of the SMTP server.
SMTP_PASSWORDemptyThe password of the SMTP server.
MAIL_FROMno-reply@shelftara.testThe sender address of the outgoing mail.

The assistant

VariableDefaultMeaning
AI_PROVIDERlocalThe provider of the assistant. The assistant of 1.0.0 answers from the database of the installation and never calls an external service.
ANTHROPIC_API_KEYemptyThe key of the external provider. It is read in 1.0.0 and not used; the assistant works without a key and without a network.
AI_MODELclaude-sonnet-5The model of the external provider. It is read in 1.0.0 and not used.
AI_ASSISTANTtrueThe flag of the assistant. The page and the endpoint of the assistant are always available in 1.0.0.

The support and the analytics

VariableDefaultMeaning
SUPPORT_EMAILsupport@shelftara.testThe address shown to the visitors on the contact page of the marketing site. It belongs to the operator of the installation, not to the author of the product.
ANALYTICS_IDemptyThe identifier of an analytics property. It is read in 1.0.0 and not used: no script of an external service is loaded by the pages of the release.

The variables of the first start

VariableDefaultMeaning
ADMIN_EMAILadmin@shelftara.testThe address of the platform administrator that the first start creates. Read from the process environment only.
ADMIN_PASSWORDShelftaraAdmin1The password of that administrator. It must have at least eight characters, and it is hashed with bcrypt before it is stored. Read from the process environment only.
ENV_FILEnot setThe path of an alternative .env file. It is tried before the usual locations.
A complete example
APP_NAME=Shelftara
APP_ENV=production
APP_DEBUG=false
APP_URL=https://inventory.example.com
BASE_URL=https://inventory.example.com
DOMAIN=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
SMTP_HOST=
SMTP_PORT=587
SMTP_USER=
SMTP_PASSWORD=
MAIL_FROM=no-reply@inventory.example.com

AI_PROVIDER=local
AI_ASSISTANT=true

SUPPORT_EMAIL=support@example.com

The configuration of a production server

  • APP_ENV=production and APP_DEBUG=false.
  • A long random APP_SECRET.
  • COOKIE_SECURE=true, and the installation really behind TLS.
  • APP_URL and BASE_URL on the public address of the server, and DOMAIN on the domain that carries the workspaces.
  • A database user of its own, with the rights only on the database of Shelftara.
  • SEED_DEMO=false.
  • UPLOAD_DIR on a folder the service account owns, and nothing else writable.
  • FRAME_OPTIONS=SAMEORIGIN and FRAME_ANCESTORS left empty, or set to the origins that really frame the panel.