Migrate flight-blender from Django to FastAPI (partial)#1
Draft
Migrate flight-blender from Django to FastAPI (partial)#1
Conversation
- Add flight_blender/config.py: Pydantic-style config replacing Django settings - Add flight_blender/db.py: SQLAlchemy engine, session, and Base setup - Update flight_blender/celery.py: Remove Django dependency, use dotenv and explicit conf - Update flight_blender/__init__.py: Remove Django-style import, use wildcard logging import Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Convert 8 models.py files from Django ORM to SQLAlchemy: - flight_feed_operations/models.py - flight_declaration_operations/models.py - geo_fence_operations/models.py - conformance_monitoring_operations/models.py - constraint_operations/models.py - rid_operations/models.py - surveillance_monitoring_operations/models.py - notification_operations/models.py Key changes: - Replace Django models.Model with SQLAlchemy Base (DeclarativeBase) - Convert all field types to SQLAlchemy Column types - Convert ForeignKey/OneToOneField to ForeignKey + relationship() - Replace auto_now_add/auto_now with default/onupdate datetime.utcnow - Remove django_celery_beat dependency from TaskScheduler - Rename metadata field to metadata_ (mapped to 'metadata' column) to avoid conflict with SQLAlchemy reserved attribute Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace Django ORM queries with SQLAlchemy Session-based queries - Both FlightBlenderDatabaseReader and FlightBlenderDatabaseWriter now accept a db: Session parameter in their constructor - Replace Model.objects.get() with db.query(Model).filter().first() - Replace Model.objects.filter().exists() with .first() is not None - Replace .save() with db.add(); db.commit(); db.refresh() - Replace .delete() with db.delete() or db.query().delete() - Replace django.db.utils.IntegrityError with sqlalchemy.exc.IntegrityError - Replace QuerySet return types with list[Model] - Replace Django signals with direct function call to handler - Replace TaskScheduler.schedule_every/start/terminate with DB record creation/deletion and Celery beat scheduler warning - Add db.rollback() in exception handlers for transaction safety Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use FK column assignments (e.g., declaration_id=x.id) instead of relationship assignments for SQLAlchemy model construction - Fix metadata -> metadata_ to match FlightObservation model attribute - Use .is_(True)/.is_(False) for boolean comparisons in SQLAlchemy filters Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rations to FastAPI/SQLAlchemy Co-authored-by: RomanPszonka <57806+RomanPszonka@users.noreply.github.com>
…go/DRF to FastAPI - Replace Django views/DRF views with FastAPI route handlers using APIRouter - Convert HomeView/ASGIHomeView TemplateViews to simple JSON endpoints - Replace JsonResponse with JSONResponse, request.data with json.loads(await request.body()) - Add request: Request and db: Session = Depends(get_db) parameters - Convert DRF ListCreateAPIView/RetrieveUpdateDestroyAPIView to individual CRUD endpoints - Convert DRF ModelSerializer to Pydantic BaseModel - Simplify urls.py to just import and export the router Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace @api_view decorators with FastAPI @router.get/post/put/delete - Replace JsonResponse/HttpResponse with JSONResponse/Response from fastapi - Replace request.data with json.loads(await request.body()) - Add request: Request, db: Session = Depends(get_db) parameters - Pass db to FlightBlenderDatabaseReader/Writer and SubscriptionsHelper - Make view functions async - Simplify urls.py to re-export the router Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Convert flight-blender from Django to FastAPI
Migrate flight-blender from Django to FastAPI (partial)
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partial migration of flight-blender from Django/DRF to FastAPI/SQLAlchemy. This PR establishes the core infrastructure and converts a subset of modules. The migration is incomplete — remaining view modules, app entry point, and cleanup are still needed.
What's done
pyproject.toml): Replaced Django, DRF, django-celery-beat, dj-database-url, channels/channels-redis with FastAPI, SQLAlchemy 2.0, Alembic, websocketsflight_blender/config.py— env-based config replacingsettings.pyflight_blender/db.py— SQLAlchemy engine,SessionLocal,Base,get_db()dependencyflight_blender/celery.py— decoupled from Django settings, explicit task discoverymodels.pyfilescommon/database_operations.py(1361 lines) — full rewrite from Django ORM to SQLAlchemy session-based queries;FlightBlenderDatabaseReader/Writernow acceptdb: Sessionin constructorauth_helper/utils.py—requires_scopesdecorator now usesfastapi.HTTPExceptioninstead ofdjango.http.JsonResponse, extracts auth fromrequest.headersinstead ofrequest.METAcommon/data_definitions.py— removedgettext_lazydependency, plain stringscommon/utils.py— removedDjangoJSONEncoderdependencyflight_feed_operations,rid_operations— Django views → FastAPIAPIRouterendpoints withDepends(get_db)injectionWhat's NOT done
scd_operations,uss_operations,geo_fence_operations,flight_declaration_operations,weather_monitoring_operations,surveillance_monitoring_operations,conformance_monitoring_operationsasgi.pywith router mounting)TestCase→ pytest +TestClient)admin.py,apps.py,migrations/,manage.py)Pattern
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.