Skip to content

Aryan-B-Parikh/SoulSync

Repository files navigation

🌟 SoulSync AI

A sophisticated AI companion with real-time streaming, long-term memory, personality modes, and a premium glassmorphic UI. Built with React, Node.js, Prisma/PostgreSQL, and advanced AI features.

SoulSync React Node.js PostgreSQL


✨ Features

πŸš€ Real-Time Streaming Responses

  • Server-Sent Events (SSE) for token-by-token streaming
  • < 500ms first token latency
  • Optimistic UI updates with smooth animations
  • Graceful error handling and reconnection

🧠 Long-Term Memory (RAG)

  • Pinecone vector database for memory storage
  • OpenAI embeddings (1536-dim vectors)
  • Automatic memory storage for every message
  • Top-3 relevant memories retrieved per query
  • Contextual AI responses that remember past conversations

🎭 Personality Modes

  • πŸŒ™ Deep & Reflective: Introspective, philosophical
  • 🌀 Supportive Friend: Warm, encouraging, validating
  • ✨ Creative & Poetic: Metaphorical, artistic
  • Persistent personality preferences per user

πŸ“Š Mood Dashboard

  • Automatic sentiment analysis of every message
  • Emotional Resonance Map - GitHub-style heatmap of your emotional journey
  • Mood Calendar - Weekly view with color-coded daily moods
  • Mood Distribution - Visual breakdown of emotional patterns
  • Trend graphs showing emotional patterns over time

πŸ‘€ User Profile System

  • Profile Settings: Customizable display name and settings
  • Sidebar Integration: Quick access to profile, mood, and settings
  • Persistent Stats: View your journey statistics

🎨 Premium UI

  • Living Organism Design - Aurora backgrounds with breathing animations
  • Dark/Light Mode with seamless transitions
  • Glassmorphism design with backdrop blur
  • Google Fonts (Playfair Display, Inter)
  • Smooth 60fps animations with Framer Motion
  • Interactive Personality Selector Modal

πŸ’¬ Chat Management

  • Create, rename, and delete conversations
  • Inline editing for chat titles
  • Message feedback (thumbs up/down)
  • Training data export for fine-tuning

πŸ—οΈ Tech Stack

Frontend

  • React 18 with Hooks & Context
  • Tailwind CSS for styling
  • Framer Motion for animations
  • Recharts for data visualization
  • Lucide React for icons
  • date-fns for date manipulation

Backend

  • Node.js with Express
  • Prisma ORM with PostgreSQL (Neon)
  • JWT authentication
  • Server-Sent Events (SSE) for streaming
  • Sentiment library for mood analysis

AI & Vector Database

  • Groq API for LLM responses (Llama 3.3 70B)
  • OpenAI API for embeddings
  • Pinecone for vector storage
  • RAG architecture for memory

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL database (Neon recommended)
  • Groq API key
  • OpenAI API key (for embeddings)
  • Pinecone account (free tier)

Installation

  1. Clone the repository
git clone https://github.com/Aryan-B-Parikh/SoulSync.git
cd SoulSync
  1. Install dependencies
# Install all dependencies (root, backend, frontend)
npm install
cd backend && npm install
cd ../frontend && npm install
cd ..
  1. Set up environment variables

Create backend/.env:

# Database (PostgreSQL via Neon)
DATABASE_URL=postgresql://user:password@host/database?sslmode=require

# AI Services
GROQ_API_KEY=your_groq_api_key
OPENAI_API_KEY=your_openai_api_key
EMBEDDING_MODEL=text-embedding-3-small

# Vector Database (Pinecone)
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=soulsync-memories

# Authentication
JWT_SECRET=your_super_secret_jwt_key_min_32_chars

# Server
NODE_ENV=development
PORT=5001

Create frontend/.env:

REACT_APP_API_URL=/api
  1. Set up Database
cd backend
npx prisma generate
npx prisma db push
  1. Set up Pinecone
  • Sign up at pinecone.io
  • Create an index:
    • Name: soulsync-memories
    • Dimension: 1536
    • Metric: cosine
  1. Run the application
# From root directory
npm run dev

The app will be available at:

  • Frontend: http://localhost:5173
  • Backend: http://localhost:5001

πŸ“š API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/me - Get current user

Chat

  • GET /api/chats - Get all chats
  • POST /api/chats - Create new chat
  • GET /api/chats/:id - Get chat with messages
  • PATCH /api/chats/:id - Rename chat
  • DELETE /api/chats/:id - Delete chat
  • POST /api/chats/:id/messages/stream - Stream AI response (SSE)

Memory

  • GET /api/memory/stats - Get memory statistics
  • GET /api/memory/search?query=... - Search memories
  • GET /api/memory/recent - Get recent memories
  • DELETE /api/memory/all - Delete all memories (privacy)

Mood

  • GET /api/mood/summary - Get mood analytics
  • GET /api/mood/history - Get mood history
  • GET /api/mood/calendar/:year/:month - Get calendar mood data
  • GET /api/mood/heatmap - Get heatmap data

User

  • GET /api/user/personality - Get personality preference
  • PUT /api/user/personality - Update personality
  • GET /api/user/profile - Get user profile
  • PUT /api/user/profile - Update profile

πŸ“ Project Structure

SoulSync/
β”œβ”€β”€ frontend/               # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/      # Chat components
β”‚   β”‚   β”‚   β”œβ”€β”€ mood/      # Mood dashboard components
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ context/       # React context (Auth, Chat, Theme)
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   └── config/        # Configuration
β”‚   └── package.json
β”œβ”€β”€ backend/                # Express backend
β”‚   β”œβ”€β”€ config/            # Database & app config
β”‚   β”œβ”€β”€ controllers/       # Request handlers
β”‚   β”œβ”€β”€ middleware/        # Express middleware
β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”œβ”€β”€ services/          # Business logic
β”‚   β”‚   └── sentiment/     # Sentiment analysis
β”‚   β”œβ”€β”€ ml/                # Machine Learning
β”‚   β”‚   β”œβ”€β”€ models/        # Trained ML models
β”‚   β”‚   β”œβ”€β”€ training/      # Training datasets
β”‚   β”‚   └── scripts/       # Training scripts
β”‚   β”œβ”€β”€ prisma/            # Database schema
β”‚   β”‚   └── schema.prisma
β”‚   β”œβ”€β”€ tests/             # Tests
β”‚   β”‚   β”œβ”€β”€ unit/          # Unit tests
β”‚   β”‚   └── integration/   # Integration tests
β”‚   └── docs/              # Backend documentation
β”œβ”€β”€ tests/                  # Integration tests
β”œβ”€β”€ docs/                   # Project documentation
└── package.json           # Root package.json

πŸ›οΈ Architecture

Frontend (React)
    ↓
ChatPage β†’ sendStreamingMessage()
    ↓
Backend (Express)
    ↓
streaming.controller.js
    ↓
1. Save user message to PostgreSQL (Prisma)
2. Analyze sentiment
3. Generate embedding β†’ OpenAI
4. Store in Pinecone (vectorService.js)
5. Retrieve top-3 memories (cosine similarity)
6. Inject memories into system prompt
7. Stream AI response (Groq API)
8. Save assistant message
    ↓
Frontend receives SSE stream
    ↓
MessageBubble displays with animations

πŸ’° Cost Estimates

Free Tier Limits

  • Groq: Free tier with rate limits
  • OpenAI Embeddings: ~$0.10 per 1M tokens
  • Pinecone: 100,000 vectors (~200 users)
  • Neon PostgreSQL: Free tier (500MB storage)

Monthly Costs

  • 10 users, 100 messages each: ~$0.05/month
  • 100 users, 500 messages each: ~$2/month

πŸ§ͺ Testing

Run Tests

# Unit tests
cd backend
node tests/unit/sentiment.test.js

# Data pipeline audit (check training data health)
npm run audit-data

# Security isolation test (cross-tenant memory leak check)
npm run test:security

# RAG stress test (memory poisoning resistance)
npm run test:rag

# Load test (Vercel timeout simulation)
npm run load-test

⚠️ Live tests (test:security, test:rag, load-test) require the backend running: npm run backend:dev

Data Flywheel β€” Smoke Test

After chatting and rating messages, run:

node scripts/audit-training-data.js

Success criteria:

  • Total messages > 0
  • Missing context_used = 0
  • Upvoted (rating=1) > 0

Manual Testing Checklist

  • Send message, verify streaming works
  • Change personality mode, verify AI tone changes
  • Test memory recall ("My favorite color is purple" β†’ ask later)
  • Verify mood dashboard updates with new messages
  • Test dark/light mode toggle
  • Test chat rename and delete
  • Click πŸ‘ on a message β†’ verify rating=1 in DB via audit script

πŸŽ“ Portfolio Highlights

Technical Achievements

βœ… Production RAG System - Real vector database with Pinecone
βœ… Streaming Architecture - SSE with async generators
βœ… PostgreSQL + Prisma - Modern ORM with type safety
βœ… Sentiment Analysis - 93.3% accuracy + LLM hybrid second opinion
βœ… Premium UI - Living organism design with aurora effects
βœ… Dark Mode - Full theme system with smooth transitions
βœ… Full-Stack Implementation - Backend + Frontend + Database
βœ… Privacy-First Design - User isolation, PII scrubbing, secure memory management
βœ… Data Flywheel - Self-improving architecture: logs β†’ filter β†’ fine-tune


πŸ”’ Data & Privacy

Privacy-First Design β€” SoulSync is built with user privacy as a core principle.

  • User Isolation: All memories and conversations are strictly scoped to your account. No user can access another user's data.
  • No Third-Party Tracking: SoulSync does not use analytics trackers or sell user data.
  • Data Deletion: Users can delete all their memories and conversations at any time via the app.
  • AI Model Improvement: Anonymized conversation data may be used to improve the quality of SoulSync's AI models. Before any processing, all personal identifiers (email addresses, phone numbers, URLs) are automatically scrubbed and replaced with placeholder tokens. Raw conversation data is never shared with third parties for this purpose.
  • Feedback is Optional: Thumbs up/down ratings are entirely optional and only used to identify high-quality training examples.

Contributions are welcome! Please feel free to submit a Pull Request.


πŸ“„ License

MIT License - feel free to use this project for learning or portfolio purposes.


πŸ™ Acknowledgments

  • Groq for fast LLM inference
  • OpenAI for embeddings API
  • Pinecone for vector database
  • Neon for serverless PostgreSQL
  • Framer Motion for animations

πŸ“§ Contact

Aryan B Parikh


Built with React, Node.js, PostgreSQL, Prisma, Groq, OpenAI, and Pinecone

About

AI Chatbot Bestie3

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages