Skip to content

chore(backend): refactor config and startup#40

Merged
ivanskv2000 merged 8 commits intomainfrom
chore/backend/refactor-config-and-startup
May 1, 2026
Merged

chore(backend): refactor config and startup#40
ivanskv2000 merged 8 commits intomainfrom
chore/backend/refactor-config-and-startup

Conversation

@ivanskv2000
Copy link
Copy Markdown
Owner

@ivanskv2000 ivanskv2000 commented May 1, 2026

chore(backend): refactor environment configuration and server startup

✨ What’s Changed?

  • Infrastructure Enforcement: Added model_validator to ensure DATABASE_URL is provided at runtime, while maintaining Pylance compatibility with field defaults.
  • Security Enhancements:
    • Added a masked_database_url property to Settings to prevent credential leakage in logs or public endpoints.
    • Updated /config endpoint to use the masked URL.
  • Improved Server Lifecycle:
    • Introduced structured Python logging in main.py controlled by environment-specific log levels.
    • Enhanced the lifespan context manager in factory.py for graceful database connection disposal.
    • Refactored create_app factory to accept the database engine instance.
  • Auth Refactoring: Decentralized settings in auth modules by using get_settings() inside functions, improving testability and preventing import-time instantiation issues.
  • Test Alignment: Updated the test suite and conftest.py to correctly handle the new configuration patterns and ensure .env.test is prioritized.
  • CI Adjustment: Added a step to the GitHub Actions workflow to dynamically generate a CI-specific .env.test, ensuring connect to the CI Postgres service.

📂 Scope

  • frontend
  • backend
  • common/shared
  • CI/config

📝 Notes (Optional)

This refactor transforms the previous configuration "plumbing" into a reliable, multi-environment system that strictly enforces required infrastructure while respecting local overrides.

✅ Checklist

  • PR title uses Conventional Commit format
  • Code is clean and commented where needed
  • I’ve manually tested relevant parts
  • I’ve updated docs (if needed)

@ivanskv2000 ivanskv2000 changed the title chore: backend refactor config and startup chore(backend): refactor config and startup May 1, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

@ivanskv2000 ivanskv2000 merged commit d6243f2 into main May 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant