Skip to content

Upgrade gateway#2

Merged
Jenish-1235 merged 34 commits intogatewayfrom
upgrade-gateway
Dec 19, 2025
Merged

Upgrade gateway#2
Jenish-1235 merged 34 commits intogatewayfrom
upgrade-gateway

Conversation

@Jenish-1235
Copy link
Copy Markdown
Contributor

This pull request introduces several foundational improvements to the NeroSpatial Backend, focusing on environment configuration, health monitoring endpoints, and application state management. It adds a standardized .env.example for environment variables, implements robust health/readiness/liveness endpoints for production deployments, introduces a centralized application state container, and improves configuration and core module structure for maintainability and scalability.

Environment and Configuration Improvements:

  • Added a comprehensive .env.example template documenting all required and optional environment variables, including Azure, PostgreSQL, Redis, JWT, and telemetry settings. This helps standardize configuration and onboarding for new developers.
  • Refactored config.py to support hierarchical configuration loading (Azure App Configuration, Key Vault, .env), added validation for the environment variable, and provided properties for constructing PostgreSQL and Redis URLs.

Health Monitoring Endpoints:

  • Implemented api/health.py with /health, /ready, and /live endpoints for detailed health checks, Kubernetes readiness, and liveness probes, including dependency checks and process health.
  • Updated README.md to document new health endpoints, infrastructure setup (Docker Compose for dependencies), JWT key generation, Azure Key Vault setup, and clarified configuration hierarchy and requirements.

Application State and Core Module Refactoring:

  • Added core/app_state.py, introducing an AppState dataclass to centralize application resources (database pool, Redis, JWT, telemetry, Key Vault), startup status, and cleanup logic.
  • Refactored core/__init__.py to expose new core types (AppState, exceptions, enums, models, telemetry, etc.) for easier imports and better modularity. [1] [2] [3]

Other Minor Changes:

  • Added a module docstring to api/__init__.py for clarity.

These changes collectively improve the backend's reliability, maintainability, and readiness for production deployment.

Jenish-1235 and others added 30 commits December 13, 2025 22:44
- Split core/models.py into domain modules
- Enhance user/auth models with production-grade features
- Update dependencies: pydantic[email] for EmailStr validation
- Update tests to match new model structure
- All imports remain backward compatible
- All 48 tests passing
…ling and OAuth provider requirements

- Changed IP address fields in models to use IPvAnyAddress for better validation.
- Made oauth_provider a required field in User and UserContext models.
- Removed deprecated OAuthTokens model and updated related tests.
- Enhanced tests to validate new model behaviors and requirements.
- Add docker-compose.infra.yml with PostgreSQL, Redis, Jaeger
- Add scripts/init-db.sql with complete database schema
- Add scripts/generate-keys.sh for JWT key generation
- Add scripts/setup-keyvault.sh for Azure Key Vault setup
- Add PostgreSQL, Redis, JWT, OpenTelemetry settings
- Add startup timeout and retry configuration
- Add pool size configuration for future use
- Create .env.example template
- Update .gitignore for secrets
- Create core/config_loader.py with retry logic
- Add environment validation (strict for prod/staging)
- Add exponential backoff retry for Azure connections
- Add azure-appconfiguration dependency
- Create core/app_state.py with AppState container
- Define DatabasePool and RedisClient protocols
- Create core/database.py with pool factory stub
- Create core/redis.py with client factory stub
- Add startup metadata tracking
- Add 7-phase startup sequence with logging
- Add configuration loading from Azure
- Add connection initialization and verification
- Add graceful shutdown with cleanup
- Add AppState dependency injection
- Add /health with detailed dependency checks
- Add /ready for Kubernetes readiness probe
- Add /live for Kubernetes liveness probe
- Update Docker health check to use /ready
- Add uptime and metadata to health response
- Add tests for environment validation
- Add tests for AppState lifecycle
- Add tests for health endpoints
- Update README with infrastructure setup
- Move all core module tests to tests/core/ directory
- Create tests/core/__init__.py
- Keep API tests (test_health_endpoints.py) in tests/ root
- Maintains test organization by module structure
…uirements

- Introduce azure-appconfiguration version 1.7.2 with its dependencies
- Update project dependencies to include azure-appconfiguration
- Ensure compatibility with existing azure-core and other related packages
- Add redis_max_connections setting to configure maximum Redis connections.
- Refactor main.py to initialize Redis client with new connection settings.
- Update health check endpoints to verify Redis connection status.
- Remove unused database and Redis client creation functions.
- Introduce idempotent session keys for WebSocket connections to improve session management.
- Implement batch operations in Redis client for efficient session handling.
- Update tests to reflect changes in session management and Redis interactions.

These enhancements improve the application's performance and reliability in managing Redis connections and user sessions.
…ultiple files

- Simplified string formatting in config.py, main.py, and various model files for improved readability.
- Refactored method signatures in auth.py, keyvault.py, and test files to enhance consistency and clarity.
- Cleaned up exception representation in exceptions.py for better debugging output.
@Jenish-1235 Jenish-1235 merged commit 9ec7ec2 into gateway Dec 19, 2025
3 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