Database Schema

Storage collection structure, document fields, and data retention policies

Overview

ViriSIM storage data is organized by user ID for efficient access and security. Below is the complete schema for some collections used in the application.

Document ID Pattern: Most collections use the user's UID as the document ID or a composite ID combining identifiers.

apiKeys

Collection

Stores API key metadata for authentication.

Security Note: Full API keys are never stored. In some cases, only salted hashes (bcrypt) are persisted for verification.

๐Ÿ“‹ Fields

FieldTypeRequiredDescription
keyHash string Required Bcrypt hash of the API key (full key never stored)
name string Required Descriptive name for the key (e.g., "Production API")
userId string Required User's UID
created timestamp Required Creation timestamp
lastUsed timestamp Optional Last time the key was used
isActive boolean Optional Whether the key is active (default: false)
permissions array Optional Array of permissions (e.g., ["read", "write"])
updatedAt timestamp Optional Last update timestamp

allTime

Collection

Stores user-level aggregations, token balances, and analytics data.

Document ID Format: User's UID.

๐Ÿ“‹ Fields

FieldTypeDescription
totalTokensPurchasednumberTotal tokens purchased over time
totalTokensUsednumberTotal tokens used in API calls
totalTokensLeftnumberRemaining token balance
totalAmountSpentnumberTotal amount spent in USD
totalAmountSavednumberTotal amount saved from discounts
totalApiCallsnumberTotal API calls made
activeStatusstring"Yes" or "No" โ€” API monitoring status
analysisDataobjectMonthly compliance analytics (see structure below)
lastUpdatedtimestampLast update timestamp

๐Ÿ“ˆ analysisData Structure

{
  "2025": {
    "jan": { totalEntries: 0, nonCompliant: 0, fullyCompliant: 0, reviewNeeded: 0, riskScore: 0 },
    "feb": { ... },
    // ... months mar through dec
  },
  "2026": { ... }
}

IOLogs

Collection

Parent collection for all audit logs. Contains two subcollections: logs and logs_full.

Document ID Format: User's UID.

๐Ÿ“‹ Fields (Parent Document)

FieldTypeDescription
userIdstringUser's UID
lastUpdatedtimestampLast update timestamp

IOLogs โ†’ logs

Subcollection

Stores lightweight log entries for quick display in the dashboard table view.

Document ID Format: VIRI-{timestamp}{random} (e.g., VIRI-0001234Xabcde)

๐Ÿ“‹ Fields

FieldTypeDescription
userIdstringUser's UID
apiKeyHASHstringRedacted API key (first 16 chars + "...")
timestampstringISO timestamp of the audit
tableHighlightobjectPreview data for dashboard table
searchableTermsarrayArray of searchable keywords for filtering

๐Ÿ“Š tableHighlight Structure

{
  logId: "VIRI-0001234Xabcde",
  company: "Example Corp",
  model: "ViriSIM-v102",
  inputPreview: "User input text...",
  outputPreview: "AI output text...",
  compliance: "Fully compliant",  // or "Review needed", "Non-compliant"
  riskScore: 2.5,
  useCase: "Customer Support",
  tier: "Professional",
  storageValue: 0.000016
}

IOLogs โ†’ logs_full

Subcollection

Stores complete audit data including compliance analysis, remediation steps, and fine-tuning data.

Document ID Format: Same as logs (e.g., VIRI-0001234Xabcde)

๐Ÿ“‹ Main Fields

FieldTypeDescription
userIdstringUser's UID
apiKeyHASHstringRedacted API key
timestampstringISO timestamp
metaobjectMetadata (companyUserId, sessionId, tokens, etc.)
userInputobjectUser input analysis (complianceScore, violations, safeInput)
aiOutputobjectAI output analysis (fairnessScore, bias, safeOutput)
verdictobjectFinal verdict (complianceStatus, riskScore, actionPlan)
regulatoryComplianceDetailsobjectPrimary/secondary regulations violated
remediationarrayRemediation steps
fineTuningobjectFine-tuning training data
integrityobjectSHA-256 hash for audit integrity
authorizationChainobjectAuthorization verification data
retentionobjectData retention policy metadata
storageValuenumberStorage size in MB for this log
tierstringUser's subscription tier

userStorage

Collection

Tracks storage usage per user for audit logs.

