BalanceBoard - Clean release

- Docker deployment ready
- Content aggregation and filtering
- User authentication
- Polling service for updates

🤖 Generated with Claude Code
This commit is contained in:
2025-10-11 21:24:21 +00:00
commit cb894b2159
53 changed files with 13514 additions and 0 deletions

53
database.py Normal file
View File

@@ -0,0 +1,53 @@
"""
Database Configuration
SQLAlchemy setup for PostgreSQL connection.
"""
import os
from flask_sqlalchemy import SQLAlchemy
# Initialize SQLAlchemy instance
db = SQLAlchemy()
def init_db(app):
"""
Initialize database with Flask app.
Args:
app: Flask application instance
"""
# Get database URL from environment variable
database_url = os.getenv('DATABASE_URL')
if not database_url:
# Fallback to individual environment variables
db_user = os.getenv('POSTGRES_USER', 'balanceboard')
db_password = os.getenv('POSTGRES_PASSWORD', 'changeme')
db_host = os.getenv('POSTGRES_HOST', 'localhost')
db_port = os.getenv('POSTGRES_PORT', '5432')
db_name = os.getenv('POSTGRES_DB', 'balanceboard')
database_url = f'postgresql+psycopg2://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}'
# Configure Flask app
app.config['SQLALCHEMY_DATABASE_URI'] = database_url
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {
'pool_size': 10,
'pool_recycle': 3600,
'pool_pre_ping': True, # Verify connections before using
}
# Initialize db with app
db.init_app(app)
# Create tables
with app.app_context():
db.create_all()
print("✓ Database tables created")
def get_db():
"""Get database instance"""
return db