25
CodeDev system / System reference

CodeDev database and data model

The current PostgreSQL/SQLAlchemy entities and the relationships that power projects, releases, media, leads, settings, analytics, users, and audit history.

codedevpostgresqlsqlalchemymodelsschema

01Persistent entities

ModelPurpose
UserAdmin identity, role, MFA/lockout/session-revocation state
ProjectPublic portfolio project and case-study fields
ReleaseVersion/channel/status/download metadata tied to a project
MediaUploaded image metadata and project ownership
LeadContact/inquiry records
SiteSettingKey/value CMS presentation settings
AnalyticsEventPrivacy-light server-side event counts/referrer domain
AuditLogPrivileged action history

02Important relationships

  • Project → Releases is one-to-many with delete-orphan cascade.
  • Project → Media is one-to-many with delete-orphan cascade.
  • Release(project_id, version) is unique per project.
  • Project.slug and User.email are unique and indexed.
  • Public-project indexes support published/build-area/featured/sort-order query patterns.

03State-change rule

Project/media workflows stage database changes and commit together. When upload validation/storage fails, the transaction is rolled back and already-stored media keys are cleaned up so the database does not claim a file was saved when the workflow failed.