Back to docs
Architecture

Data Model

Dagy organizes platform data into domain-specific entities. This document describes the core entities, their relationships, and access patterns.

Entity Overview

Dagy manages 21 entity types organized by domain:

#EntityPurpose
1FlowFlow definitions (immutable per version)
2DeploymentNamed deployments binding a flow version
3RunFlow run executions
4TaskRunIndividual task executions within a run
5ScheduleCron, interval, and one-time schedules
6UserUser accounts
7AccessTokenAuthentication tokens (with TTL expiry)
8AccessLogAccess audit trail
9OrganizationOrganizations/tenants
10MembershipOrg memberships and roles
11ApiKeyAPI keys (hashed at rest)
12DagDraftVisual builder drafts
13UsageEventRaw usage events
14UsageAggregateAggregated usage counters
15SubscriptionBilling subscriptions
16AuditLogMutation audit trail
17SecretEncrypted secrets
18NotificationChannelAlert channels
19AlertRuleAlert rules
20EnvironmentEnvironments (dev/staging/prod)
21SensorEvent sensors/triggers

Multi-Tenancy

All entities that store user-facing data include an org_id attribute. The API resolves org_id from the authenticated identity and filters all queries by it, providing data isolation between organizations.

Org-scoped entities: Flow, Deployment, Run, TaskRun, Schedule, DagDraft, UsageEvent, UsageAggregate, Subscription, AuditLog, Secret, NotificationChannel, AlertRule, Environment, Sensor, ApiKey.

Core Execution Entities

Flow

Stores flow definitions (immutable per version).

FieldTypeDescription
flow_nameStringFlow identifier (unique key with flow_version)
flow_versionStringVersion string (e.g. "1.0.0", "latest")
org_idStringOrganization ID
namespaceStringHierarchical grouping path (e.g. data/ingestion)
tagsMapArbitrary key-value metadata (e.g. {"team": "data-eng"})
flow_spec_jsonStringSerialized FlowSpec (tasks, edges, outputs)
artifact_s3_uriStringS3 path to ZIP artifact
statusStringACTIVE, INACTIVE
deployment_nameStringAssociated deployment
default_executorStringPreferred backend
deployment_versionNumberAuto-incrementing deployment counter
code_hashStringSHA-256 of flow spec + source code (for change detection)
created_atStringISO timestamp
updated_atStringISO timestamp

Deployment

Named deployment binding a flow version to a deployment name with optional schedule.

FieldTypeDescription
deployment_nameStringDeployment identifier (primary key)
org_idStringOrganization ID
flow_nameStringReference to Flow
flow_versionStringPinned flow version
scheduleStringOptional cron expression
default_executorStringPreferred backend
tagsMapArbitrary key-value metadata
statusStringACTIVE, PAUSED

Run

Tracks individual flow run executions.

FieldTypeDescription
run_idStringUUID (primary key)
org_idStringOrganization ID
run_slugStringHuman-friendly identifier
flow_nameStringFlow being executed
flow_versionStringFlow version
deployment_nameStringSource deployment
statusStringQUEUED, RUNNING, SUCCEEDED, FAILED, CANCELLED
parametersMapRuntime parameters
executorStringBackend used (lambda, step-functions, ecs)
external_idStringBackend-specific ID (ARN, task ID)
started_atStringISO timestamp
completed_atStringISO timestamp
created_atStringISO timestamp

TaskRun

Tracks individual task executions within a run.

FieldTypeDescription
run_idStringParent run ID
task_run_idStringUnique task run ID
task_nameStringTask name
statusStringPENDING, RUNNING, SUCCEEDED, FAILED, SKIPPED
attemptNumberCurrent attempt number
executorStringBackend that executed this task
started_atStringISO timestamp
completed_atStringISO timestamp
error_messageStringFailure details
output_refStringTaskOutput reference

Schedule

Defines recurring or one-time schedules for flows.

FieldTypeDescription
flow_nameStringAssociated flow
schedule_idStringSchedule identifier
org_idStringOrganization ID
modeStringcron, interval, one_time, manual
enabledBooleanWhether schedule is active
cron_expressionStringCron expression (for cron mode)
interval_secondsNumberInterval (for interval mode)
timezoneStringIANA timezone
catchup_policyStringnone, all
parametersMapDefault parameters for triggered runs
next_run_epochNumberNext due time (epoch seconds)
next_run_atStringISO timestamp
last_triggered_atStringISO timestamp
start_atStringSchedule start boundary
end_atStringSchedule end boundary

Enterprise Entities

AuditLog

Immutable audit trail of all mutations across the platform.

FieldTypeDescription
org_idStringOrganization ID
event_timeStringISO timestamp + UUID suffix for uniqueness
resource_typeStringflow, secret, member, schedule, channel, etc.
resource_idStringID of the affected resource
actionStringcreate, update, delete
actor_emailStringWho performed the action
before_jsonStringState before the change
after_jsonStringState after the change
ip_addressStringClient IP address

Secret

Fernet-encrypted secrets with per-environment scoping.

FieldTypeDescription
org_idStringOrganization ID
secret_nameStringSecret identifier
encrypted_valueStringBase64-encoded Fernet-encrypted value
environmentStringOptional environment scope (null = org-wide)
created_byStringCreator's email
created_atStringISO timestamp
updated_atStringISO timestamp

Environment

Named environments for deployment promotion workflows.

FieldTypeDescription
org_idStringOrganization ID
env_nameStringEnvironment name (dev, staging, production)
default_executorStringPreferred backend for this environment
config_jsonStringEnvironment-specific configuration
is_protectedBooleanIf true, cannot be deleted
created_atStringISO timestamp
updated_atStringISO timestamp

Sensor

Event-driven triggers that automatically start flows.

FieldTypeDescription
org_idStringOrganization ID
sensor_idStringSensor identifier
nameStringDisplay name
sensor_typeStrings3, webhook, polling
flow_nameStringFlow to trigger
flow_params_jsonStringParameters to pass
config_jsonStringType-specific configuration
enabledBooleanWhether sensor is active
webhook_tokenStringAuto-generated token (webhook type only)
last_triggered_atStringISO timestamp
created_atStringISO timestamp

Relationships

Organization (1) ---- (*) Membership ---- (1) User
     |
     +-- (*) Flow ---- (*) Deployment ---- (*) Run ---- (*) TaskRun
     |                       |
     |                       +-- (*) Schedule
     +-- (*) ApiKey
     +-- (*) DagDraft
     +-- (*) Secret
     +-- (*) Environment
     +-- (*) NotificationChannel
     +-- (*) AlertRule
     +-- (*) Sensor
     +-- (*) AuditLog
     +-- (*) UsageEvent
     +-- (1) UsageAggregate (per period)
     +-- (1) Subscription

Access Patterns

PatternEntityKey Fields
Get flow by name + versionFlowflow_name, flow_version
List flows for orgFloworg_id filter
Get runs for flowRunflow_name
Get due schedulesScheduleenabled=true, next_run_epoch <= now
List members of orgMembershiporg_id
Get audit trail for resourceAuditLogresource_type + resource_id
List secrets for environmentSecretorg_id, environment filter
Find sensor by webhook tokenSensorwebhook_token filter