Quantra Documentation

Database Schema Reference

Quantra uses Django's ORM to define and manage its database schema. The platform supports SQLite (for development), PostgreSQL, and Microsoft SQL Server as database backends. This reference documents every model, its fields, constraints, relationships, and purpose within the system.

Overview

The Quantra database schema consists of 10 primary models that together represent user management, project structure, canvas design, pipeline execution, service infrastructure, audit logging, and system configuration. All models are defined in the Django application and managed through Django migrations.

CustomUser

The CustomUser model extends Django's AbstractUser to provide email-based authentication and multi-factor authentication support. This is the primary user identity model in the system.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the user.
emailEmailField (varchar)UNIQUE, NOT NULLThe user's email address. Serves as the login identifier. Must be unique across all accounts.
first_nameCharField (varchar 150)NOT NULL, default ''The user's first name.
last_nameCharField (varchar 150)NOT NULL, default ''The user's last name.
passwordCharField (varchar 128)NOT NULLThe hashed password. Stored using Django's PBKDF2-SHA256 hasher with a random salt.
is_staffBooleanFieldNOT NULL, default FalseDesignates whether the user has access to the admin panel and administrative API endpoints.
is_activeBooleanFieldNOT NULL, default TrueDesignates whether the account is active. Inactive accounts cannot log in.
mfa_secretCharField (varchar 32)NULL, BLANKThe TOTP shared secret for multi-factor authentication. Null when MFA is not configured. Generated using pyotp when the user enrolls in MFA.
mfa_enabledBooleanFieldNOT NULL, default FalseWhether multi-factor authentication is currently active for this user.
recovery_codesJSONFieldNULL, BLANKA JSON array of single-use recovery codes for MFA bypass. Each code is invalidated after use. Null when MFA is not configured.
date_joinedDateTimeFieldNOT NULL, auto_now_addTimestamp of when the user account was created.
last_loginDateTimeFieldNULLTimestamp of the user's most recent successful login.
Authentication note: The USERNAME_FIELD is set to email, overriding Django's default username-based authentication. The username field from AbstractUser is not used.

Profile

The Profile model extends the CustomUser with additional user attributes. It has a one-to-one relationship with CustomUser.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the profile.
user_idIntegerFieldFOREIGN KEY (CustomUser.id), UNIQUE, ON DELETE CASCADEReferences the associated CustomUser. One-to-one relationship.

The Profile model can be extended with additional fields as needed (e.g., avatar, department, phone number, preferences). The one-to-one relationship ensures that each user has at most one profile, and deleting a user cascades to delete the profile.

Project

The Project model represents a pipeline project. Each project contains a canvas with nodes and edges that define the document processing pipeline.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the project.
nameCharField (varchar 255)NOT NULLThe display name of the project.
owner_idIntegerFieldFOREIGN KEY (CustomUser.id), ON DELETE CASCADEThe user who created and owns the project. The owner always has full Write access.
created_atDateTimeFieldNOT NULL, auto_now_addTimestamp of when the project was created.
updated_atDateTimeFieldNOT NULL, auto_nowTimestamp of the last modification. Automatically updated on every save.
descriptionTextFieldNULL, BLANKAn optional description of the project's purpose and contents.

CanvasNode

The CanvasNode model represents a single node on the project canvas. Each node corresponds to a plugin instance (datasource, tool, or workbench) positioned at specific coordinates on the visual editor.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the node.
project_idIntegerFieldFOREIGN KEY (Project.id), ON DELETE CASCADEThe project this node belongs to. Deleting a project cascades to delete all its nodes.
node_typeCharField (varchar 20)NOT NULL, CHOICESThe type of plugin this node represents. Valid choices: datasource, tool, workbench.
plugin_idCharField (varchar 100)NOT NULLThe identifier of the plugin this node uses. Must match the id field in a registered plugin's plugin.json manifest.
labelCharField (varchar 255)NOT NULLThe display label shown on the canvas. Defaults to the plugin name but can be customized by the user.
x_posIntegerFieldNOT NULL, default 0Horizontal position of the node on the canvas, in pixels from the left edge.
y_posIntegerFieldNOT NULL, default 0Vertical position of the node on the canvas, in pixels from the top edge.
configJSONFieldNOT NULL, default {}Plugin-specific configuration stored as a JSON object. The schema depends on the plugin. Examples: file type filters for a file upload datasource, OCR engine selection for an OCR tool, display options for a workbench.
created_atDateTimeFieldNOT NULL, auto_now_addTimestamp of when the node was added to the canvas.

