Security: deep /api/health (DB+MinIO probes, 503 on failure) + /api/live; rate-limited public forms with honeypots; real client IP behind Traefik (--proxy-headers); TipTap URL sanitization on write (nh3); non-root containers + slim .dockerignore; prod MinIO console bound to 127.0.0.1; HSTS/nosniff on TLS routers; JWT 8h; no default credentials in code. Reliability: Alembic migrations (create_all baseline); graceful shutdown (exec uvicorn); hardened backups (checksums, sanity check, freshness gauge, optional rclone off-site) + restore.sh + hourly db-backup sidecar (ops profile); stack.sh ops tooling (deploy/logs/health/backup/restore/monitoring); .gitattributes LF for shell scripts. Orchestration: json-file log rotation, pinned images, per-service memory limits, edge/internal networks, Traefik ping/accesslog/metrics + flood limiter, conditional minio-setup, pgvector db image, one-shot db-init (umami + aramesh_chatbot databases). Chatbot: unified from site-chatbot branch (RAG + pgvector, SSE, ChatWidget). Monitoring: Prometheus/Alertmanager/Loki/Promtail/Grafana + cAdvisor, node/postgres/blackbox exporters, provisioned dashboards and 10 alert rules; alerts delivered to Bale (tapi.bale.ai — Telegram-compatible). Analytics: Umami on shared Postgres, build-time tracker injection, custom events (contact/newsletter/phone/chat/lang) via frontend/src/analytics.ts. Hygiene: CSV export for contact messages and subscribers; upload image optimization (Pillow); CI script + GitHub-compatible workflow; audit.sh; gen-env.sh for strong credentials.
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""تنظیمات برنامه — از متغیرهای محیطی یا فایل .env خوانده میشود."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
database_url: str = "postgresql+psycopg://postgres:postgres@localhost:5432/arameshplaza_api"
|
|
secret_key: str = "dev-secret-change-me-in-production"
|
|
algorithm: str = "HS256"
|
|
# ۸ ساعت — توکن stateless است و امکان ابطال ندارد؛ عمر کوتاهتر ریسک نشت را کم میکند
|
|
access_token_expire_minutes: int = 480
|
|
cors_origins: list[str] = ["*"]
|
|
admin_username: str = "admin"
|
|
admin_password: str = "aramesh123"
|
|
|
|
# Object Storage (MinIO / هر S3 سازگار) برای آپلود تصاویر
|
|
s3_endpoint: str = "http://localhost:9000"
|
|
s3_access_key: str = "aramesh"
|
|
s3_secret_key: str = "aramesh-minio-secret"
|
|
s3_bucket: str = "aramesh-media"
|
|
# پیشوند عمومی مسیر تصاویر — Traefik آن را به باکت پروکسی میکند
|
|
media_public_base: str = "/media"
|
|
media_max_upload_mb: int = 10
|
|
|
|
# نشانی کامل سایت (مثل https://aramesh.example) — برای sitemap و آدرس مطلق OG
|
|
site_url: str = ""
|
|
# مسیر بیلد فرانتاند (شامل index.html) — برای سرو HTML با متای سئو در صفحات جزئیات
|
|
frontend_dist: str = "../frontend/dist"
|
|
|
|
|
|
settings = Settings()
|