Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SnapConnect - AI-Powered Ephemeral Messaging

Next-generation mobile chat application that combines ephemeral messaging with persistent AI summaries using advanced LLM and RAG technology. Unlike traditional disappearing message apps, every piece of content generates intelligent, context-aware summaries that preserve conversation meaning while maintaining media ephemerality.

๐Ÿš€ Current Status: Production-Ready with AI Infrastructure

โœ… Phase 1 COMPLETE: Core ephemeral messaging with full group chat
โœ… AI Infrastructure READY: LLM pipeline scaffolded and deployable
โœ… RAG System IMPLEMENTED: Vector search with contextual summaries
โœ… Content Moderation CONFIGURED: OpenAI safety pipeline ready
๐ŸŽฏ Activation Ready: Only requires API key configuration


๐Ÿ—๏ธ System Architecture

Current Production Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    CLIENT LAYER                                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  React Native/Expo Web                                         โ”‚
โ”‚  โ”œโ”€โ”€ NativeWind (Tailwind CSS v4)                             โ”‚
โ”‚  โ”œโ”€โ”€ Expo Router (File-based routing)                         โ”‚
โ”‚  โ”œโ”€โ”€ Zustand (State management)                               โ”‚
โ”‚  โ””โ”€โ”€ Real-time Firestore listeners                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    API LAYER                                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Firebase Services                                             โ”‚
โ”‚  โ”œโ”€โ”€ Firebase Auth (User authentication)                      โ”‚
โ”‚  โ”œโ”€โ”€ Firestore (Real-time database)                          โ”‚
โ”‚  โ”œโ”€โ”€ Firebase Storage (Media files)                          โ”‚
โ”‚  โ””โ”€โ”€ Cloud Functions (Server-side logic)                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 DATA PERSISTENCE                               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Firestore Collections:                                       โ”‚
โ”‚  โ”œโ”€โ”€ users/{userId}                    [ACTIVE]              โ”‚
โ”‚  โ”œโ”€โ”€ conversations/{conversationId}     [ACTIVE]              โ”‚
โ”‚  โ”œโ”€โ”€ messages/{messageId}              [ACTIVE]              โ”‚
โ”‚  โ”œโ”€โ”€ receipts/{receiptId}              [ACTIVE]              โ”‚
โ”‚  โ”œโ”€โ”€ friendRequests/{requestId}        [ACTIVE]              โ”‚
โ”‚  โ”œโ”€โ”€ summaries/{summaryId}             [CONFIGURED]          โ”‚
โ”‚  โ””โ”€โ”€ ragChunks/{chunkId}               [CONFIGURED]          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

AI Processing Pipeline (Ready for Activation)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   MESSAGE CREATED                              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 CLOUD TASKS QUEUE                              โ”‚
โ”‚  โ”œโ”€โ”€ Automatic queueing on message creation                   โ”‚
โ”‚  โ”œโ”€โ”€ Batch processing for cost optimization                   โ”‚
โ”‚  โ””โ”€โ”€ Retry logic with exponential backoff                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              CLOUD RUN WORKER (Deployed)                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  AI Processing Pipeline:                                       โ”‚
โ”‚  โ”œโ”€โ”€ ๐Ÿ›ก๏ธ  Content Moderation (OpenAI Moderation API)           โ”‚
โ”‚  โ”œโ”€โ”€ ๐Ÿ‘๏ธ  Vision Analysis (OpenAI Vision API)                  โ”‚
โ”‚  โ”œโ”€โ”€ ๐Ÿง  RAG Context Retrieval (Pinecone Vector DB)           โ”‚
โ”‚  โ”œโ”€โ”€ โœจ Enhanced Summary Generation (GPT-4o-mini)            โ”‚
โ”‚  โ””โ”€โ”€ ๐Ÿ“Š Vector Embedding Storage (text-embedding-3-small)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  EXTERNAL AI SERVICES                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  OpenAI Services:                                             โ”‚
โ”‚  โ”œโ”€โ”€ GPT-4o-mini (Summary generation)                        โ”‚
โ”‚  โ”œโ”€โ”€ text-embedding-3-small (Vector embeddings)              โ”‚
โ”‚  โ”œโ”€โ”€ OpenAI Moderation API (Content safety)                  โ”‚
โ”‚  โ””โ”€โ”€ Vision API (Image analysis)                             โ”‚
โ”‚                                                               โ”‚
โ”‚  Pinecone Vector Database:                                    โ”‚
โ”‚  โ”œโ”€โ”€ Conversation-scoped namespaces                          โ”‚
โ”‚  โ”œโ”€โ”€ 1536-dimension embeddings                               โ”‚
โ”‚  โ”œโ”€โ”€ Cosine similarity search                                โ”‚
โ”‚  โ””โ”€โ”€ Sub-second query performance                            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฑ Feature Architecture

