Database Schema

Last Updated: February 25, 2026


Overview

Herald uses Cloud Firestore as its primary database. Firestore is a NoSQL document database that provides real-time synchronization, offline support, and automatic scaling.

Why Firestore?


Collections Structure

Firestore Database
├── users/                    # User profiles and account data
│   ├── {uid}/
│   │   ├── firstName
│   │   ├── middleName
│   │   ├── lastName
│   │   ├── email
│   │   ├── positions
│   │   ├── mustChangePassword
│   │   ├── emailVerified
│   │   ├── disabled
│   │   ├── createdAt
│   │   ├── createdBy
│   │   └── lastLoginAt
│
├── positions/                # Organizational positions with permissions
│   ├── {positionId}/
│   │   ├── name
│   │   ├── abbreviation
│   │   ├── description
│   │   ├── permissions
│   │   ├── createdAt
│   │   └── updatedAt
│
└── auditLogs/                # Admin action audit trail
    ├── {logId}/
    │   ├── action
    │   ├── performedBy
    │   ├── targetUser
    │   ├── timestamp
    │   └── details

Collection: users

Purpose: Store user profiles, account settings, and metadata

Document ID: Firebase Auth UID (auto-generated by Firebase)

Schema

Field Type Required Description
firstName string ✅ Yes User's first name
middleName string ❌ No User's middle name (optional)
lastName string ✅ Yes User's last name
email string ✅ Yes User's email address (synced with Firebase Auth)
positions string[] ✅ Yes Reference to document ID in positions collection
mustChangePassword boolean ✅ Yes Flag to force password change on next login (default: true for new users)
emailVerified boolean ✅ Yes Whether email has been verified (synced from Firebase Auth)
disabled boolean ✅ Yes Whether account is disabled (default: false)
createdAt timestamp ✅ Yes Account creation timestamp (server timestamp)
createdBy string ✅ Yes UID of admin who created this user ("system" for self-signup if enabled)
lastLoginAt timestamp ❌ No Last successful login timestamp (updated on login)