Skip to main content

Overview

PROPPR uses centralized credential management through environment variables. All sensitive credentials are loaded from .env files in development and system environment variables in production.
The platform automatically detects the environment (production on Linux, development on macOS) and loads appropriate credentials.

Environment Detection

Credentials are environment-aware:
config/credentials.py
def is_production() -> bool:
    """Check if running in production (Linux/Hetzner server)."""
    return platform.system() == "Linux"

def is_development() -> bool:
    """Check if running in development (Mac)."""
    return not is_production()

MongoDB Configuration

Connection Strings

MongoDB credentials differ by environment:
MONGDB_URI_PRODUCTION=mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=CerebroLocal&tls=false

Database Name

.env
MONGDB_DATABASE=Cerebro

Usage in Code

from PROPPR.config import get_mongo_connection_string, get_mongo_database

# Automatically selects correct connection string
connection_string = get_mongo_connection_string()
database_name = get_mongo_database()  # Returns: 'Cerebro'

Telegram Bot Tokens

Required Tokens

Each bot requires its own Telegram token:
.env
# Bot Tokens
TELEGRAM_TOKEN_TEAM_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_PLAYER_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_ARB_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_HORSE_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_EV_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_OVERTIME_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
TELEGRAM_TOKEN_FREEZE_BOT=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz

Getting Bot Tokens

from PROPPR.config import get_telegram_token

# Get token for specific bot
team_token = get_telegram_token('team')  # Required by default
player_token = get_telegram_token('player', required=True)

# Optional token
test_token = get_telegram_token('ev', required=False)  # Returns None if not set
Bot tokens are sensitive. Never commit them to version control. Use .env files that are in .gitignore.

API Keys

Odds API Keys

Multiple API keys support load balancing:
.env
# Primary key
ODDS_API_KEY=your_primary_api_key_here

# Backup keys for specific bookmakers
ODDS_API_KEY_BACKUP_1=fbsports_api_key_here
ODDS_API_KEY_BACKUP_2=bet365_api_key_here

Key Mapping

from PROPPR.config import get_odds_api_key

# Get main API key
main_key = get_odds_api_key('main')  # Required

# Get bookmaker-specific keys
fbsports_key = get_odds_api_key('fbsports')  # Uses ODDS_API_KEY_BACKUP_1
bet365_key = get_odds_api_key('bet365')      # Uses ODDS_API_KEY_BACKUP_2

# Direct backup access
backup1 = get_odds_api_key('backup1')
backup2 = get_odds_api_key('backup2')

Sports Data APIs

.env
# FootyStats API
FOOTYSTATS_API_KEY=your_footystats_key

# SportMonks API
SPORTMONKS_API_TOKEN=your_sportmonks_token
from PROPPR.config import get_footystats_api_key, get_sportmonks_api_token

footystats_key = get_footystats_api_key()      # Optional
sportmonks_token = get_sportmonks_api_token()  # Optional

Google Sheets Integration

Credentials File

Google Sheets requires a service account JSON file:
/opt/proppr/credentials.json

Sheet IDs

.env
GOOGLE_SHEET_ID_PLAYER=1M4V0QiN9uUq9K0dH7vR5sIB5ENEvNisRjvUByou_5SU
GOOGLE_SHEET_ID_TEAM=1GxMWiPnkvjihhjX6rZW8KfwbQ8rBX6mYgMa9a1g_UkY
GOOGLE_SHEET_ID_HORSES=spreadsheet_id_here
GOOGLE_SHEET_ID_CEREBRO=spreadsheet_id_here

Getting Sheet IDs

from PROPPR.config import get_spreadsheet_id, get_google_credentials_path

# Get specific sheet ID
player_sheet = get_spreadsheet_id('player')
team_sheet = get_spreadsheet_id('team')
horses_sheet = get_spreadsheet_id('horses')
cerebro_sheet = get_spreadsheet_id('cerebro')

# Get credentials path (environment-aware)
creds_path = get_google_credentials_path()

Telegram Channels

Channel IDs

.env
# Channel IDs (negative integers for channels)
TELEGRAM_CHANNEL_SUBSCRIPTION_ARB=-1001234567890
TELEGRAM_CHANNEL_HORSE_BETA=-1001234567890
TELEGRAM_CHANNEL_FREEZE=-1001234567890
TELEGRAM_CHANNEL_PLAYER_INVITE=-1001234567890

