mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 23:04:57 +00:00
Implemented SQLAlchemy ORM for database persistence: **Models**: - Workflow: Stores workflow definitions with JSON fields for nodes/connections - Execution: Tracks workflow execution runs with status, timing, and results - NodeType: Caches available node types for registry lookups - AuditLog: Tracks all changes for compliance and debugging **Database Features**: - Proper indexing for efficient queries (tenant_id, workflow_id, status, etc.) - Foreign key relationships with cascade deletes - JSON fields for flexible node/connection storage - Audit trail for all workflow changes **Updated Flask Server** (server_sqlalchemy.py): - Uses Flask-SQLAlchemy for ORM - Database connection pooling - Proper error handling and transactions - Audit logging on all changes - Pagination support for list endpoints **Configuration**: - Support for SQLite (development) and PostgreSQL (production) - Environment-based database URL - Automatic table creation - Transaction management **Endpoints Enhanced**: - Pagination (limit, offset parameters) - Better error handling with proper HTTP status codes - Total count in list responses - Change tracking in audit logs **Performance Optimizations**: - Indexed queries for common filters - Database constraints to prevent invalid states - Efficient JSON storage for flexible fields - Connection pooling for concurrent requests Architecture: - SQLAlchemy models separate from Flask routes - ORM handles all database interactions - JSON serialization/deserialization for flexibility - Backward compatible API responses Migration Path: - In-memory server (server.py) still available for simple deployments - Production server uses SQLAlchemy (server_sqlalchemy.py) - Database-first schema allows easy schema migration tools Next: Update Flask app to use server_sqlalchemy.py by default Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>