Skip to content

Replace FastAPI scaffold with Django graph administration - #2

Closed
dragosandreibobu wants to merge 58 commits into
mainfrom
agent/django-graph-admin
Closed

Replace FastAPI scaffold with Django graph administration#2
dragosandreibobu wants to merge 58 commits into
mainfrom
agent/django-graph-admin

Conversation

@dragosandreibobu

@dragosandreibobu dragosandreibobu commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What changed

  • replaces the FastAPI starter with Django 5.2 LTS and Django REST Framework
  • adopts the existing Supabase UUID concept and relation tables without replacing their identifiers
  • exposes concepts, relations, health, and bounded graph-neighbourhood endpoints
  • adds searchable Django admin tables with relation autocomplete
  • adds a filterable graph explorer with safe JSON serialization and bounded node/edge counts
  • adds a superuser-only SQL workbench with single-statement enforcement, timeouts, read-only defaults, explicit APPLY confirmation, and dry-run rollback
  • requires Django model permissions for REST writes while keeping anonymous reads available
  • adds PostgreSQL 17 CI, migration-drift checks, Django checks, and API/admin/security tests
  • removes the obsolete FastAPI runtime and documents the Django environment
  • adds AGENTS.md implementation invariants

Why

curricula.live needs a maintainable editing surface for the knowledge graph while preserving the existing Supabase data and identifiers.

Validation

  • aligned Django models and migration state with the live Supabase UUID/foreign-key schema
  • verified existing relation predicates remain extensible rather than forcing a closed enum
  • verified no duplicate typed relations block the unique index
  • CI provisions fresh PostgreSQL 17, applies migrations, checks migration drift, and runs the test suite

Remaining before production

  • configure deployment secrets and host/CSRF values
  • create the initial Django superuser/editor groups
  • decide and implement public Supabase RLS read policies, if direct Data API reads are desired
  • review Codex feedback and keep this PR draft until CI and review are clean

@dragosandreibobu

Copy link
Copy Markdown
Contributor Author

@codex can u fix the vercel deployment issue

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • Added Vercel deployment metadata: pinned Python 3.12, configured Vercel to load the Django WSGI app from config.wsgi:application, and added function settings for config/wsgi.py.
  • Fixed the SQL workbench read-only transaction path to use PostgreSQL’s valid SET TRANSACTION READ ONLY command before executing user SQL.
  • Updated the initial migration so unique_typed_relation is represented as a real PostgreSQL table constraint, adopting an existing compatible index when present or creating the constraint directly on fresh databases.
  • Added explicit lowercase snake_case validation for relation predicates while preserving extensible predicate strings.
  • Added REST serializer validation so API relation writes enforce the model self-relation rule.
  • Added regression tests for relation predicate validation, API self-relation validation, API predicate validation, read-only SQL execution, and the database unique constraint.
  • Committed the changes on the current branch with commit c00dcad and created PR metadata with the make_pr tool.

Testing

  • python manage.py check
  • python manage.py makemigrations --check --dry-run
  • pytest
  • su postgres -c "dropdb --if-exists curricula_fresh" && su postgres -c "createdb curricula_fresh" && DATABASE_URL=postgresql://postgres:postgres@localhost:5432/curricula_fresh python manage.py migrate --noinput && DATABASE_URL=postgresql://postgres:postgres@localhost:5432/curricula_fresh python manage.py shell -c "from django.db import connection; c=connection.cursor(); c.execute(\"select contype from pg_constraint where conrelid = 'relation'::regclass and conname = 'unique_typed_relation'\"); print(c.fetchone())"
  • ⚠️ npx vercel@latest build — attempted, but Vercel CLI could not build without local project settings and also reported a package metadata fetch failure in this environment.

View task →

Copy link
Copy Markdown
Contributor Author

Review update (2026-07-19): I pushed focused correctness and deployment changes through commit d8eacb9559c56680662b8d3c6eb47521deb0b12d.

Fixed: valid PostgreSQL read-only transaction mode; real unique_typed_relation constraint adoption; REST self-relation validation; lowercase snake_case relation predicates; production settings/static handling; root health route; Vercel WSGI entry point; Python 3.12 metadata; regression tests and deployment documentation. GitHub Actions run 24 passes on PostgreSQL 17 (15 tests plus compile, migrate, Django checks, deploy checks, and migration-drift check).

I did not merge because required deployment/database gates remain open:

  1. Latest Vercel preview still fails while packaging the PostgreSQL binary driver (psycopg2._psycopg missing). The project is also still recorded by Vercel as framework fastapi, so its project framework must be changed to Other/Python before another clean validation.
  2. Preview runtime variables are not configured/accessible through the connected tools: DATABASE_URL (staging/non-production), DJANGO_SECRET_KEY, DJANGO_DEBUG=false, DJANGO_ALLOWED_HOSTS, DJANGO_CSRF_TRUSTED_ORIGINS, DB_SSL_REQUIRE=true.
  3. No staging or read-only Supabase connection was available. Therefore the real table/column/FK/nullability/index/RLS schema, safe read, staging write+cleanup, and migration safety against the external schema could not be verified. The initial migration contains schema-altering SQL and must not be run on production until compared against a staging clone.
  4. The four review threads remain marked unresolved by GitHub even though their code changes and regression tests are present.

Smallest next action: configure a staging Supabase DATABASE_URL for Preview, change the Vercel project framework from FastAPI to Other/Python, and resolve the Vercel binary-driver packaging issue (or move this Django service to Render, which is a more natural fit for persistent Django/PostgreSQL administration). Then re-run preview smoke tests before merge.

@dragosandreibobu

Copy link
Copy Markdown
Contributor Author

prea mare și amestecă decizii arhitecturale diferite: 58 commit-uri, 33 fișiere, ~1.500 linii.

Într-un singur PR face simultan:

FastAPI → Django + DRF;
definește/modifică schema Supabase;
expune API public pentru graph;
construiește admin, graph visualizer;
introduce un SQL workbench care poate executa scrieri;
adaugă CI și încearcă să pregătească Vercel.

Asta face dificil să știi ce e deja corect, ce e deployat și unde apare o problemă.

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.

2 participants