feat: initial project setup
This commit is contained in:
41
backend/app/config.py
Normal file
41
backend/app/config.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Application configuration from environment variables."""
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class Settings:
|
||||
"""Application settings loaded from environment variables.
|
||||
|
||||
Configure via DATABASE_URL (single connection string) or individual
|
||||
POSTGRES_* variables. The application expects the target database to
|
||||
contain:
|
||||
- A listings table (default: marts.funda_listings)
|
||||
- An ELO schema with ratings, comparisons, and sample_listings tables
|
||||
(default: elo.*)
|
||||
"""
|
||||
|
||||
POSTGRES_HOST: str = os.getenv("POSTGRES_HOST", "localhost")
|
||||
POSTGRES_PORT: int = int(os.getenv("POSTGRES_PORT", "5432"))
|
||||
POSTGRES_USER: str = os.getenv("POSTGRES_USER", "postgres")
|
||||
POSTGRES_PASSWORD: str = os.getenv("POSTGRES_PASSWORD", "postgres")
|
||||
POSTGRES_DB: str = os.getenv("POSTGRES_DB", "postgres")
|
||||
|
||||
LISTINGS_SCHEMA: str = os.getenv("LISTINGS_SCHEMA", "marts")
|
||||
LISTINGS_TABLE: str = os.getenv("LISTINGS_TABLE", "funda_listings")
|
||||
ELO_SCHEMA: str = os.getenv("ELO_SCHEMA", "elo")
|
||||
|
||||
K_FACTOR: float = float(os.getenv("ELO_K_FACTOR", "32"))
|
||||
DEFAULT_ELO: float = float(os.getenv("ELO_DEFAULT_RATING", "1500"))
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
url = os.getenv("DATABASE_URL")
|
||||
if url:
|
||||
return url
|
||||
return (
|
||||
f"postgresql+psycopg2://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}"
|
||||
f"@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
||||
)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user