# Admin User
ADMIN_USER_ID=123456789

Getting Channel IDs

from PROPPR.config import get_channel_id, get_admin_user_id

# Get channel IDs (returns int or None)
sub_channel = get_channel_id('subscription_arb')
horse_beta = get_channel_id('horse_beta')
freeze_channel = get_channel_id('freeze')
player_invite = get_channel_id('player_invite')

# Get admin user ID
admin_id = get_admin_user_id()  # Returns: 123456789

Overtime Bot Credentials

Special Configuration

Overtime bot requires blockchain-related credentials:
.env
# Overtime API
OVERTIME_API_KEY=your_overtime_api_key

# Wallet Encryption (Fernet key)
OVERTIME_WALLET_KEY=base64_encoded_fernet_key_here

# Optimism RPC URL
OPTIMISM_RPC_URL=https://opt-mainnet.g.alchemy.com/v2/your_key

# Referrer ID
OVERTIME_REFERRER_ID=Proppr

Generate Wallet Key

python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

Usage

from PROPPR.config import (
    get_overtime_api_key,
    get_overtime_wallet_key,
    get_overtime_rpc_url,
    get_overtime_referrer_id
)

api_key = get_overtime_api_key()
wallet_key = get_overtime_wallet_key()  # For encrypting user private keys
rpc_url = get_overtime_rpc_url()        # Defaults to public RPC if not set
referrer = get_overtime_referrer_id()   # Defaults to 'Proppr'

Credential Validation

Validate Bot Requirements

from PROPPR.config import validate_required_credentials

# Validate all required credentials for a bot
result = validate_required_credentials('player')

if not result['valid']:
    print(f"Missing credentials: {result['missing']}")
    # Output: ['MONGODB_URI_*', 'TELEGRAM_TOKEN_PLAYER_BOT', 'ODDS_API_KEY']

Debug Credential Status

from PROPPR.config import print_credential_status

# Print full status report
print_credential_status()
=== PROPPR Credential Status ===

Environment: PRODUCTION

MongoDB:
  URI: SET
  Database: Cerebro

Telegram Tokens:
  team: SET (12345678...)
  player: SET (87654321...)
  arb: SET (11223344...)
  horse: NOT SET
  ev: SET (55667788...)
  overtime: SET (99887766...)
  freeze: NOT SET

API Keys:
  Odds API: SET
  FootyStats: SET
  SportMonks: NOT SET

Google Sheets:
  player: SET
  team: SET
  horses: NOT SET
  cerebro: SET

Error Handling

Missing Credentials

from PROPPR.config import get_telegram_token, CredentialError

try:
    token = get_telegram_token('player', required=True)
except CredentialError as e:
    print(f"Error: {e}")
    # Output: Required environment variable 'TELEGRAM_TOKEN_PLAYER_BOT' is not set.

Invalid Bot Name

try:
    token = get_telegram_token('invalid_bot')
except ValueError as e:
    print(f"Error: {e}")
    # Output: Invalid bot name 'invalid_bot'. Must be one of: team, player, arb, ...

Setup Guide

1

Create .env File

Create a .env file in the PROPPR root directory:
touch /path/to/PROPPR/.env
2

Add Required Variables

Add all required environment variables for your bots:
.env
# MongoDB
MONGODB_URI_DEVELOPMENT=mongodb://...
MONGODB_DATABASE=Cerebro

# Telegram
TELEGRAM_TOKEN_PLAYER_BOT=...

# APIs
ODDS_API_KEY=...
3

Secure the File

Ensure .env is in .gitignore and has proper permissions:
echo ".env" >> .gitignore
chmod 600 .env
4

Validate

Test your configuration:
python3 -c "from PROPPR.config import print_credential_status; print_credential_status()"

Best Practices

Never Commit Secrets

Keep .env files out of version control. Use .env.example for templates.

Environment-Specific

Use different credentials for production and development environments.

Rotate Keys Regularly

Periodically rotate API keys and tokens for security.

Validate on Startup

Always validate required credentials when services start.

Settings Configuration

Non-sensitive platform settings and constants

Preset Configuration

Alert presets and market configurations

Build docs developers (and LLMs) love