Skip to main content

Configure Environment Variables

The Audit API uses a .env file for all configuration. Create and edit this file:

nano /var/www/dhis_audit_vision/.env

Full Configuration Reference

.env
# ─── Database ────────────────────────────────────────────────────────────────
DB_NAME=your_database_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=127.0.0.1
DB_PORT=5432
ENVIRONMENT=development

# ─── Server ──────────────────────────────────────────────────────────────────
HOST=0.0.0.0
PORT=8000
SERVER_DHIS2_URL=https://your-dhis2-instance-url
SERVER_DHIS2_AUTH=your_base64_encoded_credentials
SQL_VIEW_ID=InoZ6MNulN4
CONTROL_FILE_PATH=./data/control_file.json
DATA_BASE_DIR=./data

# ─── Security ────────────────────────────────────────────────────────────────
SECRET_KEY=your_secret_key_here
TOKEN_EXPIRE_MINUTES=60

# ─── Admin account ───────────────────────────────────────────────────────────
ADMIN_USERNAME=your_admin_username
ADMIN_EMAIL=your_admin_email
ADMIN_PASSWORD=your_admin_password

Variable Reference

VariableDescription
DB_NAMEName of the PostgreSQL database
DB_USERPostgreSQL user
DB_PASSWORDPostgreSQL password
DB_HOSTDatabase host (usually 127.0.0.1)
DB_PORTDatabase port (default 5432)
SERVER_DHIS2_URLFull URL of your DHIS2 instance
SERVER_DHIS2_AUTHBase64-encoded username:password credentials for the integration user
SQL_VIEW_IDID of the SQL View in DHIS2 (pre-configured as InoZ6MNulN4)
SECRET_KEYRandom secret key for JWT token signing
TOKEN_EXPIRE_MINUTESSession token expiry in minutes
ADMIN_USERNAMEUsername for the Audit Vision admin account
ADMIN_EMAILEmail for the Audit Vision admin account
ADMIN_PASSWORDPassword for the Audit Vision admin account

Run Migrations and Seeders

After configuring the .env file, run database migrations and initialize the audit system:

alembic revision --autogenerate -m "Create all tables"
alembic upgrade head
python3 commands.py start-audit

Next Steps