From 53a7983497282c1ea95d782c64f27fc4829ad58a Mon Sep 17 00:00:00 2001 From: t0xa Date: Sun, 7 Sep 2025 11:14:41 +0300 Subject: [PATCH] Add config settings for project --- DOCS/database_scheme.wsd | 1 + DOCS/deployment.puml | 25 +++++++++++++++++++++++++ app/config.py | 32 ++++++++++++++++++++++++++++---- migrations/__init__.py | 0 migrations/runner.py | 0 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 DOCS/deployment.puml create mode 100644 migrations/__init__.py create mode 100644 migrations/runner.py diff --git a/DOCS/database_scheme.wsd b/DOCS/database_scheme.wsd index 053e886..dfe3745 100644 --- a/DOCS/database_scheme.wsd +++ b/DOCS/database_scheme.wsd @@ -19,6 +19,7 @@ $table("EXERCISE", "exercise"){ $column("NAME") VARCHAR } + $table("APPROACH", "approach"){ $pk("ID") INTEGER NOT NULL $fk("EXERCISE") INTEGER NOT NULL diff --git a/DOCS/deployment.puml b/DOCS/deployment.puml new file mode 100644 index 0000000..13008f2 --- /dev/null +++ b/DOCS/deployment.puml @@ -0,0 +1,25 @@ +@startuml +actor client +agent "web interface" as WEB_UI +agent "ios app" as IOS_APP +agent "telegram app" as TG_APP + +frame docker:f1tness_db { + database "PostgreSQL" as db +} + +frame docker:fastAPI { + node backend_API + node frontend_renderer +} + +client <--> WEB_UI +client <--> IOS_APP +client <--> TG_APP + +WEB_UI <--> frontend_renderer +IOS_APP <--> backend_API +TG_APP <--> backend_API + +backend_API --> db +@enduml \ No newline at end of file diff --git a/app/config.py b/app/config.py index 79864a8..0afd3a1 100644 --- a/app/config.py +++ b/app/config.py @@ -3,12 +3,36 @@ from typing import Optional class Settings(BaseSettings): - app_name: str = "Fitness Parser API" - version: str = "0.1.0" + # Base app settings + app_name: str = "F1tness Parser API" + version: str = "0.0.1" debug: bool = False - + + # Postgres database settings + POSTGRES_DATABASE_URL: Optional[str] = None + POSTGRES_DATABASE_HOST: str = "localhost" + POSTGRES_DATABASE_PORT: int = 5432 + POSTGRES_DATABASE_NAME: str = "f1tness_db" + POSTGRES_DATABASE_USER: str = "postgres" + POSTGRES_DATABASE_PASSWORD: str = "password" + class Config: env_file = ".env" + def get_postgres_database_url(self, async_driver: bool = True) -> str: + """Method for receiving relational database URL""" + + # If POSTGRES_DATABASE_URL is somehow set in env file - return it + if self.POSTGRES_DATABASE_URL: + return self.POSTGRES_DATABASE_URL + + driver = "postgresql+asyncpg" if async_driver else "postgresql" + return ( + f"{driver}://{self.POSTGRES_DATABASE_USER}:{self.POSTGRES_DATABASE_PASSWORD}" + f"@{self.POSTGRES_DATABASE_HOST}" + f":{self.POSTGRES_DATABASE_PORT}/{self.POSTGRES_DATABASE_NAME}" + ) + + +settings = Settings() -settings = Settings() \ No newline at end of file diff --git a/migrations/__init__.py b/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/migrations/runner.py b/migrations/runner.py new file mode 100644 index 0000000..e69de29