diff --git a/backend/envs/prod/initialization/setup_prod_environment.py b/backend/envs/prod/initialization/setup_prod_environment.py
index 8a82264..8ec2da1 100644
--- a/backend/envs/prod/initialization/setup_prod_environment.py
+++ b/backend/envs/prod/initialization/setup_prod_environment.py
@@ -1,5 +1,7 @@
from database.database_manager import DatabaseManager
+from database.organization_manager import OrganizationManager
from database.user_manager import UserManager
+from models.organization import Organization
from models.user import User, UserRole
from security import get_password_hash
from utils.utils import get_app_logger
@@ -7,6 +9,20 @@
logger = get_app_logger(__name__)
+def create_docshow_ai_organization():
+ """Creates the DocShow AI organization if it doesn't already exist."""
+ organization = Organization(name="DocShow AI")
+
+ with DatabaseManager() as session:
+ org_manager = OrganizationManager(session)
+ existing_org = org_manager.get_organization_by_name(organization.name)
+ if not existing_org:
+ org_manager.create_organization(organization)
+ logger.debug("DocShow AI organization created.")
+ else:
+ logger.debug("DocShow AI organization already exists.")
+
+
def create_admin_user():
"""Creates an admin user if it doesn't already exist."""
admin_user = User(
diff --git a/backend/settings.py b/backend/settings.py
index e7a13a8..e383c12 100644
--- a/backend/settings.py
+++ b/backend/settings.py
@@ -26,7 +26,9 @@
DATABASE_URL = config("DATABASE_URL")
-EMAIL_VERIFICATION_EXPIRE_MINUTES = int(config("EMAIL_VERIFICATION_EXPIRE_MINUTES"))
+EMAIL_VERIFICATION_EXPIRE_MINUTES = int(
+ config("EMAIL_VERIFICATION_EXPIRE_MINUTES", default=15)
+)
OPENAI_API_KEY = config("OPENAI_API_KEY")
diff --git a/backend/startup.py b/backend/startup.py
index 1621a17..f31bb42 100644
--- a/backend/startup.py
+++ b/backend/startup.py
@@ -16,6 +16,7 @@
)
from envs.prod.initialization.setup_prod_environment import (
create_admin_user as prod_create_admin_user,
+ create_docshow_ai_organization,
)
from envs.dev.utils import seed_db
from settings import APP_ENV, JWT_SECRET_KEY
@@ -28,7 +29,7 @@
def run_startup_routines():
check_jwt_secret_key()
- if APP_ENV == "development":
+ if APP_ENV == "dev":
create_sample_organization()
dev_create_admin_user()
seed_db()
@@ -36,11 +37,12 @@ def run_startup_routines():
create_sample_dataprofile()
if APP_ENV == "prod":
+ create_docshow_ai_organization()
prod_create_admin_user()
def check_jwt_secret_key():
- if APP_ENV != "development" and JWT_SECRET_KEY == "mysecretkey":
+ if APP_ENV != "dev" and JWT_SECRET_KEY == "mysecretkey":
raise EnvironmentError(
"JWT_SECRET_KEY must be set in non-development environments"
)
diff --git a/backend/utils/email.py b/backend/utils/email.py
index 36f9f46..0d38802 100644
--- a/backend/utils/email.py
+++ b/backend/utils/email.py
@@ -13,7 +13,7 @@ async def send_password_reset_email_with_sendgrid(email: List[str], token: str):
html_content=f'Click on the link to reset your password: https://{APP_HOST}/reset-password',
)
# Disable click tracking in development
- if APP_ENV == "development":
+ if APP_ENV == "dev":
message.tracking_settings = TrackingSettings()
message.tracking_settings.click_tracking = ClickTracking(False, False)
try:
@@ -34,7 +34,7 @@ async def send_verification_email_with_sendgrid(email: List[str], token: str):
html_content=f'Click on the link to verify your email: https://{APP_HOST}/verify-email',
)
# Disable click tracking in development
- if APP_ENV == "development":
+ if APP_ENV == "dev":
message.tracking_settings = TrackingSettings()
message.tracking_settings.click_tracking = ClickTracking(False, False)
try:
diff --git a/backend/utils/utils.py b/backend/utils/utils.py
index afdb803..aeab935 100644
--- a/backend/utils/utils.py
+++ b/backend/utils/utils.py
@@ -91,7 +91,7 @@ def get_app_logger(name):
logger = logging.getLogger(name)
# Set log level based on the environment
- log_level = logging.DEBUG if os.getenv("APP_ENV") == "development" else logging.INFO
+ log_level = logging.DEBUG if os.getenv("APP_ENV") == "dev" else logging.INFO
logger.setLevel(log_level)
diff --git a/k8s/backend-configmap.yaml b/k8s/backend-configmap.yaml
index 1ecb6c2..f61abaa 100644
--- a/k8s/backend-configmap.yaml
+++ b/k8s/backend-configmap.yaml
@@ -3,4 +3,10 @@ kind: ConfigMap
metadata:
name: backend-config
data:
- APP_ENV: "prod"
\ No newline at end of file
+ APP_ENV: "prod"
+ APP_HOST: "docshow.ai"
+ EMAIL_VERIFICATION_EXPIRE_MINUTES: "15"
+ PASSWORD_RESET_EXPIRE_MINUTES: "15"
+ SPACES_BUCKET_NAME: "docshowai"
+ SPACES_ENDPOINT_URL: "https://docshowai.fra1.digitaloceanspaces.com"
+ SPACES_REGION_NAME: "fra1"
\ No newline at end of file
diff --git a/k8s/backend-deployment.yaml b/k8s/backend-deployment.yaml
index 3ad340e..cb583fc 100644
--- a/k8s/backend-deployment.yaml
+++ b/k8s/backend-deployment.yaml
@@ -33,3 +33,18 @@ spec:
secretKeyRef:
name: jwt-secret
key: JWT_SECRET_KEY
+ - name: SENDGRID_API_KEY
+ valueFrom:
+ secretKeyRef:
+ name: sendgrid-api-key
+ key: SENDGRID_API_KEY
+ - name: SPACES_ACCESS_KEY
+ valueFrom:
+ secretKeyRef:
+ name: spaces-access-key
+ key: SPACES_ACCESS_KEY
+ - name: SPACES_SECRET_ACCESS_KEY
+ valueFrom:
+ secretKeyRef:
+ name: spaces-secret-access-key
+ key: SPACES_SECRET_ACCESS_KEY