ποΈ Database Structure
Hey, Inner Journey architects! This document outlines the blueprint for how Inner Journey stores and manages data within Firestore. Our goal is a secure, scalable, and efficient structure to power a platform dedicated to personal growth and self-development. This foundation supports everything from user profiles and personalized insights to coach-led programs and financial tracking. Be proud β youβre crafting the core of something truly transformative! π
π― Purpose & Overviewβ
Our Firestore database is meticulously designed to enable Inner Journeyβs core functionalities:
- π€ Personal Profiling: Securely stores user data including birth details for astrology/numerology calculations and preferences for tailored personal growth insights.
- βοΈ Dynamic Journal: Captures user reflections (text, audio, video) as an integral part of their self-development journey.
- πͺ Activations and Programs: Manages coach-created activities ("activations") and structured personal growth programs.
- π€ Coach Interactions: Facilitates interactions between coaches and users, including assigning activations and monitoring progress on their journey.
- πΈ Payments and Payouts: Reliably tracks customer payments for premium features/programs and ensures accurate coach payouts for financial transparency and financial management.
π Note: We leverage Firestore for its scalability and real-time capabilities. An in-memory fallback (
call_status) might be used temporarily during development phases but the goal is full Firestore implementation.
ποΈ Collections Overviewβ
Hereβs a visual representation of how our data is organized in Firestore:
π€ Collection: usersβ
Description: Stores individual user profiles, preferences, and calculated data for personalization and AI-driven insights.
Document ID: Userβs unique Firebase Authentication UID (e.g., "firebase-uid-123").
Fields:
userId:Stringβ Unique user identifier (matches Auth UID).birthDate:Stringβ User's birth date in ISO 8601 format (e.g.,"1990-05-15"). Necessary for astrological calculations.birthTime:Stringβ User's birth time (e.g.,"14:30"). Optional but enhances astrological precision.birthLocation:Stringβ User's birth location (e.g.,"Stockholm, Sweden"). Used for astrological chart generation.phoneNumber:Stringβ Verified phone number (e.g.,"+46701234567"). Used for authentication or communication.createdAt:Timestampβ Timestamp indicating when the user profile was created.uiStyle:Stringβ User's preferred UI theme (e.g.,"clean","professional","calm").focusArea:Stringβ Primary goal selected during onboarding (e.g.,"stress_relief","career_growth"). Guides initial personal development path.timeCommitment:Numberβ Preferred daily time commitment in minutes (e.g.,15). Helps tailor program suggestions.personalityType:Objectβ Stores personality assessment results:traits:Arrayβ Key personality traits (e.g.,["introvert", "intuitive", "thinker"]).astroSign:Stringβ Calculated sun sign (e.g.,"Taurus").lifePathNumber:Numberβ Calculated numerology life path number (e.g.,7).
neuroTendencies:Objectβ Self-reported or assessed neurodiversity indicators (used sensitively):adhdScore:Numberβ Indicator score (0-10 scale, e.g.,3).autismScore:Numberβ Indicator score (0-10 scale, e.g.,2).
wellbeingFlags:Objectβ Automatically flagged potential wellbeing concerns based on user input (requires careful handling):depressionRisk:Booleanβ Flag based on screening question answers.suicideRisk:Booleanβ Flag based on screening question answers (requires immediate protocol if true).
answers:Arrayβ Raw answers from onboarding questionnaires (e.g.,[{"questionId": "q1", "answer": "Draining"}]).
π‘ Flexibility: Consider adding fields like moonSign, risingSign, progressLevel, preferredPronouns.
πͺ Collection: activationsβ
Description: Contains predefined or coach-created activities designed for user engagement and growth (e.g., meditations, journaling prompts, physical exercises).
Document ID: Unique activation identifier (e.g., "hemisync_meditation_001").
Fields:
activationId:Stringβ Unique ID for this activation (matches Document ID).title:Stringβ Clear and engaging title (e.g.,"10-Minute Morning Awareness Meditation").type:Stringβ The format of the activation (e.g.,"audio","video","text_prompt","live_interaction","physical_exercise").description:Stringβ A brief explanation of the activation and its purpose (e.g.,"A guided audio meditation using binaural beats to enhance focus.").duration:Numberβ Estimated duration in minutes (e.g.,10).mediaUrl:Stringβ Link to media file inFirebase Storage(if applicable, e.g., for audio/video types). Can benull.category:Stringβ Helps categorize activations (e.g.,"mindfulness","stress_reduction","creativity","emotional_intelligence").createdBy:Stringβ UID of the coach or admin who created the activation (e.g.,"coach_uid_123"). Links to theuserscollection.
π‘ Flexibility: Add fields like difficultyLevel (beginner, intermediate, advanced), requiredEquipment (Array<String>), tags (Array<String>).
π Collection: user_activationsβ
Description: Tracks a user's engagement and progress with specific activations. This forms the core of the Dynamic Journal and personalized journey tracking.
Document ID: Composite ID, typically userId_activationId_timestamp or a unique UUID (e.g., "firebase-uid-123_hemisync-001_1678886400" or generated UUID).
Fields:
userActivationId:Stringβ Unique ID for this specific instance of a user doing an activation.userId:Stringβ Links to theuserscollection.activationId:Stringβ Links to theactivationscollection.programId:String(Nullable) β Links to theprogramscollection if this activation was completed as part of a specific program.assignedBy:String(Nullable) β Coach UID if assigned directly.startedAt:Timestampβ When the user started the activation.completedAt:Timestamp(Nullable) β When the user marked the activation as complete.status:Stringβ Current status (e.g.,"assigned","in_progress","completed","skipped").log:Objectβ User's reflection data (Dynamic Journal entry):text:Stringβ Written reflection or notes (e.g.,"Felt surprisingly calm and focused afterward.").audioUrl:String(Nullable) β Link to a recorded audio reflection inFirebase Storage.videoUrl:String(Nullable) β Link to a recorded video reflection inFirebase Storage.moodBefore:String(Nullable) β User-reported mood before starting (e.g.,"stressed").moodAfter:String(Nullable) β User-reported mood after completing (e.g.,"calm").rating:Number(Nullable) β User rating of the activation (e.g., 1-5 stars).aiAnalysis:Object(Nullable) β Results from AI analysis of the reflection (e.g.,{ "sentimentScore": 0.8, "keyThemes": ["calm", "focus"] }).
sessionId:String(Nullable) β Links tolive_sessionsif completed during a live session.
π‘ Flexibility: Add feedbackForCoach, privateNote.
π₯ Collection: live_sessionsβ
Description: Manages real-time, scheduled group or one-on-one interactions, often involving specific activations or programs.
Document ID: Unique session identifier (e.g., "live_session_xyz789").
Fields:
liveSessionId:Stringβ Unique ID for this live session.title:Stringβ Name of the live session (e.g.,"Weekly Group Check-in").activationId:String(Nullable) β Links to anactivationsif the session revolves around one (e.g., a live guided meditation).programId:String(Nullable) β Links toprogramsif the session is part of a program schedule.coachId:Stringβ UID of the hosting coach. Links tousers.participants:Arrayβ List ofuserIds participating in the session.startTime:Timestampβ Scheduled start time and date.endTime:Timestampβ Scheduled end time and date.status:Stringβ Current status (e.g.,"scheduled","live","completed","cancelled").meetingUrl:String(Nullable) β Link to the video conferencing platform.reflections:Arrayβ Post-session reflections (can referenceuser_activationsor store simple text):userId:Stringβ User submitting the reflection.text:Stringβ Brief reflection text (e.g.,"Great energy in the group today.").submittedAt:Timestamp.
π‘ Flexibility: Add sessionRecordingUrl, maxParticipants.
β
Collection: consentsβ
Description: Records user consent for GDPR compliance, terms of service, and privacy policies, ensuring traceability.
Document ID: Userβs UID (userId).
Fields:
userId:Stringβ Links back to theuserscollection (matches Document ID).consentsGiven:Arrayβ List of specific consents granted:type:Stringβ Type of consent (e.g.,"terms_of_service","privacy_policy","data_processing","marketing_emails").version:Stringβ Version of the document consented to (e.g.,"v1.1").agreedAt:Timestampβ Timestamp when this specific consent was given.status:Stringβ"granted"or"revoked".
π‘ Flexibility: Store IP address or user agent at time of consent for extra verification if required by regulations.
π Collection: sessions (Temporary/Legacy)β
Description: Intended to manage temporary session data, potentially replacing an older in-memory call_status system during transitions or for specific short-lived state needs (e.g., phone verification codes). Note: Evaluate if this is still necessary or if state can be managed differently (e.g., within users document or client-side).
Document ID: Unique sessionId (e.g., "temp_session_abc123").
Fields:
sessionId:Stringβ Unique session ID.userId:Stringβ Links tousers.type:Stringβ Type of session (e.g.,"phone_verification","password_reset").data:Objectβ Session-specific data (e.g.,{"verificationCode": "123456", "expiresAt": Timestamp}).createdAt:Timestampβ When the session was created.
π‘ Best Practice: Minimize reliance on separate temporary session collections in Firestore; leverage client-state or user document sub-collections where possible.
π Collection: programsβ
Description: Defines structured, multi-step personal growth programs created by coaches, composed of ordered activations.
Document ID: Unique program identifier (e.g., "program_dream_to_reality_001").
Fields:
programId:Stringβ Unique ID for the program.title:Stringβ Compelling program title (e.g.,"Unlock Your Potential: A 4-Week Journey").description:Stringβ Detailed overview of the program, its goals, and target audience.durationWeeks:Numberβ Expected program length in weeks (e.g.,4).createdBy:Arrayβ List of coachuserIds who created/own the program.modules:Arrayβ Structured modules containing activations:moduleId:Stringβ Unique ID for the module (e.g.,"week1").title:Stringβ Module title (e.g.,"Week 1: Foundation & Awareness").activations:Arrayβ Ordered list of activations within the module:activationId:Stringβ Links toactivations.day:Numberβ Recommended day within the module/week to perform (e.g.,1).isOptional:Booleanβ Whether the activation is mandatory.
difficulty:Stringβ Program difficulty level (e.g.,"beginner","intermediate","advanced").category:Stringβ Primary category (e.g.,"career_development","wellbeing","relationships").tags:Array<String>β Keywords for searchability (e.g.,["mindfulness", "goal-setting", "resilience"]).price:Number(Nullable) β Price if it's a premium program (e.g.,499).currency:String(Nullable) β Currency for the price (e.g.,"SEK").
π‘ Flexibility: Add prerequisites (e.g., required prior program), enrollmentCount, averageRating.
π³ Collection: paymentsβ
Description: Logs customer transactions related to subscriptions, program purchases, or other premium features, crucial for financial tracking.
Document ID: Unique payment identifier (often generated by the payment processor or system, e.g., "pay_123abc").
Fields:
paymentId:Stringβ Unique ID for this payment record.userId:Stringβ Links to theuserscollection (the customer).amount:Numberβ Payment amount in the smallest currency unit (e.g.,49900for 499.00 SEK).currency:Stringβ Currency code (e.g.,"SEK","USD").paymentDate:Timestampβ Timestamp when the payment was processed.status:Stringβ Payment status (e.g.,"succeeded","pending","failed","refunded").processor:Stringβ Payment processor used (e.g.,"stripe","paypal").processorPaymentId:Stringβ The transaction ID from the payment processor (e.g., Stripe'spi_...orcs_...).description:Stringβ Description of what was purchased (e.g.,"Subscription renewal","Enrollment in Program X").programId:String(Nullable) β Links toprogramsif the payment was for a specific program.subscriptionId:String(Nullable) β Links to a subscription record if part of a recurring payment.
π‘ Flexibility: Add invoiceUrl, refundDetails (object).
πΈ Collection: payoutsβ
Description: Tracks payouts made to coaches for their contributions (e.g., program sales commissions, live session fees). Essential for coach financial management.
Document ID: Unique payout identifier (e.g., "payout_xyz789").
Fields:
payoutId:Stringβ Unique ID for this payout record.coachId:Stringβ Links to theuserscollection (the coach receiving the payout).amount:Numberβ Payout amount in the smallest currency unit (e.g.,40000for 400.00 SEK).currency:Stringβ Currency code (e.g.,"SEK","USD").payoutDate:Timestampβ Timestamp when the payout was initiated or completed.status:Stringβ Payout status (e.g.,"pending","processing","completed","failed").processor:Stringβ Payout processor used (e.g.,"stripe_connect","paypal","bank_transfer").processorPayoutId:String(Nullable) β The transaction ID from the payout processor.fortnoxReference:String(Nullable) β Reference ID for accounting systems like Fortnox after synchronization.relatedPaymentIds:Array<String>(Nullable) β Links topaymentsthat contributed to this payout amount.
π‘ Flexibility: Add payoutMethodDetails (e.g., last 4 digits of bank account), calculationPeriod (start/end dates).
βοΈ Data Usage Examplesβ
- π± Onboarding: Data from
users(birth info, goals) drives initial personalization.consentsensures compliance from the start. - πͺ Personal Journeys:
programsdefine structured paths.user_activationslogs every step, reflection, and insight, forming the core personal growth record. - βοΈ Dynamic Journal: The
logobject withinuser_activationsis the Dynamic Journal, capturing text, audio, video, and potentially AI-analyzed insights. - π€ Coach Interactions: Coaches create
activationsandprograms. They monitor progress viauser_activationsand interact inlive_sessions. - πΈ Financial Management:
paymentstracks incoming revenue from users.payoutsensures coaches are compensated correctly based on their contributions.
π‘οΈ Security & GDPR Complianceβ
- π Encryption: Firestore encrypts data at rest by default. All data transmission uses HTTPS.
- π Access Control: Firestore Security Rules are critical. They must enforce that:
- Users can only read/write their own data (
users,user_activations,consents). - Coaches can read data of users they are assigned to or participants in their programs/sessions, but cannot modify sensitive user base data.
- Coaches can manage the
activationsandprogramsthey create. - Admin roles have broader access for maintenance and support.
- Users can only read/write their own data (
- π GDPR:
- Consent is explicitly tracked in the
consentscollection. - Data Subject Access Requests (DSARs) can be fulfilled by querying data linked by
userId. - Data deletion requests require removing the
usersdocument and associated documents in other collections (e.g.,user_activations,consents, potentially anonymizinglive_sessionparticipation). Define clear data retention policies (e.g., logs deleted after 90 days unless actively part of user record).
- Consent is explicitly tracked in the
Refer to a dedicated Security Principles document for detailed Firestore rules examples.
Letβs continue building a robust and secure database that truly empowers the Inner Journey experience β your meticulous work here is fundamental! π