โœ… Production Features

Ephemeral Messaging System

  • TTL Engine: Client-side countdown with server-side cleanup
  • Receipt Tracking: Per-participant delivery confirmation
  • Smart Cleanup: Preserves message documents for AI summary access
  • Cross-platform: Unified behavior across web and mobile
// TTL Countdown Architecture
export const useCountdown = (receivedAt: Date | null, ttlPreset: string) => {
  // Real-time countdown with 1-second precision
  // Handles offline scenarios and clock synchronization
  // Triggers expiration events for analytics
}

Group Chat System

  • Conversation Model: Up to 5 participants with metadata tracking
  • Member Management: Dynamic add/remove with proper state sync
  • Group TTL Logic: Collective expiration when all participants' TTLs complete
  • Real-time Updates: Live conversation state via Firestore listeners
// Group Architecture
interface Conversation {
  participantIds: string[];           // Max 5 participants
  messageCount?: number;              // For RAG batching
  lastRAGUpdateAt?: FirestoreTimestamp; // AI processing tracker
  ragEnabled?: boolean;               // Per-conversation AI toggle
}

๐Ÿ”ฎ AI-Ready Features (Scaffolded)

LLM Summary Generation

  • Context-Aware: RAG-enhanced summaries using conversation history
  • Efficiency: 20-token limit with batch processing
  • Confidence Scoring: Quality metrics and fallback handling
  • Visual Indicators: Brain emoji for enhanced vs basic summaries
// AI Summary Architecture
interface Summary {
  summaryText: string;                // โ‰ค20 tokens
  contextUsed: string[];              // RAG context message IDs  
  confidence: number;                 // 0.5-0.9 quality score
  moderationPassed?: boolean;         // Safety validation
  retryCount?: number;                // Error handling
}

RAG (Retrieval-Augmented Generation)

  • Vector Database: Pinecone with conversation-scoped namespaces
  • Semantic Search: Natural language conversation queries
  • Context Window: Top 3 relevant messages for enhanced summaries
  • Pronoun Resolution: "he said yes" โ†’ "Tom agreed"
// RAG System Architecture  
export const searchConversationHistory = async (
  conversationId: string,
  query: string,
  maxResults: number = 5
): Promise<SearchResult[]> => {
  // Semantic search with confidence scoring
  // Returns relevant messages with context
}

Content Moderation Pipeline

  • Multi-Modal: Text (OpenAI Moderation) + Vision (OpenAI Vision API)
  • Real-time: Pre-delivery content filtering
  • Appeal Process: User feedback and review queue
  • Context Preservation: Safe summaries with harmful content filtered

๐Ÿ› ๏ธ Technical Stack

