Skip to content

Feature/model versioning rate limiting pooling graphql#431

Merged
gelluisaac merged 9 commits into
Traqora:mainfrom
rachealkenny:feature/model-versioning-rate-limiting-pooling-graphql
Jun 30, 2026
Merged

Feature/model versioning rate limiting pooling graphql#431
gelluisaac merged 9 commits into
Traqora:mainfrom
rachealkenny:feature/model-versioning-rate-limiting-pooling-graphql

Conversation

@rachealkenny

Copy link
Copy Markdown
Contributor

Description

This PR introduces foundational backend infrastructure to enhance AstroML's scalability, maintainability, and operational resilience.

  • Model Versioning & Registry: Implements semantic versioning for models, integrated with MLflow for experiment tracking. Adds a dedicated registry (astroml/models/registry.py) to manage metadata, performance metrics, rollback capabilities, and A/B testing support, alongside new REST endpoints for model comparison and management.
  • API Rate Limiting: Adds a Redis-backed sliding window rate limiter to protect the API from abuse. Enforces configurable limits by API key and IP address per endpoint, includes admin override capabilities (whitelist/blacklist), and surfaces standard rate-limit headers in all responses with violation logging.
  • Database Connection Pooling: Optimizes SQLAlchemy connection pools with tuned size settings, automatic recycling, and health checks. Integrates Prometheus metrics to monitor pool health and utilization.
  • GraphQL API: Introduces a GraphQL endpoint as a flexible alternative to REST, allowing clients to fetch precisely the data they need. The schema covers all primary data models with query, mutation, and subscription support, integrated with existing authentication and protected by query complexity analysis and depth limiting.

Motivation & Context: As AstroML scales to handle more users and complex ML workflows, these upgrades are necessary to ensure reliable model governance, API stability, database efficiency, and flexible data access for consumers.

Related Files:

  • Added: astroml/models/registry.py, astroml/api/graphql/, config/api.yaml, config/database.yaml
  • Modified: Database schema (model versions table), FastAPI app configuration, SQLAlchemy engine configuration

Fixes #302
Fixes #299
Fixes #297
Fixes #295

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Closes #302
Closes #299
Closes #297
Closes #295

@rachealkenny rachealkenny marked this pull request as draft June 28, 2026 19:54
…trics

Add comprehensive database connection pooling configuration with
health checks, metrics collection, and retry logic.

- Add pool configuration to database.yaml (min_size, max_size, max_overflow, etc.)
- Implement PoolConfig and HealthCheckConfig dataclasses
- Add PoolMetrics for tracking connection acquisition times and errors
- Add check_database_connection() for connection health verification
- Add get_db_with_retry() for automatic connection retry with backoff
- Add health endpoints: /health/db, /health/db/pool, /health/db/status
- Add readiness and liveness probes for Kubernetes
- Add admin endpoint to reset connection pool
Add comprehensive API rate limiting with multiple algorithms, Redis-backed
distributed rate limiting, admin override capabilities, and rate limit headers.

- Add sliding window algorithm as alternative to token bucket
- Add Redis support for distributed rate limiting
- Add rate limit headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
- Add admin override with whitelist/blacklist support
- Add rate limit violation logging with context
- Add admin endpoints for managing rate limits
- Add per-endpoint rate limit configuration
Add comprehensive model versioning system with semantic versioning,
rollback capability, A/B testing support, and deployment tracking.

- Add semantic versioning (major.minor.patch) with auto-increment
- Add model metadata fields (framework, task_type, description)
- Add rollback capability to previous versions
- Add A/B testing support with traffic splitting
- Add deployment tracking with environment history
- Add version comparison with metric deltas
- Add version history with status transitions
- Add performance metrics tracking and comparison
- Add MLflow integration for experiment tracking
Add comprehensive GraphQL API as an alternative to REST for flexible data queries.

- Add GraphQL schema for all data models (Account, Transaction, FraudAlert, LoyaltyPoints, ModelRegistry, etc.)
- Add query support with pagination and filtering
- Add mutation support for creating and updating entities
- Add subscription support for real-time updates (transactions, fraud alerts, loyalty points)
- Add authentication integration with JWT
- Add query depth limiting for security
- Add GraphQL playground for development
- Add publish functions for GraphQL subscriptions
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@rachealkenny Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@rachealkenny rachealkenny marked this pull request as ready for review June 30, 2026 12:01
@rachealkenny

Copy link
Copy Markdown
Contributor Author

@gelluisaac please, review.

@gelluisaac

Copy link
Copy Markdown
Contributor

@rachealkenny please rresolve conflict so i can merge

Resolves conflicts between HEAD and upstream/main branches in the AstroML
API application and model registry routers.

Changes in api/app.py:
- Merge both branches' routers (health, admin, GraphQL from HEAD; query_router from upstream/main)
- Add GraphQL playground endpoint for development environments
- Keep all router includes from both branches with clear commenting

Changes in api/routers/models.py:
- Add missing DeploymentEnvironment import from upstream/main
- Rename duplicate /compare endpoint to /compare-versions to resolve route conflict
- Preserve all additional functionality from HEAD:
  - Model version rollback
  - A/B testing endpoints
  - Model deployment to environments
  - Version comparison and history endpoints
  - Deployment history tracking
@gelluisaac gelluisaac merged commit 2d9f717 into Traqora:main Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants