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
| Variable | Default | Meaning |
APP_NAME | Shelftara | The name of the product shown in the interface. |
APP_ENV | production | The 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_DEBUG | false | When 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_URL | http://localhost: + PORT | The address of the installation. It is the fallback of BASE_URL. |
BASE_URL | the value of APP_URL | The public address of the installation, used for the canonical links of the marketing pages. |
DOMAIN | localhost | The 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. |
PORT | 8080 | The TCP port the server listens on. The server binds on every interface of the machine. |
APP_SECRET | shelftara-development-secret-change-me | The 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.
| Variable | Default | Meaning |
DB_HOST | 127.0.0.1 | The address of the MySQL server. |
DB_PORT | 3306 | The port of the MySQL server. |
DB_USER | root | The user that opens the connection. Use a user of its own, with the rights only on the database of Shelftara. |
DB_PASSWORD | empty | The password of that user. |
DB_NAME | shelftara | The 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
| Variable | Default | Meaning |
SESSION_COOKIE | shelftara_session | The name of the cookie that carries the identifier of the session. |
CSRF_COOKIE | shelftara_csrf | The 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_SECURE | true | Sends the cookies only over HTTPS. It is forced to false in the modes development and testing, unless you set it yourself. |
SESSION_TTL_HOURS | 720 | The 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
| Variable | Default | Meaning |
STORAGE_DIR | storage | The root of the storage of the installation. A relative path is resolved against the working directory of the process. |
UPLOAD_DIR | storage/uploads | The 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
| Variable | Default | Meaning |
SEED_DEMO | false | Fills 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_MODE | false | Reserved for a later release. The variable is read in 1.0.0 but no behaviour of the server depends on it. |
STORE_ENABLED | true | Reserved 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
| Variable | Default | Meaning |
CURRENCY | USD | The currency used by the panel, by the reports and by the assistant. |
LOCALE | en | The locale that a workspace receives when it is created, either from the registration form or from the platform console. |
TIMEZONE | UTC | The 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_FORMAT | 2006-01-02 | The Go layout of the dates. The variable is read in 1.0.0, but the templates of the release use their own format. |
The mail
| Variable | Default | Meaning |
MAIL_DRIVER | log | The 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_HOST | empty | The address of the SMTP server. |
SMTP_PORT | 587 | The port of the SMTP server. |
SMTP_USER | empty | The user of the SMTP server. |
SMTP_PASSWORD | empty | The password of the SMTP server. |
MAIL_FROM | no-reply@shelftara.test | The sender address of the outgoing mail. |
The assistant
| Variable | Default | Meaning |
AI_PROVIDER | local | The 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_KEY | empty | The 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_MODEL | claude-sonnet-5 | The model of the external provider. It is read in 1.0.0 and not used. |
AI_ASSISTANT | true | The flag of the assistant. The page and the endpoint of the assistant are always available in 1.0.0. |
The support and the analytics
| Variable | Default | Meaning |
SUPPORT_EMAIL | support@shelftara.test | The 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_ID | empty | The 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
| Variable | Default | Meaning |
ADMIN_EMAIL | admin@shelftara.test | The address of the platform administrator that the first start creates. Read from the process environment only. |
ADMIN_PASSWORD | ShelftaraAdmin1 | The 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_FILE | not set | The 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.