Layer Technology Status Purpose
Frontend React Native + Expo Router โœ… DEPLOYED Cross-platform UI
Styling NativeWind (Tailwind v4) โœ… DEPLOYED Responsive design system
State Zustand + React Context โœ… DEPLOYED Global state management
Backend Firebase (Auth/Firestore/Storage) โœ… DEPLOYED BaaS infrastructure
Functions Cloud Functions v2 โœ… DEPLOYED Server-side logic
AI Worker Cloud Run (Express + Winston) โœ… DEPLOYED AI processing pipeline
LLM OpenAI GPT-4o-mini ๐Ÿ”ฎ CONFIGURED Summary generation
Embeddings OpenAI text-embedding-3-small ๐Ÿ”ฎ CONFIGURED Vector search
Vector DB Pinecone (1536-dim, cosine) ๐Ÿ”ฎ CONFIGURED RAG context retrieval
Moderation OpenAI Moderation + Vision API ๐Ÿ”ฎ CONFIGURED Content safety
Analytics Firebase Analytics + BigQuery โœ… DEPLOYED Usage tracking
Monitoring Winston + Cloud Logging โœ… DEPLOYED System observability

๐Ÿš€ Development Setup

Prerequisites

  • Node.js 18+ and npm
  • Expo CLI (npm install -g @expo/cli)
  • Firebase CLI (npm install -g firebase-tools)
  • Firebase project with Blaze plan

1. Repository Setup

git clone <repository-url> snapconnect
cd snapconnect
npm install

# Install dependencies for all services
cd functions && npm install && cd ..
cd backend/worker && npm install && cd ../..

2. Firebase Configuration

# Authenticate and configure project
firebase login
firebase use --add

# Deploy core infrastructure
firebase deploy --only firestore:rules,firestore:indexes
firebase deploy --only storage:rules
firebase deploy --only functions

3. Environment Variables

Create .env file:

# Firebase Configuration
EXPO_PUBLIC_FB_API_KEY=your_api_key
EXPO_PUBLIC_FB_AUTH_DOMAIN=project.firebaseapp.com
EXPO_PUBLIC_FB_PROJECT_ID=your_project_id
EXPO_PUBLIC_FB_STORAGE_BUCKET=project.appspot.com
EXPO_PUBLIC_FB_MESSAGING_SENDER_ID=123456789
EXPO_PUBLIC_FB_APP_ID=1:123456789:web:abcdef

# AI Services (for activation)
OPENAI_API_KEY=sk-your_openai_key_here
PINECONE_API_KEY=your_pinecone_key_here
PINECONE_INDEX_NAME=snaps-prod

4. AI Infrastructure Setup (Optional)

# Deploy AI processing worker
cd backend/worker
gcloud run deploy moderation-worker \
  --source . \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

# Configure Cloud Tasks queue
gcloud tasks queues create moderate-summary-queue \
  --location=us-central1

5. Start Development

# Web development server
npx expo start --web

# Mobile development (Expo Go)
npx expo start

# Monitor logs (separate terminal)
npx firebase functions:log --follow

๐Ÿ“ Detailed Project Architecture

