Skip to content

Database

Postgres via SQLAlchemy. Models live in src/db/models.py. Connection from DATABASE_URL or DB_* pieces (src/db/config.py).

Tables

users

App profile and automation summary. No portal password here.

Notable columns Purpose
user_id Public UUID string (not the DB PK)
email Unique
needs_password Skip Sunday runs until credentials are updated
last_timecard_check_at / _signoff_at / _check_status Last attempt summary
Counters auto_signed_off_count, already_signed_off_count, failed_login_count

credentials

Encrypted portal login (one site label: timecard_portal).

Column Contents
enc_username / nonce_username AES-GCM ciphertext + nonce
enc_password / nonce_password AES-GCM ciphertext + nonce
dek_wrapped KMS-wrapped data key
kms_key_id Customer key id/ARN used
dek_version Starts at 1; increments on each save
last_success_at Last successful portal use

Cascade: deleting a User removes related credentials (cascade="all, delete-orphan").

Hashed tokens for enrollment and deletion (MagicLinkType).

timecard_runs

One row per automation attempt: status, login/sign-off flags, optional error_reason, and credential_dek_version for mid-run password-change detection.

Status enum

login_success_signed_off
login_success_already_signed
login_failed_bad_credentials
login_failed_site_error
login_failed_unknown_error
Signoff archive • Material for MkDocs