QueryGateway is delivered as a self-hosted platform that lets teams expose Oracle query results as secure REST endpoints through a guided wizard while preserving security-by-default, reproducible infrastructure, and operational reliability. The implemented baseline uses Python 3.14+, FastAPI, PostgreSQL, SQLAlchemy 2.0 + Alembic, APScheduler 3.x, Pydantic Settings, API versioning, a Vite + React SPA, shadcn/ui + Tailwind, and Dockerized CI/CD.
- Module 1: Database Connection Management
- Create, edit, delete, and test Oracle connections.
- Secure credential storage and pool configuration.
- Module 2: API Creation Wizard
- Connection selection, SQL authoring with bind parameters, preview/mapping, auth selection, endpoint definition, data strategy, deploy.
- Dynamic endpoint registration and runtime routing.
- Module 3: Authentication Configuration
- Manage Bearer token, Basic Auth, and API key methods.
- Token generation and credential verification workflows.
- Module 4: Task Scheduling + Snapshot Cache
- APScheduler-driven scheduled refresh jobs.
- Snapshot persistence in PostgreSQL JSONB and execution logs.
- Module 5: Settings + Health Dashboard
- Base URL/port and application runtime settings.
- Health and status visibility for core dependencies.
- Additional databases beyond Oracle for user data sources (e.g., MySQL, SQL Server, PostgreSQL as target source DB).
- Write operations for dynamic data endpoints (POST/PUT/DELETE).
- GraphQL support.
- Auto-generated per-endpoint OpenAPI packages for consumer APIs.
- Postman collection export.
- Distributed task execution architecture (Celery/queue workers).
- Advanced RBAC beyond baseline admin role controls.
backend/: FastAPI service, domain logic, data layer, scheduler runtime, migrations.frontend/: Vite + React SPA admin console (shadcn/ui + Tailwind).docker/: Dockerfiles, runtime config, optional local Oracle XE profile.docs/: architecture decisions, API contracts, runbooks.docker-compose.yml: local/dev orchestration (api,web,db, optionaloracle).
- Admin console (frontend SPA) consumes admin APIs only.
- Backend exposes two versioned namespaces:
/api/v1/admin/*: management APIs for connections, auth methods, endpoints, schedules, settings, logs./api/v1/data/*: dynamic consumer-facing data endpoints resolved at runtime.
- FastAPI service responsibilities:
- Validate auth for every data endpoint request.
- Resolve endpoint metadata and selected freshness strategy.
- Execute parameterized SQL against Oracle (live mode) or select a covering retained snapshot and apply typed cached-row filters (snapshot mode).
- Manage scheduler jobs and persist execution telemetry.
- Versioning is mandatory from day one (
v1prefixes for admin and data namespaces). - Backward compatibility policy:
- No breaking change inside
v1without compatibility fallback. - Breaking contract changes require
v2route introduction.
- No breaking change inside
- Deprecation policy:
- Mark deprecated endpoints in docs and response headers.
- Maintain deprecated endpoint behavior for one full minor release cycle before removal.
- Publish migration notes in
docs/for all deprecated/removed contracts.
- Establish a reproducible monorepo foundation and quality gates before feature work.
- Monorepo directory skeleton (
backend/,frontend/,docker/,docs/). - Baseline Docker and
docker-composesetup for local development. - GitHub Actions workflows for backend, frontend, and Docker build verification.
- Shared coding standards and contribution conventions.
- Initialize backend Python project for 3.14+ with dependency management and lint/test/type scripts.
- Initialize frontend Vite + React + TypeScript with Tailwind, shadcn/ui base setup, eslint/prettier, and vitest (or Jest).
- Add root-level tooling docs and Makefile/task runner commands for consistent local workflows.
- Create
docker-compose.ymlwithapi,web,dband optionaloracleprofile. - Add
.github/workflows/:- Backend job:
ruff,pytest,mypy. - Frontend job:
eslint,prettier --check,vitest(or Jest). - Docker job: build all target images.
- Backend job:
- Define branch/PR conventions, commit hygiene, and release tagging approach in
docs/.
- Clean clone can run lint/test/build through documented commands.
- CI runs on pull request and blocks merge on failing required jobs.
docker compose upboots backend, frontend, and PostgreSQL successfully.- Repository has clear onboarding and contribution instructions.
- GitHub repository and Actions enabled.
- Container runtime available to development team.
- Risk: Early drift in coding standards.
- Mitigation: Enforce all checks in CI, not just local hooks.
- Risk: Docker startup inconsistency across developer machines.
- Mitigation: Pin base images and provide versioned env templates.
- Deliver the core FastAPI service skeleton with configuration, persistence, observability, and migration baseline.
- FastAPI app structure with startup lifecycle, dependency injection boundaries, and health endpoints.
- Pydantic Settings configuration system with
.envschema. - Structured logging via Python logging + structlog.
- SQLAlchemy 2.0 models for app database and Alembic migration baseline.
- Database connectivity for PostgreSQL (asyncpg) and Oracle driver integration point.
- Implement app factory, router registration, middleware pipeline, and exception handling.
- Define settings classes (environment, secrets, database URLs, CORS, query timeouts, logging levels).
- Configure structlog JSON rendering and request correlation IDs.
- Model core tables: connections, auth methods, endpoints, schedules, job runs, cached snapshots, audit/access logs, settings.
- Initialize Alembic and create first migration for all foundational tables.
- Add readiness/liveness/DB health endpoints under
/api/v1/admin/health/*. - Establish repository/service layer patterns to control FastAPI DI complexity.
- Service boots and passes lint, type-check, and unit tests.
- Alembic upgrade creates schema from empty database deterministically.
- Health endpoints validate app readiness and PostgreSQL connectivity.
- Logs are emitted as structured JSON with traceable request context.
- Phase 0 complete.
- PostgreSQL service running.
- Risk: Poor boundary design leading to DI sprawl.
- Mitigation: Enforce service/repository conventions and module templates early.
- Risk: Migration instability across environments.
- Mitigation: Use migration checks in CI and test fresh + incremental upgrades.
- Provide complete connection lifecycle management for Oracle sources.
- Admin APIs and frontend screens for creating, editing, deleting, listing, and testing Oracle connections.
- Secure storage for credentials and pool configuration metadata.
- Connectivity test endpoint with diagnostic feedback.
- Implement connection entity validation (host/service/SID, username, pool sizing, timeouts).
- Encrypt sensitive fields at rest and manage keys via environment-based secret inputs.
- Build backend CRUD endpoints under
/api/v1/admin/connections/*. - Implement connection test workflow using
python-oracledb(thin mode by default). - Build frontend pages/forms/tables for connection management with validation and error feedback.
- Add audit logging for create/update/delete/test actions.
- Users can create and test at least one Oracle connection successfully.
- Credentials are not returned in plain text from API responses or logs.
- Invalid connection configs return actionable validation errors.
- UI supports full CRUD flows and reflects backend state changes.
- Phase 1 complete.
- Reachable Oracle instance for integration testing.
- Risk: Oracle environment differences causing false-negative tests.
- Mitigation: Provide explicit thin/thick mode diagnostics and timeout controls.
- Risk: Credential leakage in logs.
- Mitigation: Central redaction filter for sensitive fields.
- Deliver configurable endpoint authentication using PyJWT + bcrypt.
- Auth method CRUD for Bearer token, Basic Auth, API key.
- Token issuance/validation services with expiration and rotation settings.
- Middleware enforcing authentication on
/api/v1/data/*.
- Implement auth models and schemas for all supported types.
- Build credential hashing and verification using
bcrypt. - Build JWT creation/validation utilities using
PyJWT. - Implement admin APIs under
/api/v1/admin/auth/*. - Add middleware/dependencies that resolve per-endpoint auth policy.
- Build frontend auth management screens and secure token display/regen UX.
- Add access logging with timestamp, IP, principal, endpoint, status.
- Protected data endpoints reject unauthorized requests consistently.
- Valid credentials grant access according to configured endpoint policy.
- Token expiry and invalid signature cases are handled with deterministic responses.
- Auth management UI supports creation, update, disable, and revocation flows.
- Phase 2 complete.
- Risk: Misconfigured auth policies exposing endpoints.
- Mitigation: Default-deny policy and mandatory auth assignment before endpoint activation.
- Risk: Weak secret management.
- Mitigation: Enforce minimum key lengths and reject insecure defaults.
- Deliver the core wizard that converts parameterized SQL into deployable versioned data endpoints.
- Multi-step wizard UI and backend orchestration APIs.
- Rich SQL editor integration with CodeMirror 6 via
@uiw/react-codemirror. - SQL preview engine with bind parameter extraction/validation rules.
- Endpoint registration pipeline and dynamic data router.
- Build wizard flow state model and backend draft/publish lifecycle.
- Integrate SQL editor with syntax highlighting, lint/error markers, and shortcuts.
- Implement parameter binding contract:
- Only named bind variables (e.g.,
:param_name). - Reject string-concatenated SQL interpolation patterns.
- Validate input types/coercion using explicit schemas.
- Treat preview samples as temporary values, never persisted defaults.
- Enforce required descriptors for both live and snapshot requests regardless of defaults.
- Keep optional live defaults independent from schedule-owned SQL bindings.
- Only named bind variables (e.g.,
- Build preview execution endpoint to return sample JSON and inferred schema.
- Implement result mapping layer (rename/select columns and output shaping).
- Build endpoint definition step (path, GET method for MVP, auth method, data strategy).
- Register dynamic endpoint metadata and activate runtime resolution under
/api/v1/data/*. - Ensure router lookup is version-aware and supports deprecation metadata.
- User can complete wizard and publish a functioning GET endpoint end-to-end.
- SQL preview enforces bind parameters and blocks unsafe query patterns.
- Published endpoint serves expected JSON for valid parameter inputs.
- Dynamic router resolves endpoint config without service restart.
- Phase 2 and Phase 3 complete.
- Risk: SQL safety regressions.
- Mitigation: Mandatory bind variable enforcement and explicit query validation layer.
- Risk: Complex wizard state causing inconsistent deployments.
- Mitigation: Persist wizard drafts server-side with explicit state transitions.
- Enable scheduled data refresh with persisted definitions, restart restoration, and filtered cached response serving.
- APScheduler 3.x integration with an in-memory job store whose active schedule definitions are persisted in PostgreSQL and restored on API startup.
- Schedule CRUD and control actions (run now, pause/resume, enable/disable).
- Snapshot cache storage in PostgreSQL JSONB.
- Job execution logging dashboard and APIs.
- Implement scheduler service lifecycle integrated with FastAPI startup/shutdown.
- Model schedules, job state, run history, and snapshot payload metadata.
- Implement admin APIs under
/api/v1/admin/schedules/*and/api/v1/admin/jobs/*. - Create execution worker logic for scheduled query runs and cache replacement strategy.
- Require schedule-owned parameter bindings, timezone-aware logical dates, and declarative calendar windows; persist resolved values for audit and coverage selection.
- Add staleness tracking and fallback handling when latest snapshot fails.
- Wire data endpoints in snapshot mode to require cached-column mappings, select the newest retained run that covers the request, and apply typed equality/range filters.
- Build frontend schedule management UI and execution log views.
- Active scheduled jobs are restored exactly once after a single API process restarts.
- Manual run and pause/resume actions work reliably from UI and API.
- Snapshot-mode endpoints enforce required request parameters, reject requests outside retained coverage, return only filtered cached rows, and expose last-refresh metadata.
- Job logs capture start time, duration, row count, status, and error details.
- Phase 4 complete.
- Risk: In-process scheduler contention under load.
- Mitigation: Constrain job concurrency, isolate DB session handling, and monitor execution latency.
- Risk: Unbounded cache growth.
- Mitigation: Define retention policy and periodic cleanup jobs.
- Provide centralized operational controls and health visibility.
- Settings APIs and UI for base URL/port-related metadata, logging level, query timeout, CORS/rate-limit policy inputs.
- Health dashboard summarizing API, DB, Oracle connectivity probes, scheduler status, and recent job outcomes.
- Implement settings persistence model and validation constraints.
- Build admin APIs under
/api/v1/admin/settings/*. - Add runtime-safe application of mutable settings (where supported) and restart-required flags otherwise.
- Implement health aggregation service and dashboard widgets.
- Add alerts/flags for degraded dependencies and stale snapshots.
- Settings can be viewed/updated with validation and audit trail.
- Health dashboard reflects real-time system state and recent scheduler outcomes.
- Misconfigurations surface clear diagnostics without exposing secrets.
- Phase 5 complete.
- Risk: Runtime mutation causing inconsistent behavior.
- Mitigation: Explicitly separate dynamic vs restart-required settings.
- Risk: Health indicators becoming noisy/unreliable.
- Mitigation: Define probe intervals, timeout thresholds, and debounce rules.
- Validate production readiness across module boundaries and security controls.
- Cross-module integration and smoke E2E tests.
- Security validation checklist and remediation pass.
- Deployment and operations documentation for self-hosted environments.
- Build end-to-end smoke scenarios:
- Create connection -> configure auth -> publish endpoint -> schedule snapshot -> consume
/api/v1/data/*.
- Create connection -> configure auth -> publish endpoint -> schedule snapshot -> consume
- Add negative-path security tests (invalid auth, SQL injection attempts, malformed parameters, rate-limit behavior).
- Validate migration upgrade path from baseline to latest.
- Add performance sanity tests for common query and snapshot paths.
- Finalize docs: architecture, API versioning/deprecation, setup, backup/restore, incident troubleshooting.
- Critical E2E smoke suite passes in CI on clean environment.
- Security checklist items are verified with no unresolved high-severity findings.
- Deployment runbook enables first-time setup without tribal knowledge.
- Phases 0-6 complete.
- Risk: Late integration defects across modules.
- Mitigation: Gate each phase with integration tests and contract checks before advancing.
- Risk: Gaps between implementation and operational docs.
- Mitigation: Documentation updates required in same PR as behavior changes.
- Backend tests
- Unit tests for services, validation logic, auth helpers, scheduler orchestration, and router resolution.
- Integration tests for API routes, DB persistence, migrations, and Oracle query execution paths.
- Frontend tests
- Component tests for forms, wizard step logic, validation states, and schedule controls.
- Targeted integration tests for critical user flows in the admin SPA.
- End-to-end smoke tests
- Minimal but mandatory flows covering publish-and-consume lifecycle and scheduled snapshot refresh.
- Test data and environments
- Seed deterministic fixture data for PostgreSQL.
- Use controlled Oracle test schema for repeatable query tests.
GitHub Actions workflows will run on pull requests and protected branches with separate jobs:
- Backend job
- Setup Python 3.14+
- Install backend dependencies
- Run
ruff,mypy,pytest
- Frontend job
- Setup Node LTS
- Install frontend dependencies
- Run
eslint,prettier --check,vitest(or Jest)
- Docker job
- Build backend and frontend images
- Validate
docker-composebuild targets
- Optional gating enhancements
- Migration check job (upgrade from empty DB)
- E2E smoke job against compose environment for release branches
- Environments and configuration
- Use Pydantic Settings (Pydantic v2) as the canonical
.envschema and configuration loader. - Maintain per-environment variable sets for local, test, staging, production.
- Keep secrets out of code and inject via environment/secret manager.
- Use Pydantic Settings (Pydantic v2) as the canonical
- Logging and observability
- Standardize structured JSON logs (structlog) across API, scheduler, and DB operations.
- Include correlation IDs and principal identifiers for traceability.
- Redact credentials, tokens, and sensitive payload fields at logger middleware level.
- Migrations and schema control
- Alembic is mandatory from day one.
- All app DB schema changes must be migration-driven and validated in CI.
- Backup and recovery notes
- Define backup strategy for PostgreSQL metadata and cached snapshots.
- Document restore procedure and verify restore drills at least in staging.
- Keep migration and application version compatibility notes in release docs.
- Upgrade/versioning notes
- Maintain API versioned namespaces from initial release (
/api/v1/admin/*,/api/v1/data/*). - Use explicit deprecation notices and migration documentation for contract evolution.
- Track dependency upgrade windows (Python, FastAPI, APScheduler, SQLAlchemy, frontend libs) with quarterly review cadence.
- Maintain API versioned namespaces from initial release (