Skip to content

feat(database): integrate Supabase PostgreSQL with SQLAlchemy models and Alembic migrations#16

Merged
Yosoyepa merged 3 commits intodevelopfrom
feature/SupabaseIntegration
Nov 27, 2025
Merged

feat(database): integrate Supabase PostgreSQL with SQLAlchemy models and Alembic migrations#16
Yosoyepa merged 3 commits intodevelopfrom
feature/SupabaseIntegration

Conversation

@Yosoyepa
Copy link
Owner

📝 Descripción

Integración completa de Supabase PostgreSQL como base de datos de producción para CodeGuard AI. Se implementaron modelos ORM con SQLAlchemy, migraciones con Alembic, y repositorios para persistencia de análisis de código.

🎯 Historia de Usuario Relacionada

Closes #15 (CGAI-15: Supabase modelos y migraciones)

✅ Cambios Implementados

Base de Datos

  • Conexión a Supabase PostgreSQL via DATABASE_URL
  • Modelos SQLAlchemy: UserEntity, CodeReviewEntity, AgentFindingEntity
  • Migraciones Alembic con esquema inicial
  • Tablas creadas en Supabase: users, code_reviews, agent_findings

Repositorios

  • CodeReviewRepository: CRUD para análisis
  • AgentFindingRepository: persistencia de hallazgos
  • Integración con AnalysisService para guardar resultados

Análisis → BD

  • El endpoint POST /api/v1/analyze ahora persiste:
    • code_reviews con metadata del análisis
    • agent_findings con cada vulnerabilidad detectada
  • Cifrado AES-256 para code_content

Documentación

  • WARP.md - Guía para desarrollo con Warp terminal
  • SoftwareDesingPrinciples.instructions.md - Principios de diseño

🧪 Cómo se Probó

  • Backend conecta a Supabase exitosamente
  • Migraciones aplicadas con alembic upgrade head
  • Análisis ejecuta y detecta vulnerabilidades (3 críticos en test)
# Análisis exitoso con persistencia
POST /api/v1/analyze → 200 OK
CodeReview persistido: 1754e5ab-b6a1-4dce-997a-e3e6f485f43c

📋 Checklist Previo al Merge

  • Mi código sigue las convenciones del proyecto
  • He actualizado la documentación relevante (WARP.md)
  • Mis commits siguen Conventional Commits
  • CI/CD passing (lint, test, docker)
  • He configurado .env con Supabase credentials

- Add UserEntity with Clerk ID, rate limiting, and role management
- Add CodeReviewEntity with encrypted code storage support
- Add AgentFindingEntity with severity and quality metrics
- Create enums: SeverityEnum, UserRole aligned with PostgreSQL ENUMs
- Configure Alembic env.py for model discovery and autogenerate
- Implement relationships with cascade delete for data integrity

Related CGAI-15
- Create users table with Clerk ID, role, rate limiting fields
- Create code_reviews table with encrypted code storage
- Create agent_findings table with severity and metrics
- Add PostgreSQL ENUMs: userrole, reviewstatus, severityenum
- Add indexes for performance optimization
- Configure cascade delete for data integrity

Migration ID: ba48c1bb8e18
Related CGAI-15
@Yosoyepa Yosoyepa added the enhancement New feature or request label Nov 27, 2025
@Yosoyepa Yosoyepa self-assigned this Nov 27, 2025
@Yosoyepa Yosoyepa merged commit f95c460 into develop Nov 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant