Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/InnoDev69/StockManager/llms.txt

Use this file to discover all available pages before exploring further.

StockManager reads all runtime configuration from a .env file in the project root. The python-dotenv library loads this file automatically at boot — both in main.py (desktop mode) and in tools/email.py (for email delivery). Every setting listed below can be overridden by a real environment variable already present in the shell, which takes precedence over the file.

Environment Variables

Application Security

Never use the default secret key ("a") in any environment where the application is accessible to real users. A predictable secret key allows session cookies to be forged, granting unauthorized access to any account.
VariableRequiredDefaultDescription
FLASK_SECRET_KEYYes"a"Signs and verifies Flask session cookies. Use a long, random string (e.g. output of python -c "import secrets; print(secrets.token_hex(32))") in production.

Email (Password Resets)

StockManager sends password-reset codes by email. All four variables must be set for email delivery to work; the application will raise an error at startup if they are absent and a reset is attempted.
VariableRequiredDescription
SMTP_SERVERYesHostname of your SMTP relay (e.g. smtp.gmail.com).
SMTP_PORTYesSMTP port number (e.g. 465 for SMTP_SSL).
SMTP_USERNAMEYesLogin username for the SMTP server; also used as the From address.
SMTP_PASSWORDYesPassword or app-specific token for SMTP authentication.

Developer Flags

VariableRequiredDefaultDescription
APP_ENVNounsetSet to "development" to enable DEBUG-level log output. When unset the logger defaults to INFO level.
DEBUGNounsetSet to 1 to start Flask in debug mode via run-dev.py. Has no effect when running main.py directly (debug is hardcoded to False there).
DB_PATHNo./data/stock.dbOverride the SQLite file path in development mode. Ignored when the app is running as a compiled executable.

Linux Display Flags

These two variables are set automatically by main.py on Linux using os.environ.setdefault, so you only need to set them explicitly if you are running the server headlessly or are overriding the defaults.
VariablePlatformDescription
PYWEBVIEW_GTKLinux onlySet to 1 to force the GTK backend for PyWebView.
WEBKIT_DISABLE_DMABUF_RENDERERLinux onlySet to 1 to disable DMA-BUF rendering in WebKitGTK, which resolves black-screen or blank-window issues on some GPU drivers.

Sample .env File

# ── Required ──────────────────────────────────────────────
FLASK_SECRET_KEY=replace-this-with-a-long-random-string

# ── Email – password reset ─────────────────────────────────
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
SMTP_USERNAME=your-address@gmail.com
SMTP_PASSWORD=your-app-password

# ── Development ────────────────────────────────────────────
APP_ENV=development
DEBUG=1
DB_PATH=./data/stock.db

Waitress Server Settings

The following Waitress parameters are hardcoded in main.py and are not configurable via environment variables.
SettingValueDescription
host127.0.0.1IP address the Waitress server binds to. Loopback-only; the PyWebView window connects to this same address.
port5000TCP port Waitress listens on. The PyWebView window connects to this same port.
threads8Number of worker threads in the Waitress thread pool.
channel_timeout30 sSeconds before an idle HTTP connection is closed.
cleanup_interval10 sHow often Waitress sweeps for expired channels.
MAX_CONTENT_LENGTH16 MBMaximum allowed size for incoming request bodies (set on the Flask app).

Background Scheduler Tasks

Two periodic tasks are registered with the built-in Scheduler in main.py before the server starts:
IntervalTaskDescription
Every 86 400 s (24 h)logger._cleanup_old_logsDeletes log files older than 3 days from the logs directory.
Every 1 800 s (30 min)db._check_unique_root_userVerifies that exactly one ROOT-role user exists; raises a critical error if more than one is found.
The scheduler runs each task in its own daemon thread and handles exceptions internally so a failing task does not crash the server.

Build docs developers (and LLMs) love