Overview
Arre uses Cloud Firestore as its primary database. Data is organized by user, with each user having their own sub-collections for tasks, projects, and integrations.Data Structure
The database follows a hierarchical structure with user isolation:All user data is isolated under
/users/{userId} to ensure proper access control via security rules.Collections
Tasks Collection
The tasks collection stores all user task data with status tracking, scheduling, and project associations.TaskDocument Interface
Defined insrc/lib/types/firestore.ts:
src/lib/types/firestore.ts
Field Details
Unique document identifier. Matches the Firestore document ID.
Task title. Must be non-empty string (validated by security rules).
Additional task description or notes. Supports markdown formatting in the UI.
Current task status. Must be one of:
'todo', 'completed', 'canceled', 'someday'Scheduled date in
YYYY-MM-DD format. Used for daily planning and filtering.Marks task for “This Evening” planning feature. Used in conjunction with
date.Estimated energy level required for the task. Used for smart scheduling.
Array of tag strings for categorization. Frontend suggests common tags.
Foreign key reference to a project document ID. Must exist in user’s projects collection.
Firestore server timestamp set on document creation.
Timestamp when task status changed to
'completed'. Used for analytics.Firestore server timestamp updated on every document modification.
TaskStatus Type
src/shared/types/task.ts
Projects Collection
Projects organize tasks into categories with visual color coding.ProjectDocument Interface
src/lib/types/firestore.ts
Field Details
Unique project identifier matching the Firestore document ID.
Project name. Must be non-empty (validated by security rules).
Color identifier. Can be a hex code (
#10b981) or color name from the predefined palette.Numeric ordering for display. Lower numbers appear first in the UI.
Available Project Colors
src/shared/types/task.ts
Integrations Collection
Stores OAuth tokens and configuration for third-party integrations (e.g., Google Tasks).Timestamp Handling
Firestore Timestamps vs. ISO Strings
Arre uses different timestamp formats depending on the context:- Firestore (Database)
- Application (Client)
Uses Firestore
Timestamp objects for precise datetime storage:Converting Between Formats
Always use
serverTimestamp() when writing timestamps to Firestore to ensure consistency across different client time zones.Query Examples
Fetch User’s Tasks
Create a New Task
Update Task Status
Best Practices
Use Server Timestamps
Always use
serverTimestamp() for createdAt and updatedAt fields to avoid client clock skew.Validate Before Writing
Ensure all required fields are present before writing to Firestore. Security rules will reject invalid documents.
Handle Subcollection References
When referencing projects via
projectId, verify the project exists in the user’s projects collection.Next Steps
Cloud Functions
Learn how functions interact with Firestore
Security Rules
Understand how schema is enforced