Firestore Schema Documentation
This document provides a comprehensive reference for all Firestore collections, their paths, types, and field descriptions.
Note: This is generated from the schema file. For the source of truth, see
src/schema/firestoreSchema.ts
Table of Contents
Root Collections
orgsPub - Public Organizations
Path: orgsPub/{orgId}
Type: OrganizationPublic
Description: Public-facing organization data visible to all users
Subcollections:
vacancies- Public job postingsdocs- Public documentsmembers- Public member list
orgs - Private Organizations
Path: orgs/{orgId}
Type: OrganizationPrivate
Description: Private organization data accessible only to members
See Organization Subcollections below.
usersPub - Public Users
Path: usersPub/{userId}
Type: User
Description: Public user profile data
Subcollections:
orgMemberships- Organizations the user is a member of
users - Private Users
Path: users/{userId}
Type: User
Description: Private user data (admin only)
contracts - Contracts
Path: contracts/{contractId}
Type: Contract
Description: Global contract templates
Organization Subcollections
All subcollections are under orgs/{orgId}/
Members
Path: orgs/{orgId}/members/{userId}
Type: Member
Fields:
userId(string) - User IDrole(string) - Member role (admin, member, etc.)addedAt(Date | Timestamp) - When member joinedposition(string?) - Job position/titleisMember(boolean?) - Active member flagmeetingCount(number?) - Total meetings attendedattendanceRate(number?) - Attendance percentage (0-100)lastAttendanceCalculatedAt(Date | Timestamp?) - Last attendance calculation
Tasks
Path: orgs/{orgId}/tasks/{taskId}
Type: Task
Subcollections:
votes- User votes on tasks
Meetings
Path: orgs/{orgId}/meetings/{meetingId}
Type: Meeting
Subcollections:
attendance- Meeting attendance records
Daily Meetings
Path: orgs/{orgId}/dailyMeetings/{meetingId}
Type: DailyMeeting
Visitors
Path: orgs/{orgId}/visitors/{userId}
Type: Visitor
Subcollections:
messages- Messages from visitors
Warnings
Path: orgs/{orgId}/warnings/{warningId}
Type: Warning
Teams
Path: orgs/{orgId}/teams/{teamId}
Type: Team
Achievements
Path: orgs/{orgId}/achievements/{achievementId}
Type: Achievement
Fields:
id(string?) - Achievement IDorgId(string) - Organization IDuserId(string) - User who earned achievementuserName(string) - User display nameuserPhotoURL(string?) - User photo URLtitle(string) - Achievement titledescription(string) - Achievement descriptionimageUrls(string[]?) - Achievement imagesvideoUrl(string?) - Achievement videocategory(AchievementCategory) - Category typecreatedAt(Date | Timestamp) - Creation dateupdatedAt(Date | Timestamp) - Last updatevotesCount(number) - Number of votesstatus(AchievementStatus) - 'pending' | 'approved' | 'rejected'
Achievement Votes
Path: orgs/{orgId}/achievement-votes/{voteId}
Type: AchievementVote
Nomination Periods
Path: orgs/{orgId}/nomination-periods/{periodId}
Type: NominationPeriod
Nomination Votes
Path: orgs/{orgId}/nomination-votes/{voteId}
Type: NominationVote
Contract Signatures
Path: orgs/{orgId}/contract-signatures/{userId}
Type: ContractSignature
Applications
Path: orgs/{orgId}/applications/{applicationId}
Type: Application
Commitments
Path: orgs/{orgId}/commitments/{commitmentId}
Type: WeeklyCommitment
Fields:
id(string?) - Commitment IDorgId(string) - Organization IDuserId(string) - User who made commitmentteamId(string?) - Team ID if team-specificweekStartDate(Date | Timestamp) - Monday of the week (ISO week)title(string) - What they commit to dodescription(string?) - Optional detailsconfidenceScore(number?) - 0-100 confidence levelproject(string?) - Related project/prioritycreatedAt(Date | Timestamp) - Creation dateupdatedAt(Date | Timestamp) - Last updatestatus(CommitmentStatus?) - 'pending' | 'done' | 'not-done' | 'partial'checkInDate(Date | Timestamp?) - When checked inreason(string?) - Reason if not donenextAction(string?) - Next action if not doneevidenceLink(string?) - Link to PR, doc, etc.notes(string?) - Additional notes
Time Off
Path: orgs/{orgId}/time-off/{timeOffId}
Type: TimeOff
Fields:
id(string?) - Time off IDuserId(string) - User IDuserName(string) - User display nameorgId(string) - Organization IDweekStartDate(Date | Timestamp) - Monday of the weekweekEndDate(Date | Timestamp) - Sunday of the weekreason(string?) - Reason for time offcreatedAt(Date | Timestamp) - Creation datecreatedBy(string) - User ID who created
Scores
Path: orgs/{orgId}/scores/{userId}
Type: ScoreBreakdown
Fields:
meetingsAttended(number) - Count of meetings attendedachievementsEarned(number) - Count of approved achievementscommitmentsCompleted(number) - Count of completed commitmentsmeetingPoints(number) - Points from meetings (meetingsAttended * 1)achievementsPoints(number) - Points from achievements (achievementsEarned * 10)commitmentPoints(number) - Points from commitments (commitmentsCompleted * 5)totalScore(number) - Total score (sum of all points)lastCalculatedAt(Date | Timestamp) - Last calculation time
Scoring Rules:
- Each meeting attended: 1 point
- Each approved achievement: 10 points
- Each completed commitment (status='done'): 5 points
Attendance
Path: orgs/{orgId}/attendance/{userId}
Type: AttendanceStats
Fields:
totalMeetings(number) - Total meetings in organizationmeetingsAttended(number) - Meetings member attendedattendanceRate(number) - Attendance percentage (0-100)lastCalculatedAt(Date | Timestamp) - Last calculation time
Note: This is calculated hourly by the hourlyTasks cloud function.
Activity Logs
Path: orgs/{orgId}/activityLogs/{logId}
Type: OrgActivityLog
User Subcollections
Org Memberships
Path: usersPub/{userId}/orgMemberships/{orgId}
Type: OrgMembership
Fields:
orgId(string) - Organization IDrole(string) - User role in organizationjoinedAt(Date) - When user joined
Type Definitions
All type definitions are located in src/types/:
src/types/organization.ts- OrganizationPrivate, OrganizationPublic, OrgActivityLogsrc/types/user.ts- Usersrc/types/member.ts- Member, OrgMembershipsrc/types/achievement.ts- Achievement, AchievementVotesrc/types/nomination.ts- NominationPeriod, NominationVotesrc/types/contract.ts- Contract, ContractSignaturesrc/types/application.ts- Applicationsrc/types/commitment.ts- WeeklyCommitmentsrc/types/timeOff.ts- TimeOffsrc/types/score.ts- ScoreBreakdown, MemberScoresrc/types/attendance.ts- AttendanceStatssrc/types/task.ts- Tasksrc/types/team.ts- Teamsrc/types/warning.ts- Warningsrc/types/vacancy.ts- Vacancy
Reference Functions
All Firestore reference functions are centralized in src/services/firestoreRefs.ts.
Example usage:
import { orgScoresRef, orgScoreDocRef } from '../services/firestoreRefs';
// Get collection reference
const scoresRef = orgScoresRef(orgId);
// Get document reference
const scoreRef = orgScoreDocRef(orgId, userId);Best Practices
- Always use centralized refs - Import from
firestoreRefs.tsinstead of hardcoding paths - Keep types in sync - Update types in
src/types/when adding new fields - Update schema - Keep
firestoreSchema.tsupdated when adding collections - Document fields - Add field descriptions in the schema file
- Use TypeScript - Leverage type safety from the reference functions
Maintenance
When adding a new collection:
- Add the type definition to
src/types/ - Add reference functions to
src/services/firestoreRefs.ts - Update
src/schema/firestoreSchema.tswith path, type, and description - Update this documentation file
- Update Firestore security rules if needed