Skip to content

aniruddhabagal/MindMate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

64 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  MindMate

A modern, privacy-first mental wellness companion that helps you take meaningful steps toward better mental health.

Live Demo Built with Next.js Styled with Tailwind License

๐ŸŒŸ Overview

MindMate is a comprehensive mental wellness platform designed with simplicity, privacy, and accessibility at its core. Built using modern web technologies, it provides users with practical tools for stress management, emotional awareness, and personal reflection without the friction of complex interfaces.

๐Ÿš€ Live Demo: mindmate.aniruddha.fyi

โœจ Features

Core Functionality

  • ๐ŸŽฏ Advanced Mood Tracking - Comprehensive mood logging with:
    • Visual trend charts with customizable time periods (7, 30, 90 days)
    • Mood streak tracking and statistics
    • Mood score analytics (1-10 scale)
    • Recent entries overview with emoji indicators
  • ๐Ÿง˜ Interactive Breathing Exercises - Guided breathing animation with:
    • 4-4-6-2 breathing pattern (inhale-hold-exhale-hold)
    • Visual circle animation for breathing guidance
    • Start/stop controls with smooth transitions
  • ๐Ÿ“ Complete Journaling System - Feature-rich journaling with:
    • Rich text entries with title and content
    • Daily writing prompts for inspiration
    • Full CRUD operations (Create, Read, Update, Delete)
    • Entry editing with confirmation modals
  • ๐Ÿค– Advanced AI Chat Integration - Powered by Google's Gemini AI:
    • Multi-session chat management
    • Session title editing and organization
    • Context-aware mental wellness responses
    • Crisis detection and professional help redirection
    • Credit-based usage system
  • ๐Ÿ‘ฅ Admin Dashboard - Comprehensive user management:
    • User listing with pagination
    • Credit management and role assignment
    • Blacklisting capabilities for moderation
    • Real-time user statistics

Technical Features

  • ๐Ÿ” JWT Authentication - Secure token-based authentication system
  • ๐Ÿ›ก๏ธ Middleware Protection - Route-level security for API endpoints
  • ๐Ÿ“Š Data Visualization - Chart.js integration for mood analytics
  • โšก Real-time Updates - Dynamic UI updates without page refreshes
  • ๐ŸŽจ Modern UI/UX - Tailwind CSS with gradient backgrounds and animations
  • ๐Ÿ“ฑ Mobile-First Design - Responsive layout with mobile-optimized components
  • ๐Ÿ”ง Modular Architecture - Clean separation of components and API logic

๐Ÿ› ๏ธ Tech Stack

Core Technologies

  • Framework: Next.js 14+ (App Router)
  • Runtime: React 18+
  • Styling: Tailwind CSS + PostCSS
  • Language: JavaScript (with JSX)
  • Authentication: JWT with jose library
  • Database: MongoDB (via connection models)
  • AI Integration: Google Gemini API (@google/generative-ai)
  • Charts: Chart.js for data visualization
  • Notifications: react-hot-toast for user feedback
  • Linting: ESLint with custom configurations
  • Package Manager: npm / pnpm / yarn / bun

Key Integrations

  • Google Gemini AI - Advanced conversational AI for mental health support
  • Chart.js - Interactive mood tracking visualizations
  • JWT Authentication - Secure user sessions and API protection
  • MongoDB - Persistent data storage for users, moods, and journal entries

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ (LTS recommended)
  • Package manager of choice (npm, pnpm, yarn, or bun)
  • Git for version control

Installation

# Clone the repository
git clone https://github.com/aniruddhabagal/MindMate.git
cd MindMate

# Install dependencies (choose one)
npm install
# or
pnpm install
# or
yarn install
# or
bun install

# Start the development server
npm run dev
# or
pnpm dev
# or
yarn dev
# or
bun dev

Open http://localhost:3000 in your browser to see the application.

Environment Setup

Create a .env.local file in the project root:

# Basic Configuration
NEXT_PUBLIC_SITE_URL=http://localhost:3000
NEXT_PUBLIC_APP_NAME=MindMate

# JWT Configuration (Required)
JWT_SECRET=your-super-secure-jwt-secret-key-here

# MongoDB Configuration (Required)
MONGODB_URI=mongodb://localhost:27017/mindmate
# or for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/mindmate

# Google Gemini AI Configuration (Required for Chat)
GEMINI_API_KEY=your-google-gemini-api-key-here

# Optional: Additional Configuration
NODE_ENV=development

Security Notes:

  • Never commit .env* files to version control
  • Use strong, unique JWT secrets in production
  • Store sensitive API keys securely

๐Ÿ“ Project Structure

MindMate/
โ”œโ”€โ”€ app/                    # Next.js App Router (pages, layouts, API routes)
โ”‚   โ”œโ”€โ”€ admin/             # Admin dashboard page
โ”‚   โ”‚   โ””โ”€โ”€ page.js        # User management interface
โ”‚   โ”œโ”€โ”€ api/               # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ admin/         # Admin-only endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ auth/          # Authentication endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ chat/          # AI chat functionality
โ”‚   โ”‚   โ”œโ”€โ”€ journal/       # Journal CRUD operations
โ”‚   โ”‚   โ””โ”€โ”€ moods/         # Mood tracking endpoints
โ”‚   โ”œโ”€โ”€ globals.css        # Global styles and animations
โ”‚   โ”œโ”€โ”€ layout.js          # Root layout component
โ”‚   โ””โ”€โ”€ page.js            # Main application page
โ”œโ”€โ”€ components/            # Reusable UI components
โ”‚   โ”œโ”€โ”€ BreathingModal.js  # Interactive breathing exercise component
โ”‚   โ”œโ”€โ”€ ChatPage.js        # Multi-session chat interface
โ”‚   โ”œโ”€โ”€ ConfirmationModal.js # Reusable confirmation dialog
โ”‚   โ”œโ”€โ”€ Header.js          # Application header with user menu
โ”‚   โ”œโ”€โ”€ HomePage.js        # Dashboard with quick actions
โ”‚   โ”œโ”€โ”€ JournalPage.js     # Full-featured journaling interface
โ”‚   โ”œโ”€โ”€ Loader.js          # Loading spinner component
โ”‚   โ””โ”€โ”€ MoodTrackerPage.js # Analytics and mood visualization
โ”œโ”€โ”€ lib/                  # Utility functions and configurations
โ”‚   โ”œโ”€โ”€ apiClient.js      # API communication functions
โ”‚   โ”œโ”€โ”€ formatters.js     # Date, mood, and data formatting
โ”‚   โ”œโ”€โ”€ geminiClient.js   # Google Gemini AI configuration
โ”‚   โ””โ”€โ”€ mongodb.js        # Database connection setup
โ”œโ”€โ”€ models/               # MongoDB data schemas
โ”‚   โ”œโ”€โ”€ User.js           # User account model
โ”‚   โ”œโ”€โ”€ Mood.js           # Mood entry model
โ”‚   โ”œโ”€โ”€ Journal.js        # Journal entry model
โ”‚   โ””โ”€โ”€ ChatSession.js    # Chat session model
โ”œโ”€โ”€ public/               # Static assets
โ”‚   โ”œโ”€โ”€ images/           # Image assets
โ”‚   โ””โ”€โ”€ favicon.ico       # Application icon
โ”œโ”€โ”€ middleware.js         # JWT authentication middleware
โ”œโ”€โ”€ next.config.mjs       # Next.js configuration
โ”œโ”€โ”€ tailwind.config.js    # Tailwind CSS configuration
โ”œโ”€โ”€ postcss.config.js     # PostCSS configuration
โ”œโ”€โ”€ eslint.config.mjs     # ESLint configuration
โ”œโ”€โ”€ package.json          # Dependencies and scripts
โ””โ”€โ”€ README.md             # This file

Key Directories Explained

  • app/ - Next.js App Router with single-page application structure
  • app/api/ - RESTful API endpoints with JWT authentication middleware
  • components/ - Feature-complete UI components (Chat, Journal, Mood Tracker, etc.)
  • lib/ - Core utilities including API client, AI integration, and data formatting
  • models/ - MongoDB schemas for Users, Moods, Journal entries, and Chat sessions
  • middleware.js - JWT verification and role-based access control

๐Ÿ“œ Available Scripts

Script Description
npm run dev Start development server on http://localhost:3000
npm run build Build the application for production
npm run start Start the production server
npm run lint Run ESLint to check code quality
npm run lint:fix Run ESLint and automatically fix issues
npm run type-check Run TypeScript compiler to check types

๐Ÿ—๏ธ Development Guidelines

Code Standards

  • Components: Functional components with hooks-based state management
  • Styling: Utility-first approach with Tailwind CSS classes
  • State Management: React state with useCallback/useMemo for optimization
  • API Design: RESTful endpoints with consistent error handling
  • Authentication: JWT-based with middleware protection
  • Database: MongoDB with proper schema validation

Component Architecture

// Example component structure
"use client"; // For client-side components

import { useState, useEffect, useCallback } from "react";
import toast from "react-hot-toast";

