MokshAi A spiritual AI companion

Spiritual AI Companion: A Mobile Application for Spiritual and Philosophical Guidance

Technologies Used

  • Frontend:

    • Built with React Native v0.75.4 for seamless cross-platform performance.

    • MobX powers intuitive state management.

    • TypeScript ensures reliability and smooth development.

    • Firebase Authentication for secure and flexible sign-ins.

    • React Navigation enables a streamlined, intuitive experience.

    • Tailwind CSS for adaptive, visually appealing styling.

  • Backend:

    • Firebase Cloud Functions ensure responsive, serverless support.

    • Firestore for real-time data storage.

    • Integrated with OpenAI's API (GPT-4) for AI-driven guidance.

    • Node.js to create a robust runtime environment.

  • Payment Integration:

    • RevenueCat provides seamless subscription and purchase tracking.

    • Webhook integration ensures real-time purchase verifications.

    • Token-based usage tracking for transparent usage insights.

Infrastructure Highlights

Authentication System

  • Integrated multi-provider authentication with Firebase Auth:

    • Google Sign-In (Android) and Apple Sign-In (iOS) for universal access.

    • Persistent authentication managed with MobX stores for a smooth experience.

    • Ensured secure token handling and session management.

    • Custom context provider supports seamless authentication across sessions.

State Management Architecture

  • Powered by MobX with customized stores for smooth data flow:

    • AuthStore manages login status and user data.

    • UserStore controls preferences and data unique to each user.

    • Store hydration enables data persistence across app launches.

  • Built on observable patterns, the app adapts to every user interaction.

Database Structure

  • Firestore Collections:

    • users: Maintains user profiles and usage.

    • messages: Stores conversation history.

    • threads: Manages chat threads for smooth context continuation.

    • subscriptions: Tracks subscription details.

    • credits: Supports the token-based credit system.

Subscription and Payment Management

  1. RevenueCat Integration: Handles in-app purchases and subscriptions.

  2. Token-Based System:

    • Offers flexible plans:

      • Weekly: 50 tokens

      • Monthly: 150 tokens

      • Yearly: 800 tokens

    • One-time purchases: 20 or 50 tokens for quick access.

  3. Webhook Processing:

    • Validates purchases in real-time, manages renewals, and allocates tokens based on subscription type.

App Features and AI Integration

Multi-Philosophy AI Assistants

  1. Specialized Spiritual Assistants:

    • Buddhist Philosophy, Indian Mythology, Greek Mythology, Arabic Scriptures, and Japanese Philosophy.

  2. Contextual Conversation Management:

    • Thread-based, ensuring every chat preserves its flow and meaning.

    • Tone customization to align with the user's emotional needs.

OpenAI Integration

  1. Responsive AI Stream

  2. Intelligent Event Handling:

    • Real-time progress, usage tracking, and retry mechanisms ensure a smooth experience.

User Experience Features

  1. Chat Interface:

    • Real-time typing indicators and detailed message history.

    • Customizable tones to suit each user’s needs and moods.

    • Organized thread navigation for easy access to ongoing conversations.

  2. Token Management UI:

    • At-a-glance usage tracking, subscription updates, and token purchase options.

Enhanced Functionality

  1. Intuitive Usage Tracking:

  2. Seamless Thread Management:

    • Automatic thread creation, real-time updates, and context retention make chats effortless.

Performance Enhancements

  1. Data Efficiency:

    • Efficient Firestore indexing and batch updates streamline data handling.

    • Optimistic UI updates ensure smooth transitions.

    • Smart caching reduces redundant requests.

  2. Resource Management:

    • A token-based quota keeps users informed about usage.

    • Batch processing optimizes database interactions.

Payment Processing and Subscription Lifecycle

RevenueCat Integration

  1. Webhook Handlers:

    • Processes purchase events, validates transactions, updates subscriptions, and manages renewals.

  2. Token Allocation System

  3. Subscription Lifecycle:

    • Supports renewals, adjustments, and both subscription and one-time purchases, with real-time entitlement management.

  4. Usage Tracking:

    • Token counting, subscription verification, and limit enforcement.

Conclusion

This Spiritual AI Companion offers an inspiring blend of spiritual insight and modern technology, providing users with a unique, thoughtful experience. With features like multi-philosophy AI assistants, real-time streaming, and secure payment management, this app is poised to become a vital tool for anyone seeking guidance through ancient wisdom in a modern world.

Key highlights include:

  • Real-time streaming with OpenAI’s API for responsive assistance.

  • Comprehensive subscription and token-based system for flexible use.

  • Rich multi-philosophy AI guidance covering a spectrum of wisdom traditions.

  • Scalable Firebase infrastructure supporting seamless performance.

This app delivers more than just conversation—it brings wisdom to life with a blend of technical precision and human-centered design, all in the spirit of helping users find clarity, purpose, and peace.