snapconnect/
โ”œโ”€โ”€ ๐ŸŽฏ CLIENT APPLICATION
โ”‚   โ”œโ”€โ”€ app/                          # Expo Router file-based routing
โ”‚   โ”‚   โ”œโ”€โ”€ _layout.tsx              # Root navigation with auth flow
โ”‚   โ”‚   โ”œโ”€โ”€ index.tsx                # Landing page with auth redirect
โ”‚   โ”‚   โ”œโ”€โ”€ (auth)/                  # Public authentication stack
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ _layout.tsx          # Auth layout wrapper
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ login.tsx            # Firebase Auth integration
โ”‚   โ”‚   โ””โ”€โ”€ (protected)/             # Auth-gated application
โ”‚   โ”‚       โ”œโ”€โ”€ _layout.tsx          # Protected route wrapper
โ”‚   โ”‚       โ”œโ”€โ”€ home.tsx             # Main message feed
โ”‚   โ”‚       โ”œโ”€โ”€ camera.tsx           # Media capture with TTL selection
โ”‚   โ”‚       โ”œโ”€โ”€ preview.tsx          # Media preview before sending
โ”‚   โ”‚       โ”œโ”€โ”€ compose-text.tsx     # Text message composition
โ”‚   โ”‚       โ”œโ”€โ”€ select-friend.tsx    # Recipient selection
โ”‚   โ”‚       โ”œโ”€โ”€ friends.tsx          # Friend management
โ”‚   โ”‚       โ”œโ”€โ”€ add-friend.tsx       # Friend request sending
โ”‚   โ”‚       โ”œโ”€โ”€ groups.tsx           # Group conversation list
โ”‚   โ”‚       โ”œโ”€โ”€ create-group.tsx     # Group creation wizard
โ”‚   โ”‚       โ”œโ”€โ”€ settings.tsx         # User preferences + TTL defaults
โ”‚   โ”‚       โ”œโ”€โ”€ group-conversation/
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ [conversationId].tsx    # Real-time group chat
โ”‚   โ”‚       โ”œโ”€โ”€ group-settings/
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ [conversationId].tsx    # Group administration
โ”‚   โ”‚       โ””โ”€โ”€ add-group-member/
โ”‚   โ”‚           โ””โ”€โ”€ [conversationId].tsx    # Dynamic member addition
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ components/                   # Reusable UI architecture
โ”‚   โ”‚   โ”œโ”€โ”€ Header.tsx               # Navigation with context awareness
โ”‚   โ”‚   โ”œโ”€โ”€ MessageItem.tsx          # Individual message with TTL countdown
โ”‚   โ”‚   โ”œโ”€โ”€ GroupMessageItem.tsx     # Group message with sender context
โ”‚   โ”‚   โ”œโ”€โ”€ InConversationComposer.tsx # Context-aware message composer
โ”‚   โ”‚   โ”œโ”€โ”€ TextMessageComposer.tsx  # Standalone text composition
โ”‚   โ”‚   โ”œโ”€โ”€ TtlSelector.tsx          # TTL preset selection UI
โ”‚   โ”‚   โ”œโ”€โ”€ ConversationSummaryBanner.tsx # AI summary display
โ”‚   โ”‚   โ”œโ”€โ”€ SummaryLine.tsx          # Individual message summaries
โ”‚   โ”‚   โ”œโ”€โ”€ ProcessingDemarcationLine.tsx # RAG processing indicators
โ”‚   โ”‚   โ”œโ”€โ”€ FullScreenImageViewer.tsx # Media viewing component
โ”‚   โ”‚   โ”œโ”€โ”€ LoadingSpinner.tsx       # Loading state management
โ”‚   โ”‚   โ”œโ”€โ”€ Toast.tsx                # Notification system
โ”‚   โ”‚   โ””โ”€โ”€ ConfirmDialog.tsx        # Action confirmation modals
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ hooks/                       # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ useCountdown.ts          # TTL countdown with offline handling
โ”‚   โ”‚   โ””โ”€โ”€ useReceiptTracking.ts    # Message delivery confirmation
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ store/                       # Global state management
โ”‚   โ”‚   โ”œโ”€โ”€ useAuth.ts               # Authentication state (Zustand)
โ”‚   โ”‚   โ””โ”€โ”€ usePresence.ts           # User online/offline status
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ lib/                         # Core client utilities
โ”‚       โ”œโ”€โ”€ firebase.ts              # Firebase SDK initialization
โ”‚       โ”œโ”€โ”€ analytics.ts             # Event tracking with platform detection
โ”‚       โ””โ”€โ”€ conversationSearch.ts    # RAG search client interface
โ”‚
โ”œโ”€โ”€ ๐Ÿ”ง CONFIGURATION & MODELS
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ messaging.ts             # TTL presets, group limits, LLM config
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ models/firestore/            # TypeScript data models
โ”‚   โ”‚   โ”œโ”€โ”€ user.ts                  # User profile with TTL preferences
โ”‚   โ”‚   โ”œโ”€โ”€ friend.ts                # Friend relationship model
โ”‚   โ”‚   โ”œโ”€โ”€ friendRequest.ts         # Friend request lifecycle
โ”‚   โ”‚   โ”œโ”€โ”€ conversation.ts          # Group conversation with RAG hooks
โ”‚   โ”‚   โ”œโ”€โ”€ message.ts               # Message with AI integration flags
โ”‚   โ”‚   โ”œโ”€โ”€ receipt.ts               # Delivery/view tracking per participant
โ”‚   โ”‚   โ”œโ”€โ”€ summary.ts               # LLM summary with confidence scoring
โ”‚   โ”‚   โ””โ”€โ”€ blockedUser.ts           # User blocking relationships
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ firestore.rules              # Security rules with AI collection support
โ”‚   โ”œโ”€โ”€ firestore.indexes.json       # Optimized query indexes
โ”‚   โ”œโ”€โ”€ storage.rules                # Media storage permissions
โ”‚   โ””โ”€โ”€ env.ts                       # Type-safe environment configuration
โ”‚
โ”œโ”€โ”€ โšก BACKEND SERVICES
โ”‚   โ”œโ”€โ”€ functions/                   # Firebase Cloud Functions
โ”‚   โ”‚   โ””โ”€โ”€ src/
โ”‚   โ”‚       โ””โ”€โ”€ index.ts             # Friend system + TTL cleanup (10min schedule)
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ backend/worker/              # AI Processing Service (Cloud Run)
โ”‚       โ”œโ”€โ”€ src/
โ”‚       โ”‚   โ””โ”€โ”€ index.ts             # Complete AI pipeline implementation
โ”‚       โ”œโ”€โ”€ package.json             # Node.js dependencies with AI libraries
โ”‚       โ””โ”€โ”€ cloudbuild.yaml          # Google Cloud deployment config
โ”‚
โ”œโ”€โ”€ ๐Ÿ“– DOCUMENTATION
โ”‚   โ”œโ”€โ”€ docs/
โ”‚   โ”‚   โ”œโ”€โ”€ PRD.md                   # Product Requirements (v2.0 - LLM focused)
โ”‚   โ”‚   โ”œโ”€โ”€ PHASE3_RAG_IMPLEMENTATION.md # RAG system documentation
โ”‚   โ”‚   โ”œโ”€โ”€ GROUP_CHAT_KNOWN_ISSUES.md # Known limitations
โ”‚   โ”‚   โ”œโ”€โ”€ REMAINING_TASKS.md       # Future roadmap
โ”‚   โ”‚   โ””โ”€โ”€ TODO.md                  # Implementation tracking
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ๐Ÿงช TESTING & VALIDATION
โ”‚       โ”œโ”€โ”€ test_ai_pipeline.sh      # AI service health checks
โ”‚       โ”œโ”€โ”€ validate_setup.sh        # Infrastructure validation
โ”‚       โ””โ”€โ”€ end-to-end-pipeline-test.html # Full workflow testing

๐Ÿ”ง Key Architectural Components

TTL System Architecture

// Client-side countdown with server synchronization
const TTL_FLOW = {
  1: "Message sent with TTL preset",
  2: "Recipient receives โ†’ receipt timestamp created", 
  3: "Client calculates expiresAt = receivedAt + TTL",
  4: "Real-time countdown via useCountdown hook",
  5: "Server cleanup every 10min deletes expired media",
  6: "Document preserved with expired flag for AI access"
}

Group Chat Architecture

// Conversation-scoped message management
const GROUP_ARCHITECTURE = {
  "Conversation Document": "Metadata + participant list + RAG hooks",
  "Message Collection": "All messages with conversationId reference",
  "Receipt Tracking": "Per-participant delivery confirmations",
  "Real-time Updates": "Firestore listeners for live state sync"
}

AI Processing Architecture

// Modular AI pipeline with graceful degradation
const AI_PIPELINE = {
  "Queue Management": "Cloud Tasks with retry logic",
  "Content Moderation": "OpenAI APIs with confidence thresholds", 
  "RAG Enhancement": "Pinecone vector search for context",
  "Summary Generation": "GPT-4o-mini with 20-token efficiency",
  "Error Handling": "Fallback to basic processing on failures"
}

๐Ÿš€ Deployment Architecture

Production Deployment

# Complete deployment pipeline
firebase deploy                      # Core Firebase services
cd backend/worker && gcloud run deploy # AI processing service
eas build --platform all            # Mobile app builds
npx expo export --platform web      # Web application build

Environment Management

  • Development: Local Expo server + Firebase Emulators
  • Staging: Firebase project + Cloud Run staging
  • Production: Full Firebase + Cloud Run + EAS builds

Monitoring & Observability

  • Cloud Logging: Comprehensive logging across all services
  • Firebase Analytics: User behavior and feature adoption
  • Cost Monitoring: AI processing cost tracking and alerts
  • Performance: Real-time function execution monitoring

๐ŸŽฏ AI Feature Activation Guide

Immediate Activation (< 1 day)

# 1. Configure API keys
firebase functions:config:set openai.api_key="sk-your-key"
firebase functions:config:set pinecone.api_key="your-key"

# 2. Deploy AI-enabled functions  
firebase deploy --only functions

# 3. Activate Cloud Run worker
# (Already deployed, just needs environment variables)

Feature Rollout (< 1 week)

# 1. Enable summary generation
# Update config/messaging.ts โ†’ ENABLE_AI_FEATURES = true

# 2. Deploy client updates
npx expo export --platform web
eas build --platform all

# 3. Monitor AI processing
gcloud logging read "resource.type=cloud_run_revision"

๐Ÿ” Performance Benchmarks

Metric Current Target Status
Message Delivery <500ms P95 <800ms โœ… EXCEEDS
TTL Countdown Accuracy ยฑ1s ยฑ2s โœ… EXCEEDS
Group Chat Load Time <1s <2s โœ… EXCEEDS
AI Summary Generation N/A <3s P95 ๐Ÿ”ฎ CONFIGURED
RAG Context Retrieval N/A <500ms ๐Ÿ”ฎ CONFIGURED
Vector Search N/A <800ms ๐Ÿ”ฎ CONFIGURED

๐Ÿ› Known Architectural Limitations

Group TTL Extension Issue

// Current behavior: Messages persist until ALL participants' TTLs expire
// Impact: Offline users can extend message lifetime indefinitely
// Status: Documented acceptable limitation for Phase 1
// Solution: Multiple strategies planned for Phase 2

AI Processing Dependencies

// External service dependencies for AI features
const AI_DEPENDENCIES = {
  "OpenAI API": "Summary generation and moderation",
  "Pinecone": "Vector search and RAG functionality", 
  "Cloud Run": "AI processing worker service"
  // All configured with fallback handling
}

๐Ÿ“š Architecture Documentation


๐Ÿค Development Guidelines

Code Architecture Principles

  • Modular Design: Each feature as independent, reusable components
  • Type Safety: Comprehensive TypeScript interfaces for all data models
  • Real-time First: Firestore listeners for immediate state synchronization
  • AI-Ready: All data structures prepared for LLM integration
  • Observability: Extensive logging and monitoring throughout

Contribution Workflow

  1. Architecture Review: Major changes require architectural discussion
  2. Type Definitions: Update models/firestore/* for data structure changes
  3. Security Rules: Update firestore.rules for new collections/permissions
  4. Documentation: Update README and docs/ for significant changes
  5. Testing: Use provided validation scripts for infrastructure changes

๐Ÿš€ Built with cutting-edge architecture: React Native + Firebase + OpenAI + Pinecone

Ready for immediate AI feature activation with production-grade infrastructure

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages