<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vedang Kulkarni</title>
    <description>The latest articles on DEV Community by Vedang Kulkarni (@kvedang).</description>
    <link>https://dev.to/kvedang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4108314%2F5f4f42c8-f90b-4184-b300-c8cca9ce1e7e.jpg</url>
      <title>DEV Community: Vedang Kulkarni</title>
      <link>https://dev.to/kvedang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kvedang"/>
    <language>en</language>
    <item>
      <title>Building Sanctuary AI: A Privacy-First AI Journal with Gemini and Google Cloud Run</title>
      <dc:creator>Vedang Kulkarni</dc:creator>
      <pubDate>Fri, 04 Sep 2026 08:44:15 +0000</pubDate>
      <link>https://dev.to/kvedang/building-sanctuary-ai-a-privacy-first-ai-journal-with-gemini-and-google-cloud-run-2ee6</link>
      <guid>https://dev.to/kvedang/building-sanctuary-ai-a-privacy-first-ai-journal-with-gemini-and-google-cloud-run-2ee6</guid>
      <description>&lt;p&gt;Personal journaling is useful, but it can be difficult to turn a collection of thoughts into meaningful insights or actionable goals.&lt;/p&gt;

&lt;p&gt;I wanted to experiment with a different approach: what if an AI could act as a reflection companion while keeping each user's journal data isolated and securely managed?&lt;/p&gt;

&lt;p&gt;That idea became Sanctuary AI, a cloud-native personal reflection and journaling application built with Google Cloud Run, Firebase Authentication, Cloud Firestore, and Google Gemini.&lt;/p&gt;

&lt;p&gt;The core workflow is simple:&lt;/p&gt;

&lt;p&gt;Reflect → Understand → Act → Review&lt;/p&gt;

&lt;p&gt;What does Sanctuary AI do?&lt;/p&gt;

&lt;p&gt;Sanctuary AI allows an authenticated user to:&lt;/p&gt;

&lt;p&gt;✍️ Write and save personal reflections&lt;br&gt;
🎙️ Create reflections using voice&lt;br&gt;
🧠 Analyze reflections with Gemini&lt;br&gt;
💭 Explore thoughts using Socratic questions&lt;br&gt;
🔄 Get alternative perspectives and cognitive reframing&lt;br&gt;
🤝 Chat with different AI Companion personas&lt;br&gt;
🔎 Ask questions about previous journal entries&lt;br&gt;
🎯 Convert insights into actionable goals&lt;br&gt;
✅ Track goals and tasks&lt;br&gt;
📊 Review recurring themes and insights&lt;br&gt;
📦 Export personal data&lt;br&gt;
🗑️ Delete their account and associated data&lt;/p&gt;

&lt;p&gt;The idea is not to replace personal reflection with AI.&lt;/p&gt;

&lt;p&gt;Instead, AI is used as a tool to help the user think more deeply about their own experiences.&lt;/p&gt;

&lt;p&gt;Architecture&lt;/p&gt;

&lt;p&gt;The application uses Google Cloud services for authentication, storage, backend processing, and AI.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;               Sanctuary AI
                    │
                    ▼
            ┌───────────────┐
            │   Web Client  │
            └───────┬───────┘
                    │
                    ▼
            Firebase Auth
                    │
               ID Token
                    │
                    ▼
            ┌───────────────┐
            │   Cloud Run   │
            │    Backend    │
            └───────┬───────┘
                    │
         ┌──────────┴──────────┐
         ▼                     ▼
  Cloud Firestore          Gemini API
   User Data                 AI
         │
         ▼
  User-scoped data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Cloud Run handles the backend logic while Firestore stores application data.&lt;/p&gt;

&lt;p&gt;Gemini provides the AI capabilities.&lt;/p&gt;

&lt;p&gt;Firebase Authentication provides the identity layer.&lt;/p&gt;

&lt;p&gt;Keeping User Data Isolated&lt;/p&gt;

&lt;p&gt;Because this application deals with personal reflections, data isolation was one of the most important design considerations.&lt;/p&gt;

&lt;p&gt;User data is organized using user-scoped Firestore collections:&lt;/p&gt;

&lt;p&gt;/users/{userId}/journals&lt;br&gt;
/users/{userId}/goals&lt;br&gt;
/users/{userId}/insights&lt;br&gt;
/users/{userId}/conversations&lt;br&gt;
/users/{userId}/messages&lt;/p&gt;

&lt;p&gt;Firestore security rules enforce ownership:&lt;/p&gt;

&lt;p&gt;request.auth.uid == userId&lt;/p&gt;

&lt;p&gt;The backend also validates the Firebase ID token and derives the authenticated user's identity from the token instead of trusting a user-provided user ID.&lt;/p&gt;

&lt;p&gt;This creates a clear boundary between users.&lt;/p&gt;

&lt;p&gt;Note: Firestore security rules provide authorization and data isolation. They should not be confused with end-to-end encryption.&lt;/p&gt;

&lt;p&gt;Gemini-Powered Reflection&lt;/p&gt;

&lt;p&gt;One of the main challenges was deciding how Gemini should actually be useful inside a journal.&lt;/p&gt;

&lt;p&gt;Instead of creating only a general-purpose chatbot, I created focused AI workflows.&lt;/p&gt;

&lt;p&gt;A reflection can be processed to generate:&lt;/p&gt;

&lt;p&gt;Key themes&lt;br&gt;
Socratic questions&lt;br&gt;
Alternative perspectives&lt;br&gt;
Summaries&lt;br&gt;
Potential action items&lt;br&gt;
Goal suggestions&lt;/p&gt;

&lt;p&gt;For example, instead of simply telling the user what to do, the Socratic workflow can encourage deeper thinking by asking questions about assumptions, evidence, and possible alternatives.&lt;/p&gt;

&lt;p&gt;This keeps the user involved in the reflection process.&lt;/p&gt;

&lt;p&gt;AI Companion&lt;/p&gt;

&lt;p&gt;Sanctuary AI also includes multiple interaction styles.&lt;/p&gt;

&lt;p&gt;Socratic Guide&lt;/p&gt;

&lt;p&gt;Designed to encourage deeper thinking through questions.&lt;/p&gt;

&lt;p&gt;Compassionate Empath&lt;/p&gt;

&lt;p&gt;Designed for supportive and empathetic reflection.&lt;/p&gt;

&lt;p&gt;Execution Coach&lt;/p&gt;

&lt;p&gt;Focused more on practical next steps and execution.&lt;/p&gt;

&lt;p&gt;The purpose is to make the AI interaction more useful depending on what the user needs at that moment.&lt;/p&gt;

&lt;p&gt;Ask My Journal&lt;/p&gt;

&lt;p&gt;One of the features I particularly wanted to build was Ask My Journal.&lt;/p&gt;

&lt;p&gt;Instead of asking Gemini general questions, the user can ask questions about their own previous reflections.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;"What topics have I been thinking about repeatedly?"&lt;/p&gt;

&lt;p&gt;"What goals have I mentioned recently?"&lt;/p&gt;

&lt;p&gt;"What patterns appear across my reflections?"&lt;/p&gt;

&lt;p&gt;"What did I write about this topic previously?"&lt;/p&gt;

&lt;p&gt;The system uses the user's journal history to help answer these questions and can reference relevant reflection dates.&lt;/p&gt;

&lt;p&gt;This turns the journal from a collection of individual entries into something that can be explored over time.&lt;/p&gt;

&lt;p&gt;Voice Journaling&lt;/p&gt;

&lt;p&gt;Sometimes writing isn't the easiest way to capture an idea.&lt;/p&gt;

&lt;p&gt;Sanctuary AI supports voice journaling using browser speech capabilities.&lt;/p&gt;

&lt;p&gt;The flow is:&lt;/p&gt;

&lt;p&gt;Speak&lt;br&gt;
  ↓&lt;br&gt;
Speech Recognition&lt;br&gt;
  ↓&lt;br&gt;
Journal Text&lt;br&gt;
  ↓&lt;br&gt;
Save Reflection&lt;br&gt;
  ↓&lt;br&gt;
AI Analysis&lt;/p&gt;

&lt;p&gt;This makes it easier to capture thoughts quickly.&lt;/p&gt;

&lt;p&gt;From Reflection to Action&lt;/p&gt;

&lt;p&gt;Another important part of the application is connecting reflection with action.&lt;/p&gt;

&lt;p&gt;An insight can be converted into a goal containing tasks, priority, and progress.&lt;/p&gt;

&lt;p&gt;Goal&lt;br&gt;
 ├── Priority&lt;br&gt;
 ├── Progress&lt;br&gt;
 ├── Task 1&lt;br&gt;
 ├── Task 2&lt;br&gt;
 └── Completion Status&lt;/p&gt;

&lt;p&gt;This creates a bridge between:&lt;/p&gt;

&lt;p&gt;"I realized something"&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;"I am going to do something about it."&lt;/p&gt;

&lt;p&gt;Insights and Periodic Reviews&lt;/p&gt;

&lt;p&gt;The application also looks beyond individual journal entries.&lt;/p&gt;

&lt;p&gt;Over time, users can review recurring themes and insights from their reflections.&lt;/p&gt;

&lt;p&gt;The workflow becomes:&lt;/p&gt;

&lt;p&gt;Reflections&lt;br&gt;
     ↓&lt;br&gt;
AI Analysis&lt;br&gt;
     ↓&lt;br&gt;
Recurring Themes&lt;br&gt;
     ↓&lt;br&gt;
Insights&lt;br&gt;
     ↓&lt;br&gt;
Goals&lt;br&gt;
     ↓&lt;br&gt;
Periodic Review&lt;/p&gt;

&lt;p&gt;This is where the Reflect → Understand → Act → Review model becomes useful.&lt;/p&gt;

&lt;p&gt;Using Google AI Studio&lt;/p&gt;

&lt;p&gt;I used Google AI Studio while developing and refining the AI workflows.&lt;/p&gt;

&lt;p&gt;The development process looked roughly like this:&lt;/p&gt;

&lt;p&gt;Idea&lt;br&gt;
  ↓&lt;br&gt;
Prompt Design&lt;br&gt;
  ↓&lt;br&gt;
Test in AI Studio&lt;br&gt;
  ↓&lt;br&gt;
Evaluate Response&lt;br&gt;
  ↓&lt;br&gt;
Refine Instructions&lt;br&gt;
  ↓&lt;br&gt;
Integrate into Application&lt;/p&gt;

&lt;p&gt;This was especially useful for experimenting with the different AI Companion personas and reflection workflows before integrating them into the application.&lt;/p&gt;

&lt;p&gt;Handling AI Reliability&lt;/p&gt;

&lt;p&gt;AI APIs can occasionally experience latency or failures.&lt;/p&gt;

&lt;p&gt;For that reason, I designed the AI integration with resilience in mind, including fallback and timeout/circuit-breaker concepts.&lt;/p&gt;

&lt;p&gt;The basic idea is:&lt;/p&gt;

&lt;p&gt;Primary Model&lt;br&gt;
      ↓&lt;br&gt;
Failure / Timeout?&lt;br&gt;
      ↓&lt;br&gt;
Fallback Model&lt;br&gt;
      ↓&lt;br&gt;
Failure?&lt;br&gt;
      ↓&lt;br&gt;
Next Fallback&lt;/p&gt;

&lt;p&gt;This helps prevent a temporary AI service problem from making the entire application unavailable.&lt;/p&gt;

&lt;p&gt;Security and Privacy&lt;/p&gt;

&lt;p&gt;Privacy was considered throughout the application architecture.&lt;/p&gt;

&lt;p&gt;Some of the key decisions include:&lt;/p&gt;

&lt;p&gt;Firebase Authentication for user identity&lt;br&gt;
User-scoped Firestore data&lt;br&gt;
Ownership-based Firestore security rules&lt;br&gt;
Server-side handling of Gemini credentials&lt;br&gt;
Google Cloud Secret Manager for sensitive configuration&lt;br&gt;
Backend token validation&lt;br&gt;
User data export&lt;br&gt;
Account/data deletion&lt;/p&gt;

&lt;p&gt;There are also areas I would like to improve further, particularly around stronger encryption and minimizing sensitive information sent to external AI services.&lt;/p&gt;

&lt;p&gt;Why Cloud Run?&lt;/p&gt;

&lt;p&gt;Cloud Run provides a simple way to deploy the backend as a containerized service without managing traditional servers.&lt;/p&gt;

&lt;p&gt;For this project, it fits well because the application needs a backend that can:&lt;/p&gt;

&lt;p&gt;Authenticate requests&lt;br&gt;
Communicate with Firestore&lt;br&gt;
Communicate with Gemini&lt;br&gt;
Manage application logic&lt;br&gt;
Scale with demand&lt;br&gt;
Run securely behind a public HTTPS endpoint&lt;/p&gt;

&lt;p&gt;The deployment flow is essentially:&lt;/p&gt;

&lt;p&gt;Application&lt;br&gt;
    ↓&lt;br&gt;
Container&lt;br&gt;
    ↓&lt;br&gt;
Cloud Run&lt;br&gt;
    ↓&lt;br&gt;
HTTPS Service&lt;br&gt;
What I Learned&lt;/p&gt;

&lt;p&gt;The biggest lesson from this project was that building an AI application is not just about calling an LLM API.&lt;/p&gt;

&lt;p&gt;The surrounding engineering is equally important:&lt;/p&gt;

&lt;p&gt;Authentication&lt;br&gt;
Authorization&lt;br&gt;
Data isolation&lt;br&gt;
Prompt engineering&lt;br&gt;
Secret management&lt;br&gt;
AI reliability&lt;br&gt;
Backend architecture&lt;br&gt;
User experience&lt;br&gt;
Data ownership&lt;/p&gt;

&lt;p&gt;Gemini is one component of the application, not the entire application.&lt;/p&gt;

&lt;p&gt;The final system combines:&lt;/p&gt;

&lt;p&gt;Firebase Authentication&lt;br&gt;
          +&lt;br&gt;
Cloud Firestore&lt;br&gt;
          +&lt;br&gt;
Cloud Run&lt;br&gt;
          +&lt;br&gt;
Gemini&lt;br&gt;
          +&lt;br&gt;
Google AI Studio&lt;br&gt;
          +&lt;br&gt;
Privacy &amp;amp; Security&lt;br&gt;
          ↓&lt;br&gt;
     Sanctuary AI&lt;br&gt;
Try the Application&lt;/p&gt;

&lt;p&gt;🌐 Live Demo:&lt;br&gt;
&lt;a href="https://private-ai-journal-reflection.ai.studio" rel="noopener noreferrer"&gt;https://private-ai-journal-reflection.ai.studio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fix1l05c9ouvv26fib3wq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fix1l05c9ouvv26fib3wq.png" alt=" " width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8xjivw8simffql2wyvs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8xjivw8simffql2wyvs3.png" alt=" " width="800" height="430"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffeawd1hpi4wqb4uy9qwx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffeawd1hpi4wqb4uy9qwx.png" alt=" " width="799" height="416"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc8opqtnavjl0mr3xvq94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc8opqtnavjl0mr3xvq94.png" alt=" " width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💻 Source Code:&lt;br&gt;
&lt;a href="https://github.com/KVedang/Stability-AI" rel="noopener noreferrer"&gt;https://github.com/KVedang/Stability-AI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project is also part of my participation in the Accelerate AI with Cloud Run challenge.&lt;/p&gt;

&lt;p&gt;What's Next?&lt;/p&gt;

&lt;p&gt;Some improvements I would like to explore include:&lt;/p&gt;

&lt;p&gt;More advanced semantic retrieval&lt;br&gt;
Better long-term journal analysis&lt;br&gt;
Additional privacy controls&lt;br&gt;
Improved personalization&lt;br&gt;
More sophisticated insights&lt;br&gt;
Stronger encryption options&lt;br&gt;
Improved goal analytics&lt;br&gt;
Final Thoughts&lt;/p&gt;

&lt;p&gt;Sanctuary AI started with a simple question:&lt;/p&gt;

&lt;p&gt;Can AI help people understand their own reflections without taking the reflection away from them?&lt;/p&gt;

&lt;p&gt;The result is a platform built around:&lt;/p&gt;

&lt;p&gt;Reflect → Understand → Act → Review&lt;/p&gt;

&lt;p&gt;The goal isn't to have AI make decisions for the user.&lt;/p&gt;

&lt;p&gt;It's to provide a private space where AI can help users ask better questions, discover patterns, and turn their own reflections into meaningful actions.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>accelerateaiwithcloudrun</category>
      <category>googlecloud</category>
      <category>cloudnextchallenge</category>
    </item>
  </channel>
</rss>