Document ID Format: User's UID.
FieldTypeDescription
userIdstringUser's UID
storageUsednumberStorage used in MB
storageLimitnumberStorage limit in MB (default: 1000 MB / 1 GB)
lastUpdatedtimestampLast update timestamp
createdAttimestampCreation timestamp

account

Collection

Stores user profile and settings.

Document ID Format: User's UID.
FieldTypeDescription
adminNamestringUser's full name
companyNamestringCompany name
emailstringUser's email address
phonestringPhone number
profileImagestringURL to profile image
sectorstringIndustry sector
countrystringCountry
privacySecurityobjectPrivacy and security settings
languageRegionobjectLanguage and region preferences
notificationsobjectNotification preferences
timeTracknumberTimestamp tracking
createdAttimestampAccount creation timestamp
updatedAttimestampLast update timestamp

paymentsHistory

Collection โ†’ Subcollection

Stores payment transactions. Organized as a subcollection under each user.

Document ID Format: Payment reference ID (from Paystack/Flutterwave).
FieldTypeDescription
planstringPlan name (Free, Pro, Professional, Enterprise, Custom)
tokensnumberNumber of tokens purchased
finalTotalnumberAmount paid
savednumberAmount saved from discounts
realRatenumberCurrency conversion rate used
statusstringPayment status (completed, pending)
userIdstringUser's UID
createdAttimestampPayment timestamp
completedAttimestampCompletion timestamp

fineTuning

Collection โ†’ Subcollections

Manages fine-tuning jobs and automation schedules.

๐Ÿ“‹ Subcollections

  • summary โ†’ main โ€” Aggregated stats about all fine-tuning jobs
  • jobs โ†’ Individual fine-tuning job documents
Document ID Format: User's UID for parent, custom IDs for jobs.

certifications

Collection โ†’ Subcollection

Stores yearly compliance certifications for users.

Document ID Format: User's UID โ†’ yearlyCerts โ†’ {year}
FieldTypeDescription
totallogsCertsnumberTotal logs audited this year
totalTokensUsednumberTotal tokens used this year
fullyCompliantnumberCount of fully compliant audits
nonCompliantnumberCount of non-compliant audits
needsReviewnumberCount of audits needing review
cumulativeRiskScorenumberAverage risk score for the year (0-10 scale)
compliantRatenumberPercentage of compliant audits
certNumberstringCertificate number
certTypestringCertificate type (e.g., "ViriSIM-v102-4001:2025")
companyNamestringCompany name for the certificate

automationConfigs

Collection

Stores integration configurations for Slack, Teams, Jira, Zapier, Google Analytics and Google Sheets.

Document ID Format: User's UID.

๐Ÿ“‹ Config Objects

  • slackAutomation โ€” Webhook URL, alert triggers, channel name
  • teamsAutomation โ€” Webhook URL, alert triggers, channel name
  • jiraAutomation โ€” Jira URL, email, API token, project key, risk threshold
  • zapierAutomation โ€” Zapier webhook URLs for various events
  • googleAnalyticsAutomation โ€” Measurement ID (G-XXXXXXXX), API secret, event parameters, custom dimensions
  • sheetsAutomation โ€” Google OAuth tokens, spreadsheet ID, sheet name
  • customAutomation โ€” Custom webhook URL, headers, alert triggers

Data Retention Policy

ViriSIM follows a 7-year log retention policy to comply with EU AI Act Article 12 requirements for high-risk AI systems.

{
  policy: "Logs: 7 years | Training data: 90 days | Extended retention: Customer responsibility via export, download, or third-party archival",
  logRetentionExpiry: "YYYY-MM-DD",  // 7 years from log creation
  trainingDataExpiry: "YYYY-MM-DD", // 90 days from log creation
  basis: "EU AI Act Article 12 - minimum 6 month retention for high-risk AI system logs"
}
Note: Training data used for fine-tuning is retained for 90 days only. For longer retention, customers must export, download, or archive using third-party solutions.
Access Control:
  • Admin Access: Full access to all logs and settings
  • Shared Access: Admins can share specific logs with selected individuals (view-only)
  • Regulator Access: Extended access with detailed audit data and export/download capabilities (view-only, time-limited)

Ready to Start Auditing?

Go to ViriSIM, get your API key and run your first compliance audit in under 30 minutes.

Go to ViriSIM