Skip to content

Tareq-Bilal/Mood

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

44 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“” Mood - AI-Powered Journal Application

Next.js React TypeScript Tailwind CSS

A modern, intelligent journaling application with real-time auto-saving and AI-powered mood analysis

Features โ€ข Tech Stack โ€ข Getting Started โ€ข Architecture โ€ข Documentation


๐ŸŒ Live Application

Experience Mood in action:

https://mood-five-sigma.vercel.app/

Click the link above to start journaling with AI-powered mood analysis!


โœจ Features

๐Ÿ”„ Real-Time Auto-Saving

Write without worry! Your journal entries are automatically saved every 200ms after you stop typing.

  • Intelligent Debouncing - Prevents excessive saves while typing
  • Optimistic Updates - Instant UI feedback with save status indicators
  • Content Preservation - Your text never gets lost, even during navigation
  • Visual Feedback - Clear saving/saved status with timestamps

๐Ÿค– AI-Powered Mood Analysis

Powered by Google's Gemini AI, each entry is automatically analyzed to detect:

  • Mood Detection - Identifies emotional state (Happy, Anxious, Calm, etc.)
  • Sentiment Scoring - Quantifies positivity/negativity (-10 to +10 scale)
  • Subject Extraction - Identifies the main topic of your entry
  • Smart Summaries - Generates concise one-line summaries
  • Color Coding - Each mood gets a unique color for visual tracking
  • Negativity Detection - Flags entries with concerning emotional content

๐Ÿ“ Seamless Entry Management

Intuitive interface for creating and managing your journal entries:

  • Instant Creation - Start writing immediately, entry saves on first keystroke
  • Grid View - Beautiful card-based layout of all your entries
  • Quick Navigation - Click any entry to open and edit
  • Entry Counter - Track your journaling consistency
  • Mood Indicators - Visual mood colors on each entry card

๐Ÿ” Secure Authentication

Built with Clerk for enterprise-grade security:

  • User Authentication - Secure sign-up and sign-in
  • Protected Routes - Middleware ensures only authenticated users access journals
  • User Isolation - Each user's data is completely private and separated

๐ŸŽจ Modern UI/UX

Clean, distraction-free writing experience:

  • Dark Theme - Easy on the eyes for any time of day
  • Responsive Design - Works beautifully on desktop, tablet, and mobile
  • Minimalist Editor - Focus on writing without clutter
  • Live Analysis Panel - Real-time mood insights displayed alongside your entry
  • Smooth Animations - Polished micro-interactions throughout

๐Ÿ› ๏ธ Tech Stack

Frontend

Backend & Database

AI & Analysis

  • Google Gemini AI - Advanced language model for mood analysis
  • Custom Prompt Engineering - Optimized prompts for accurate sentiment detection

Authentication

  • Clerk - Complete user management and authentication

Development Tools


๐Ÿš€ Getting Started

Prerequisites

  • Node.js 20+ installed
  • PostgreSQL database (we recommend Neon)
  • Clerk account for authentication
  • Google Gemini API key

Installation

  1. Clone the repository

    git clone https://github.com/Tareq-Bilal/Mood.git
    cd mood
  2. Install dependencies

    npm install
  3. Set up environment variables

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

    # Database
    DATABASE_URL=your_neon_postgres_connection_string
    
    # Clerk Authentication
    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
    CLERK_SECRET_KEY=your_clerk_secret_key
    NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
    NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
    
    # Google Gemini AI
    GEMINI_API_KEY=your_gemini_api_key
  4. Set up the database

    npm run db:push
  5. Run the development server

    npm run dev
  6. Open your browser

    Navigate to http://localhost:3000


Landing Page

Screenshot from 2025-10-29 18-53-53

Journal Listing

image

Realtime Journal Analyzing

Screenshot from 2025-10-29 18-54-59

Auto Saving Feature

Screenshot from 2025-10-29 18-53-10

Ask About Your Journals

image

Journals Chart Aanalysis

image

Bookmarks Listing

image
---

๐Ÿ—๏ธ Architecture

Application Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         User Interface                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚  โ”‚ Journal List โ”‚  โ”‚ Editor Page  โ”‚  โ”‚ Analysis Viewโ”‚      โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     API Routes (Next.js)                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”‚
โ”‚  โ”‚ POST /api/journal    โ”‚  โ”‚ PATCH /api/journal/  โ”‚         โ”‚
โ”‚  โ”‚ (Create Entry)       โ”‚  โ”‚ [id] (Update Entry)  โ”‚         โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ”‚                              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Database (Neon)     โ”‚     โ”‚   Google Gemini AI     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚     โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ JournalEntries  โ”‚  โ”‚     โ”‚  โ”‚ Mood Analysis    โ”‚  โ”‚
โ”‚  โ”‚ JournalAnalysis โ”‚  โ”‚     โ”‚  โ”‚ Sentiment Score  โ”‚  โ”‚
โ”‚  โ”‚ Users           โ”‚  โ”‚     โ”‚  โ”‚ Subject Extract  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚     โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Database Schema

-- Users (managed by Clerk)
Users {
  id: UUID PRIMARY KEY
  clerkUserId: VARCHAR(255) UNIQUE
  email: VARCHAR(255)
  createdAt: TIMESTAMP
  updatedAt: TIMESTAMP
}

-- Journal Entries
JournalEntries {
  id: UUID PRIMARY KEY
  userId: UUID FOREIGN KEY -> Users.id
  content: TEXT
  createdAt: TIMESTAMP
  updatedAt: TIMESTAMP
}

-- AI Analysis Results
JournalAnalysis {
  id: UUID PRIMARY KEY
  entryId: UUID UNIQUE FOREIGN KEY -> JournalEntries.id ON DELETE CASCADE
  mood: VARCHAR(100)
  subject: VARCHAR(255)
  summary: TEXT
  color: VARCHAR(7)  -- Hex color code
  negative: BOOLEAN
  sentimentScore: INTEGER  -- Range: -10 to +10
  createdAt: TIMESTAMP
  updatedAt: TIMESTAMP
}

Key Components

Editor Component (components/Editor.tsx)

The heart of the application, featuring:

  • Real-time auto-save with 200ms debounce
  • State management for new vs. existing entries
  • Optimistic UI updates
  • Smart content preservation during navigation

AI Analysis (utils/ai.ts)

Handles mood detection:

  • Sends entry content to Gemini AI
  • Validates response with Zod schema
  • Returns structured analysis data
  • Error handling for API failures

API Routes

  • POST /api/journal - Creates new entries
  • PATCH /api/journal/[id] - Updates entries and triggers AI analysis
  • Automatic analysis on content changes
  • Efficient database queries with Drizzle ORM

๐Ÿ“– Documentation

Auto-Save Behavior

The auto-save feature intelligently decides when to save:

Should Save When:
โœ“ New entry with content (first save creates the entry)
โœ“ Existing entry with changed content
โœ“ Not already saving

Skip Save When:
โœ— New entry with empty content (no point creating empty entries)
โœ— Existing entry with unchanged content
โœ— Save operation already in progress

AI Analysis Trigger

Analysis runs automatically but efficiently:

Analysis Triggers:
โœ“ Entry content changes
โœ“ Content is not empty

Analysis Skips:
โœ— Content unchanged since last analysis
โœ— Empty content
โœ— API key missing or invalid

State Management Strategy

Component State:
- entryContent: Current textarea value
- entryId: Database ID (null for new entries)
- hasCreated: Boolean flag to prevent re-creation
- isSaving: Visual feedback for save operation
- lastSaved: Timestamp for "Saved at..." message

Refs:
- timeoutRef: Manages debounce timeout
- isCreatingRef: Prevents duplicate creation calls

๐ŸŽฏ Use Cases

Personal Journaling

  • Daily reflections and thoughts
  • Mood tracking over time
  • Identifying emotional patterns

Mental Health Tracking

  • Monitor sentiment trends
  • Flag negative emotional states
  • Track progress in therapy

Creative Writing

  • Brainstorming and ideation
  • Capturing fleeting thoughts
  • Organizing narrative ideas

Professional Logging

  • Work reflections
  • Project retrospectives
  • Learning journal

๐Ÿ”ฎ Future Enhancements

  • Mood Trends Dashboard - Visualize mood changes over time with charts
  • Export Functionality - Download entries as PDF or Markdown
  • Search & Filter - Find entries by mood, date, or keyword
  • Tags & Categories - Organize entries with custom tags
  • Dark/Light Theme Toggle - User preference for appearance
  • Offline Mode - Queue saves when offline, sync when back online
  • Reminders - Push notifications to encourage daily journaling
  • Multiple AI Models - Choice between Gemini, GPT, or Claude
  • Voice Journaling - Speech-to-text for hands-free entries
  • Shared Journals - Collaborate with therapists or partners

๐Ÿค Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

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


๐Ÿ™ Acknowledgments


๐Ÿ“ง Contact

Tareq Bilal - @Tareq-Bilal

Project Link: https://github.com/Tareq-Bilal/Mood


Made with โค๏ธ and โ˜• by Tareq Bilal

โญ Star this repository if you find it helpful!

About

Mood is a simple, intuitive journal app designed to help you track your emotions and reflect on your daily experiences, it just takes being honest with yourself.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors