cd /news/artificial-intelligence/building-sanctuary-ai-a-privacy-firs… Β· home β€Ί topics β€Ί artificial-intelligence β€Ί article
[ARTICLE Β· art-121315] src=dev.to β†— pub= topic=artificial-intelligence verified=true sentiment=Β· neutral

Building Sanctuary AI: A Privacy-First AI Journal with Gemini and Google Cloud Run

A developer built Sanctuary AI, a privacy-first AI journaling application using Google Cloud Run, Firebase Authentication, Cloud Firestore, and Google Gemini. The app allows users to write or voice-record reflections, analyze them with Gemini, and engage with AI personas for Socratic questioning and cognitive reframing, with user data isolated via user-scoped Firestore collections and security rules.

read6 min views1 publishedSep 4, 2026

Personal journaling is useful, but it can be difficult to turn a collection of thoughts into meaningful insights or actionable goals.

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?

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.

The core workflow is simple:

Reflect β†’ Understand β†’ Act β†’ Review

What does Sanctuary AI do?

Sanctuary AI allows an authenticated user to:

✍️ Write and save personal reflections

πŸŽ™οΈ Create reflections using voice

🧠 Analyze reflections with Gemini

πŸ’­ Explore thoughts using Socratic questions

πŸ”„ Get alternative perspectives and cognitive reframing

🀝 Chat with different AI Companion personas

πŸ”Ž Ask questions about previous journal entries

🎯 Convert insights into actionable goals

βœ… Track goals and tasks

πŸ“Š Review recurring themes and insights

πŸ“¦ Export personal data

πŸ—‘οΈ Delete their account and associated data

The idea is not to replace personal reflection with AI.

Instead, AI is used as a tool to help the user think more deeply about their own experiences.

Architecture

The application uses Google Cloud services for authentication, storage, backend processing, and AI.

               Sanctuary AI
                    β”‚
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   Web Client  β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
                    β–Ό
            Firebase Auth
                    β”‚
               ID Token
                    β”‚
                    β–Ό
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚   Cloud Run   β”‚
            β”‚    Backend    β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                     β–Ό
  Cloud Firestore          Gemini API
   User Data                 AI
         β”‚
         β–Ό
  User-scoped data

Cloud Run handles the backend logic while Firestore stores application data.

Gemini provides the AI capabilities.

Firebase Authentication provides the identity layer.

Keeping User Data Isolated

Because this application deals with personal reflections, data isolation was one of the most important design considerations.

User data is organized using user-scoped Firestore collections:

/users/{userId}/journals

/users/{userId}/goals

/users/{userId}/insights

/users/{userId}/conversations

/users/{userId}/messages

Firestore security rules enforce ownership:

request.auth.uid == userId

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.

This creates a clear boundary between users.

Note: Firestore security rules provide authorization and data isolation. They should not be confused with end-to-end encryption.

Gemini-Powered Reflection

One of the main challenges was deciding how Gemini should actually be useful inside a journal.

Instead of creating only a general-purpose chatbot, I created focused AI workflows.

A reflection can be processed to generate:

Key themes

Socratic questions

Alternative perspectives

Summaries

Potential action items

Goal suggestions

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.

This keeps the user involved in the reflection process.

AI Companion

Sanctuary AI also includes multiple interaction styles.

Socratic Guide

Designed to encourage deeper thinking through questions.

Compassionate Empath

Designed for supportive and empathetic reflection.

Execution Coach

Focused more on practical next steps and execution.

The purpose is to make the AI interaction more useful depending on what the user needs at that moment.

Ask My Journal

One of the features I particularly wanted to build was Ask My Journal.

Instead of asking Gemini general questions, the user can ask questions about their own previous reflections.

For example:

"What topics have I been thinking about repeatedly?"

"What goals have I mentioned recently?"

"What patterns appear across my reflections?"

"What did I write about this topic previously?"

The system uses the user's journal history to help answer these questions and can reference relevant reflection dates.

This turns the journal from a collection of individual entries into something that can be explored over time.

Voice Journaling

Sometimes writing isn't the easiest way to capture an idea.

Sanctuary AI supports voice journaling using browser speech capabilities.

The flow is:

Speak

↓

Speech Recognition

↓

Journal Text

↓

Save Reflection

↓

AI Analysis

This makes it easier to capture thoughts quickly.

From Reflection to Action

Another important part of the application is connecting reflection with action.

An insight can be converted into a goal containing tasks, priority, and progress.

Goal

β”œβ”€β”€ Priority

β”œβ”€β”€ Progress

β”œβ”€β”€ Task 1

β”œβ”€β”€ Task 2

└── Completion Status

This creates a bridge between:

"I realized something"

and

"I am going to do something about it."

Insights and Periodic Reviews

The application also looks beyond individual journal entries.

Over time, users can review recurring themes and insights from their reflections.

The workflow becomes:

Reflections

↓

AI Analysis

↓

Recurring Themes

↓

Insights

↓

Goals

↓

Periodic Review

This is where the Reflect β†’ Understand β†’ Act β†’ Review model becomes useful.

Using Google AI Studio

I used Google AI Studio while developing and refining the AI workflows.

The development process looked roughly like this:

Idea

↓

Prompt Design

↓

Test in AI Studio

↓

Evaluate Response

↓

Refine Instructions

↓

Integrate into Application

This was especially useful for experimenting with the different AI Companion personas and reflection workflows before integrating them into the application.

Handling AI Reliability

AI APIs can occasionally experience latency or failures.

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

The basic idea is:

Primary Model

↓

Failure / Timeout?

↓

Fallback Model

↓

Failure?

↓

Next Fallback

This helps prevent a temporary AI service problem from making the entire application unavailable.

Security and Privacy

Privacy was considered throughout the application architecture.

Some of the key decisions include:

Firebase Authentication for user identity

User-scoped Firestore data

Ownership-based Firestore security rules

Server-side handling of Gemini credentials

Google Cloud Secret Manager for sensitive configuration

Backend token validation

User data export

Account/data deletion

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

Why Cloud Run?

Cloud Run provides a simple way to deploy the backend as a containerized service without managing traditional servers.

For this project, it fits well because the application needs a backend that can:

Authenticate requests

Communicate with Firestore

Communicate with Gemini

Manage application logic

Scale with demand

Run securely behind a public HTTPS endpoint

The deployment flow is essentially:

Application

↓

Container

↓

Cloud Run

↓

HTTPS Service

What I Learned

The biggest lesson from this project was that building an AI application is not just about calling an LLM API.

The surrounding engineering is equally important:

Authentication

Authorization

Data isolation

Prompt engineering

Secret management

AI reliability

Backend architecture

User experience

Data ownership

Gemini is one component of the application, not the entire application.

The final system combines:

Firebase Authentication

Cloud Firestore

Cloud Run

Gemini

Google AI Studio

Privacy & Security

↓

Sanctuary AI

Try the Application

🌐 Live Demo:

https://private-ai-journal-reflection.ai.studio

πŸ’» Source Code:

https://github.com/KVedang/Stability-AI

The project is also part of my participation in the Accelerate AI with Cloud Run challenge.

What's Next?

Some improvements I would like to explore include:

More advanced semantic retrieval

Better long-term journal analysis

Additional privacy controls

Improved personalization

More sophisticated insights

Stronger encryption options

Improved goal analytics

Final Thoughts

Sanctuary AI started with a simple question:

Can AI help people understand their own reflections without taking the reflection away from them?

The result is a platform built around:

Reflect β†’ Understand β†’ Act β†’ Review

The goal isn't to have AI make decisions for the user.

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.

── more in #artificial-intelligence 4 stories Β· sorted by recency
── more on @sanctuary ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/building-sanctuary-a…] indexed:0 read:6min 2026-09-04 Β· β€”