Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Kr-Yogsa/ECE-BOT/llms.txt

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

ECE-BOT is a Flask application that can be run directly with Python for local development or containerised with Docker for production. Both approaches require a set of environment variables — most critically a PostgreSQL connection string, because the SQLite fallback has been removed. This page covers both deployment paths and the full list of required and optional variables.
PostgreSQL is required. DATABASE_URL must point to a live PostgreSQL instance. SQLite is no longer supported. If you need a managed database, services such as Neon, Supabase, or Render Postgres offer free tiers.

Environment variables

Set these variables before starting the application, either in a .env file (local Python) or as -e flags (Docker).
VariableRequiredDescription
JWT_SECRETYesSecret key used to sign JWT tokens. Use a long random string.
DATABASE_URLYesPostgreSQL connection URL, e.g. postgresql://user:pass@host/db.
APP_BASE_URLYesPublic base URL of the app, e.g. https://your-app.onrender.com.
GEMINI_API_KEYYesAPI key for the Gemini LLM fallback.
BREVO_API_KEYYesAPI key for Brevo transactional email (OTP delivery).
MAIL_FROMYesSender address for OTP emails, e.g. no-reply@your-domain.com.
MACHINE_LIVE_UPDATE_TOKENRecommendedBearer token that IoT devices must supply when pushing machine telemetry.
RUN_MQTT_WORKEROptionalSet to true to start the MQTT background worker alongside the web server.

Run locally with Python

1

Clone the repository and install dependencies

git clone https://github.com/Kr-Yogsa/ECE-BOT.git
cd ECE-BOT
pip install -r requirements.txt
2

Create a .env file

Create a .env file in the project root and fill in your values:
.env
JWT_SECRET=your-long-random-secret
DATABASE_URL=postgresql://user:password@localhost:5432/ecebot
APP_BASE_URL=http://localhost:5000
GEMINI_API_KEY=your-gemini-key
BREVO_API_KEY=your-brevo-key
MAIL_FROM=no-reply@your-domain.com
MACHINE_LIVE_UPDATE_TOKEN=your-live-update-token
# Optional: start the MQTT worker alongside the web server
# RUN_MQTT_WORKER=true
3

Start the application

python app.py
The server starts at http://localhost:5000. Flask’s built-in server is suitable for development. For production, use Gunicorn (see below).

Deploy with Docker

The Dockerfile builds a self-contained image that runs Gunicorn on port 8080. Pass environment variables with -e flags at runtime — do not bake secrets into the image.
docker build -t ece-bot .
The app is accessible at http://localhost:8080 once the container starts.
On Render, Railway, or Fly.io you can set environment variables in the platform dashboard instead of passing -e flags. Point the service’s start command to the Docker image and expose port 8080.

Gunicorn and the startup script

The repository includes start_services.sh, which the Dockerfile uses as its entrypoint. It starts Gunicorn with the appropriate worker configuration and, when RUN_MQTT_WORKER=true, launches the MQTT background worker in a separate process.
start_services.sh
#!/bin/sh
set -eu

PORT_VALUE="${PORT:-8080}"
WEB_WORKERS_VALUE="${WEB_WORKERS:-2}"
WEB_THREADS_VALUE="${WEB_THREADS:-8}"
RUN_MQTT_WORKER_VALUE="${RUN_MQTT_WORKER:-true}"

if [ "${RUN_MQTT_WORKER_VALUE}" = "true" ]; then
  echo "Starting MQTT worker..."
  python mqtt_worker.py &
fi

echo "Starting web app on port ${PORT_VALUE}..."
exec gunicorn \
  -w "${WEB_WORKERS_VALUE}" \
  --threads "${WEB_THREADS_VALUE}" \
  --worker-class gthread \
  --timeout 120 \
  --graceful-timeout 30 \
  -b "0.0.0.0:${PORT_VALUE}" \
  app:app
The MQTT worker ingests sensor telemetry from connected ESP8266 devices and writes readings to PostgreSQL. You only need it if you have physical IoT hardware sending data. See ESP8266 sensor setup for wiring and firmware instructions.

Next steps

Environment variables reference

Full reference for every configuration option.

MQTT and IoT setup

Configure the MQTT broker and connect your sensors.

ESP8266 sensor

Wire and flash the ESP8266 to publish machine telemetry.

Get started

Create an account and send your first message.

Build docs developers (and LLMs) love