export default function Component({ currentUser, apiClient, ...props }) {
  const [state, setState] = useState(initialValue);
  const [isLoading, setIsLoading] = useState(false);

  const handleAction = useCallback(async () => {
    setIsLoading(true);
    try {
      // API call logic
      const result = await apiClient.someAPI();
      // Update state
      setState(result);
      toast.success("Action completed!");
    } catch (error) {
      console.error("Error:", error);
      toast.error(`Error: ${error.message}`);
    } finally {
      setIsLoading(false);
    }
  }, [apiClient]);

  // Component JSX with proper loading states and error handling
  return (
    <div className="component-wrapper">
      {/* Component content */}
    </div>
  );
}

API Endpoint Pattern

// app/api/example/route.js
import { NextResponse } from "next/server";
import { connectDB } from "@/lib/mongodb";
import Model from "@/models/Model";

export async function GET(request) {
  try {
    const userId = request.headers.get("x-user-id"); // Set by middleware
    await connectDB();
    
    const data = await Model.find({ userId });
    return NextResponse.json(data);
  } catch (error) {
    console.error("API Error:", error);
    return NextResponse.json(
      { message: "Internal server error" },
      { status: 500 }
    );
  }
}

๐Ÿ”ฎ Roadmap

Planned Features

  • User Profile Management - Complete profile editing and preferences
  • Data Export - Export mood and journal data in various formats
  • Advanced Analytics - Weekly/monthly mood reports and insights
  • Reminder System - Customizable notifications for check-ins
  • Goal Setting - Personal wellness goals with progress tracking
  • Community Features - Anonymous peer support groups (optional)
  • Integration APIs - Connect with fitness trackers and health apps
  • Offline Support - Progressive Web App capabilities
  • Multi-language Support - Internationalization (i18n)
  • Advanced AI Features - Personalized recommendations and insights

Technical Improvements

  • TypeScript Migration - Gradual conversion to TypeScript
  • Enhanced Testing - Unit and integration test coverage
  • Performance Monitoring - Real-time performance metrics
  • Advanced Security - Rate limiting and enhanced data protection
  • CI/CD Pipeline - Automated testing and deployment
  • Docker Support - Containerized deployment options
  • Database Optimization - Indexing and query optimization
  • API Documentation - OpenAPI/Swagger documentation

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

Getting Started

  1. Fork the repository
  2. Clone your fork locally
  3. Create a feature branch (git checkout -b feature/amazing-feature)
  4. Install dependencies and run the development server
  5. Make your changes following our coding standards
  6. Test your changes thoroughly
  7. Commit using conventional commit format
  8. Push to your branch (git push origin feature/amazing-feature)
  9. Open a Pull Request with a clear description

๐Ÿ“š Key Features Deep Dive

๐ŸŽฏ Mood Tracking System

  • Visual Analytics: Interactive Chart.js graphs showing mood trends
  • Smart Statistics: Automatic calculation of streaks, averages, and dominant moods
  • Flexible Timeframes: View data for last 7, 30, or 90 days
  • Score-Based System: 1-10 mood scoring with emoji representations

๐Ÿค– AI-Powered Chat

  • Google Gemini Integration: Advanced conversational AI specifically trained for mental wellness
  • Multi-Session Management: Organize conversations with editable titles
  • Crisis Detection: Automatic detection of crisis language with professional help redirection
  • Context Awareness: AI remembers conversation context within sessions
  • Credit System: Usage-based system to manage AI costs

๐Ÿ“ Advanced Journaling

  • Rich Text Editor: Title and content fields with formatting preservation
  • Writing Prompts: Daily inspiration prompts to encourage reflection
  • Full CRUD Operations: Create, read, update, and delete entries seamlessly
  • Confirmation System: Safe deletion with confirmation modals

๐Ÿง˜ Breathing Exercises

  • 4-4-6-2 Pattern: Scientifically-backed breathing rhythm for relaxation
  • Visual Guidance: Animated circle that scales with breathing phases
  • Smooth Animations: CSS transitions for calming visual experience

๐Ÿ‘ฅ Admin Dashboard

  • User Management: View and edit user accounts with pagination
  • Credit Management: Adjust user credits and monitor usage
  • Role Assignment: Promote users to admin or manage permissions
  • Moderation Tools: Blacklist users who violate terms of service

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Aniruddha Bagal

๐Ÿ™ Acknowledgments

  • Thanks to the mental health community for inspiration
  • Next.js team for the amazing framework
  • Tailwind CSS for the utility-first approach
  • All contributors who help make MindMate better

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Join our community discussions
  4. Contact the maintainer directly

Made with โค๏ธ by Aniruddha Bagal

Building technology for better mental wellness, one commit at a time.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors