Serenity AI is a comprehensive mental health application designed to support users' emotional well-being through journaling, mood tracking, personalized activities, and AI-powered insights.
- Personalized mood tracking
- Sentiment-aware journaling
- AI-powered emotional insights
- Activity and exercise recommendations
- Gamification of mental wellness
- Emergency support features
https://github.com/Serenity-AI-Chatbot/serenity-ai-frontend
https://github.com/Serenity-AI-Chatbot/serenity-ai-ml
-Interative 3D model of a robot
- Activity tracking
- Mood trends
- Journal insights
- Recommended activities
- AI-powered journaling
- Emotion detection
- Real-time insights
- Tag suggestions
- Personalized suggestions
- Difficulty levels
- Progress tracking
- Achievement system
- Interactive Chat Bot which can be used to talk to the user
- with all the context of the user's mood and journal entries
- Next.js 14
- Tailwind CSS
- Shadcn/UI Components
- Vercel Deployment
- FastAPI Service
- Supabase Authentication & Database
- Google Gemini AI (Embeddings & Language Model)
- Custom ML Model (AWS EC2)
- Spacy & NLTK Models
- Vector Embeddings
- Sentiment Analysis Pipeline
- Supabase Postgres
- Vector Embeddings
- Row Level Security
- Python 3.9+
- Node.js 18+
- Supabase Account
- Google AI Studio API Key
- AWS Account (for EC2)
- Vercel Account (optional)
mental-health-app/
│
├── frontend/ # Next.js Application
│ ├── app/
│ ├── components/
│ ├── lib/
│ └── styles/
│
├── ml-service/ # FastAPI ML Service
│ ├── app/
│ │ ├── main.py
│ │ ├── models/
│ │ │ ├── custom_model.py
│ │ │ └── nlp_models.py
│ │ ├── routers/
│ │ └── utils/
│ └── requirements.txt
│
├── database/ # Supabase Migrations & Functions
│ ├── migrations/
│ └── functions/
│
└── README.md
- Create a new Supabase project
- Enable the
vector
extension - Run database migrations
- Set up Row Level Security (RLS)
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
GEMINI_API_KEY=your_gemini_api_key
ELEVENLABS_API_KEY=your_elevenlabs_api_key
FASTAPI_API_URL=your_fastapi_api_url
- Get API key from Google AI Studio
- Set environment variable
GEMINI_API_KEY=your_gemini_api_key
# Install dependencies
cd frontend
npm install
# Run development server
npm run dev
# Clone repository and navigate to ml-service
git clone <repository-url>
cd mental-health-app/ml-service
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run FastAPI server with PM2
pm2 start "uvicorn app.main:app --host 0.0.0.0 --port 8000"
- Stores user journal entries with AI enhancements
- Fields:
- Basic: id, user_id, title, content
- AI Insights: summary, mood_tags, embedding, keywords
- Metadata: created_at, tags
- Location: nearby_places (JSONB)
- Related Content: latest_articles (JSONB)
- Catalog of wellness activities
- Fields:
- Basic: id, title, description, category
- Difficulty: difficulty_level (beginner/intermediate/advanced)
- Mood Matching: recommended_moods
- Planning: estimated_duration
- Organization: tags
- Tracks user engagement with activities
- Fields:
- References: user_id, activity_id
- Status: planned_at, completed_at, status
- Feedback: difficulty_rating, reflection
sql Function: get_mood_trends(p_user_id UUID) Returns: TABLE (entry_date DATE, mood_categories JSONB, total_entries BIGINT)
- Analyzes mood patterns over time
- Groups mood tags by date
- Aggregates mood frequencies
- Provides total entries per day
sql Function: get_recommended_activities(p_user_id UUID, p_current_mood_tags TEXT[]) Returns: TABLE (activity_id UUID, title TEXT, description TEXT, match_score double precision)
- Recommends activities based on current mood
- Calculates mood-activity match scores
- Uses intersection algorithm for matching
- Returns top 5 matched activities
sql Function: match_journals(query_embedding VECTOR(768), match_threshold FLOAT, match_count INT, user_id UUID) Returns: TABLE (id UUID, content TEXT, summary TEXT, created_at TIMESTAMP, similarity FLOAT)
- Performs semantic search on journal entries
- Uses vector embeddings for similarity
- Supports configurable matching threshold
- Returns matched entries with similarity scores
sql Function: get_dashboard_insights(p_user_id UUID, p_days_back INT DEFAULT 90) Returns: JSONB Comprehensive analytics function providing:
- Journal trends:
- Weekly journal counts
- Mood distribution
- Keyword analysis
- Activity trends:
- Completion rates
- Difficulty ratings
- Category distribution
- Summary insights:
- Total counts
- Most common moods
- Activity engagement
Function: get_journals_by_date
Description: Retrieves journal entries for a specific user, optionally filtered by year and month. This function allows users to fetch their journal entries within a particular time frame, making it easier to review and analyze past entries.
Parameters:
p_user_id UUID
: The unique identifier of the user.p_year INT DEFAULT NULL
: (Optional) The year to filter journal entries.p_month INT DEFAULT NULL
: (Optional) The month to filter journal entries.p_limit INT DEFAULT 50
: (Optional) The maximum number of journal entries to return.
Returns: A table containing the following fields:
id UUID
: The unique identifier of the journal entry.title TEXT
: The title of the journal entry.content TEXT
: The main content of the journal entry.summary TEXT
: An AI-generated summary of the journal entry.mood_tags TEXT[]
: Array of mood tags associated with the entry.tags TEXT[]
: Additional tags for categorization.keywords TEXT[]
: Extracted keywords from the entry.song TEXT
: Link to a related song.created_at TIMESTAMP WITH TIME ZONE
: The timestamp when the entry was created.
Function: get_journal_stats_by_period
Description: Fetches journal entries for a user within a specified date range. This function is useful for generating reports and analytics based on user activity over a particular period.
Parameters:
p_user_id UUID
: The unique identifier of the user.p_start_date DATE
: The start date of the period.p_end_date DATE
: The end date of the period.
Returns: A table containing the following fields:
id UUID
: The unique identifier of the journal entry.title TEXT
: The title of the journal entry.content TEXT
: The main content of the journal entry.summary TEXT
: An AI-generated summary of the journal entry.mood_tags TEXT[]
: Array of mood tags associated with the entry.tags TEXT[]
: Additional tags for categorization.keywords TEXT[]
: Extracted keywords from the entry.song TEXT
: Link to a related song.created_at TIMESTAMP WITH TIME ZONE
: The timestamp when the entry was created.
- Enabled on all main tables:
- journals
- activities
- user_activities
sql Indexes: idx_journals_user_id idx_user_activities_user_id idx_journals_mood_tags (GIN) idx_journals_keywords (GIN) idx_journals_embedding (IVFFLAT)
- Enabled vector extension for semantic search
- Uses 768-dimensional embeddings
- Optimized for similarity searches
- Daily and weekly aggregations
- Mood category distribution
- Trend analysis over time
- Completion rates
- Difficulty progression
- Category distribution
- User engagement metrics
- Semantic search capabilities
- Keyword extraction
- Mood pattern recognition
- Content summarization
- Vector embeddings for semantic search
- Mood prediction from journal content
- Content summarization
- Keyword extraction
- Location-based recommendations
- Related article suggestions
- Activity recommendations
- Uses CTEs for complex analytics
- Efficient date-based grouping
- Indexed text search capabilities
- Vector similarity optimization
- Weekly rollups for trends
- Efficient JSON aggregation
- Optimized mood analysis
- Smart activity matching
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit changes (
git commit -m 'Add some AmazingFeature'
) - Push to branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
For issues, please open a GitHub issue or contact [email protected] or [email protected]
- Multi-language support
- Advanced machine learning models
- Integration with health tracking devices