Skip to content

Configuration

FenLiu is configured via environment variables in a .env file.

Basic Setup

Create .env in the project root:

# Database
DATABASE_URL=sqlite:///./fenliu.db

# Fediverse
DEFAULT_INSTANCE=mastodon.social
API_TIMEOUT=30
MAX_POSTS_PER_FETCH=20

# Application
DEBUG=false
SECRET_KEY=your-secret-key-here
APP_NAME=FenLiu

# Spam Scoring
VERY_HIGH_THRESHOLD=76
LOW_MAX_THRESHOLD=25

# Queue Timeout (seconds)
RESERVE_TIMEOUT_SECONDS=300

Environment Variables

Database

  • DATABASE_URL - SQLite path or PostgreSQL connection string (default: sqlite:///./fenliu.db)

Security note: FenLiu redacts the password component of DATABASE_URL before writing it to debug logs. The raw credential is never written to logs/fenliu_debug.log.

Fediverse API

  • DEFAULT_INSTANCE - Default Mastodon instance (default: mastodon.social)
  • API_TIMEOUT - HTTP request timeout in seconds (default: 30)
  • MAX_POSTS_PER_FETCH - Posts per fetch request (default: 20)
  • RATE_LIMIT_DELAY - Delay between requests in seconds (default: 1.0)

Application

  • DEBUG - Enable debug mode (default: false)
  • SECRET_KEY - Secret key for sessions. Required: the application refuses to start if this is set to the default placeholder. Generate a secure value with: python -c "import secrets; print(secrets.token_urlsafe(32))"
  • APP_NAME - Application name (default: FenLiu)
  • UI_AUTH_ENABLED - Enable session-based web UI authentication (default: true). When true, all browser-facing routes require login with the admin account. Set to false only for personal/private-LAN deployments — never for instances reachable from the public internet. See Authentication for when it is safe to disable.

Spam Scoring

  • VERY_HIGH_THRESHOLD - Score threshold for "very high" spam (default: 76)
  • LOW_MAX_THRESHOLD - Maximum score for "low" spam (default: 25)

Queue Management

  • RESERVE_TIMEOUT_SECONDS - Reserved post timeout in seconds (default: 300 / 5 minutes)

Logging

  • LOG_LEVEL - Logging level: DEBUG, INFO, WARNING, ERROR (default: INFO)
  • LOG_DIR - Log directory path (default: logs/)

Development Configuration

DEBUG=true
SECRET_KEY=dev-secret-key-not-for-production
DATABASE_URL=sqlite:///./fenliu.db
LOG_LEVEL=DEBUG

Run with:

fenliu --reload --debug

Production Configuration

DEBUG=false
SECRET_KEY=<generate-strong-random-key>
DATABASE_URL=sqlite:///./fenliu.db
LOG_LEVEL=INFO
API_TIMEOUT=60

For PostgreSQL (recommended for production):

DATABASE_URL=postgresql://user:password@localhost/fenliu

Run with:

fenliu --host 0.0.0.0 --port 8000

Generating a Secret Key

python -c "import secrets; print(secrets.token_urlsafe(32))"

Common Tasks

Change Spam Detection Sensitivity

More sensitive (flag more content):

VERY_HIGH_THRESHOLD=70
LOW_MAX_THRESHOLD=30

Less sensitive (allow more content):

VERY_HIGH_THRESHOLD=85
LOW_MAX_THRESHOLD=15

Increase Fetch Performance

For faster post fetching:

MAX_POSTS_PER_FETCH=50
RATE_LIMIT_DELAY=0.5
API_TIMEOUT=60

Enable Debug Logging

DEBUG=true
LOG_LEVEL=DEBUG

Logs are written to logs/fenliu_debug.log.

Next Steps