node_type Choices

ValueDescription
datasourceA data ingestion node that brings documents or data into the pipeline.
toolA processing node that transforms, analyzes, or enriches data.
workbenchAn interactive UI node for human review and interaction with processed data.

CanvasEdge

The CanvasEdge model represents a directed connection between two nodes on the canvas. Edges define the data flow and dependencies between pipeline steps.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the edge.
project_idIntegerFieldFOREIGN KEY (Project.id), ON DELETE CASCADEThe project this edge belongs to.
source_node_idIntegerFieldFOREIGN KEY (CanvasNode.id), ON DELETE CASCADEThe node where the edge originates. Data flows from the source to the target.
target_node_idIntegerFieldFOREIGN KEY (CanvasNode.id), ON DELETE CASCADEThe node where the edge terminates. This node receives data from the source.
edge_modeCharField (varchar 20)NOT NULL, CHOICESThe type of connection. Determines how data flows between the connected nodes.

edge_mode Choices

ValueDescription
flowStandard data flow edge. The output of the source node is passed as input to the target node during pipeline execution. Nodes connected by flow edges are executed in topological order.
interactiveInteractive edge. Indicates that the target node provides an interactive interface for reviewing or modifying the source node's output. Typically used to connect processing tools to workbenches.
referenceReference edge. The target node can access the source node's data for reference purposes, but it does not receive it as direct input in the pipeline flow. Used for cross-referencing between nodes.

ServiceEndpoint

The ServiceEndpoint model stores the connection details for each registered gRPC microservice. The platform uses this table to discover and connect to microservices during pipeline execution.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the service endpoint.
nameCharField (varchar 100)NOT NULL, UNIQUEThe name of the microservice. Must match the service identifier used in plugin configurations.
hostCharField (varchar 255)NOT NULLThe hostname or IP address where the microservice is running. Typically localhost for single-machine deployments.
portIntegerFieldNOT NULL, UNIQUEThe port number the microservice listens on. Must be in the range 50051-50090 and must be unique across all services.
protocolCharField (varchar 20)NOT NULL, default 'grpc'The communication protocol. Currently always grpc.
is_activeBooleanFieldNOT NULL, default TrueWhether the service endpoint is currently active. Inactive endpoints are skipped during pipeline execution.
descriptionTextFieldNULL, BLANKA human-readable description of the microservice's function.

GraphExecution

The GraphExecution model records every pipeline execution, including its status, timing, the chain JSON that was executed, and the result data.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the execution.
project_idIntegerFieldFOREIGN KEY (Project.id), ON DELETE CASCADEThe project whose pipeline was executed.
started_atDateTimeFieldNOT NULL, auto_now_addTimestamp of when the execution was initiated.
completed_atDateTimeFieldNULLTimestamp of when the execution finished (either successfully or with an error). Null while the execution is still running.
statusCharField (varchar 20)NOT NULL, default 'running'The current status of the execution. Values: running, completed, failed.
result_dataJSONFieldNULLThe output data from the execution, stored as a JSON object. Contains the results from each node in the pipeline. Null while the execution is running.
chain_jsonJSONFieldNULLThe CNO chain JSON document that was constructed and executed. Stored for auditability, debugging, and replay.
initiated_by_idIntegerFieldFOREIGN KEY (CustomUser.id), ON DELETE SET NULL, NULLThe user who initiated the execution. Set to NULL if the user account is deleted.

AuditLog

The AuditLog model records security-relevant and operational events for compliance and forensic analysis.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the audit log entry.
user_idIntegerFieldFOREIGN KEY (CustomUser.id), ON DELETE SET NULL, NULLThe user who performed the action. NULL if the user has been deleted or the event is system-generated.
event_typeCharField (varchar 30)NOT NULL, CHOICES (14 values)The type of event. See the event type choices table below.
timestampDateTimeFieldNOT NULL, auto_now_addWhen the event occurred.
detailsJSONFieldNULL, BLANKA JSON object containing event-specific details. The schema varies by event type. Examples: project ID and name for project events, permission level for share events, error message for execution failures.
ip_addressGenericIPAddressFieldNULLThe IP address of the client that triggered the event. Captured from the HTTP request.

event_type Choices (14 types)

ValueCategoryDescription
login_successAuthenticationSuccessful user login.
login_failureAuthenticationFailed login attempt.
logoutAuthenticationUser logged out.
mfa_enabledAccountUser enabled MFA.
mfa_disabledAccountUser disabled MFA.
password_changeAccountUser changed password.
project_createdProjectNew project created.
project_deletedProjectProject deleted.
project_sharedProjectProject shared with another user.
execution_startedExecutionPipeline execution started.
execution_completedExecutionPipeline execution completed.
execution_failedExecutionPipeline execution failed.
settings_changedAdminSystem settings modified.
user_createdAdminNew user account created.

ProjectShare

The ProjectShare model manages project access permissions between users. It records which projects have been shared with which users, at what permission level, and by whom.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEY, AUTO INCREMENTUnique identifier for the share record.
project_idIntegerFieldFOREIGN KEY (Project.id), ON DELETE CASCADEThe project being shared.
shared_with_idIntegerFieldFOREIGN KEY (CustomUser.id), ON DELETE CASCADEThe user who is being granted access to the project.
permission_levelCharField (varchar 10)NOT NULL, CHOICESThe level of access granted. Choices: read, execute, write.
shared_by_idIntegerFieldFOREIGN KEY (CustomUser.id), ON DELETE SET NULL, NULLThe user who granted the share. NULL if the granting user has been deleted.
shared_atDateTimeFieldNOT NULL, auto_now_addTimestamp of when the share was created.

permission_level Choices

ValueCapabilities
readView the project, its canvas, and execution results. No modifications or executions allowed.
executeAll read capabilities plus the ability to run pipelines.
writeFull control: modify canvas, run pipelines, share with others, delete the project.

SystemSettings

The SystemSettings model is a singleton table (only one row) that stores platform-wide configuration parameters. These settings control security policies, session behavior, and other system-level options.

ColumnTypeConstraintsDescription
idAutoField (int)PRIMARY KEYAlways 1 (singleton).
session_timeoutIntegerFieldNOT NULL, default 3600Session timeout in seconds. After this period of inactivity, the user's session is automatically invalidated and they must re-authenticate. Default: 3600 (1 hour).
max_login_attemptsIntegerFieldNOT NULL, default 5Maximum number of consecutive failed login attempts before the account is temporarily locked. Default: 5.
mfa_requiredBooleanFieldNOT NULL, default FalseWhen True, all users must enroll in multi-factor authentication before accessing the platform. Users without MFA enabled are redirected to the MFA setup page upon login.

Entity-Relationship Diagram

The following ASCII diagram shows the relationships between all models in the Quantra database schema:


+----------------+       +----------------+       +-----------------+
|   CustomUser   |       |    Profile     |       | SystemSettings  |
|----------------|       |----------------|       |-----------------|
| id         PK  |<--+   | id         PK  |       | id          PK  |
| email          |   |   | user_id   FK --+---+   | session_timeout |
| first_name     |   |   +----------------+       | max_login_att.. |
| last_name      |   |                            | mfa_required    |
| password       |   |                            +-----------------+
| is_staff       |   |
| is_active      |   |   +----------------+
| mfa_secret     |   +---| owner_id  FK   |
| mfa_enabled    |   |   |   Project      |
| recovery_codes |   |   |----------------|
| date_joined    |   |   | id         PK  |<---------+----------+
+----------------+   |   | name           |          |          |
        ^            |   | created_at     |   +------+---+  +---+--------+
        |            |   | updated_at     |   | CanvasNode|  | CanvasEdge |
        |            |   | description    |   |-----------|  |------------|
        |            |   +----------------+   | id     PK |  | id      PK |
        |            |          |              | project FK|  | project FK |
        |            |          |              | node_type |  | source  FK |--+
        |            |          |              | plugin_id |  | target  FK |--+
        |            |          |              | label     |  | edge_mode  |
        |            |          |              | x_pos     |  +------------+
        |            |          |              | y_pos     |       |
        |            |          |              | config    |<------+
        |            |          |              | created_at|
        |            |          |              +-----------+
        |            |          |
        |            |   +------------------+
        |            +---| initiated_by FK  |
        |            |   | GraphExecution   |
        |            |   |------------------|
        |            |   | id           PK  |
        |            |   | project_id   FK  |
        |            |   | started_at       |
        |            |   | completed_at     |
        |            |   | status           |
        |            |   | result_data      |
        |            |   | chain_json       |
        |            |   +------------------+
        |            |
        |            |   +------------------+
        |            +---| user_id     FK   |
        |            |   |    AuditLog      |
        |            |   |------------------|
        |            |   | id           PK  |
        |            |   | event_type       |
        |            |   | timestamp        |
        |            |   | details          |
        |            |   | ip_address       |
        |            |   +------------------+
        |            |
        |            |   +------------------+
        |            +---| shared_with  FK  |
        |            +---| shared_by    FK  |
        |                | ProjectShare     |
        |                |------------------|
        |                | id           PK  |
        |                | project_id   FK  |
        |                | permission_level |
        |                | shared_at        |
        |                +------------------+
        |
+-------------------+
| ServiceEndpoint   |
|-------------------|
| id            PK  |
| name              |
| host              |
| port              |
| protocol          |
| is_active         |
| description       |
+-------------------+

Foreign Key Summary

The following table summarizes all foreign key relationships in the schema:

Source ModelSource ColumnTarget ModelTarget ColumnOn Delete
Profileuser_idCustomUseridCASCADE
Projectowner_idCustomUseridCASCADE
CanvasNodeproject_idProjectidCASCADE
CanvasEdgeproject_idProjectidCASCADE
CanvasEdgesource_node_idCanvasNodeidCASCADE
CanvasEdgetarget_node_idCanvasNodeidCASCADE
GraphExecutionproject_idProjectidCASCADE
GraphExecutioninitiated_by_idCustomUseridSET NULL
AuditLoguser_idCustomUseridSET NULL
ProjectShareproject_idProjectidCASCADE
ProjectShareshared_with_idCustomUseridCASCADE
ProjectShareshared_by_idCustomUseridSET NULL

Relationships Summary

  • CustomUser to Profile: One-to-one. Each user has at most one profile.
  • CustomUser to Project: One-to-many. A user can own multiple projects.
  • Project to CanvasNode: One-to-many. A project contains multiple nodes on its canvas.
  • Project to CanvasEdge: One-to-many. A project contains multiple edges connecting its nodes.
  • CanvasNode to CanvasEdge: One-to-many (as source or target). A node can be the source or target of multiple edges.
  • Project to GraphExecution: One-to-many. A project can have multiple execution records.
  • CustomUser to GraphExecution: One-to-many. A user can initiate multiple executions.
  • CustomUser to AuditLog: One-to-many. A user's actions generate multiple audit log entries.
  • Project to ProjectShare: One-to-many. A project can be shared with multiple users.
  • CustomUser to ProjectShare: One-to-many (as shared_with or shared_by). A user can receive and grant multiple project shares.
  • ServiceEndpoint: Standalone. No foreign key relationships. Represents external gRPC service infrastructure.
  • SystemSettings: Standalone singleton. No foreign key relationships. Stores global configuration.