A modern, intelligent journaling application with real-time auto-saving and AI-powered mood analysis
Features โข Tech Stack โข Getting Started โข Architecture โข Documentation
Experience Mood in action:
https://mood-five-sigma.vercel.app/
Click the link above to start journaling with AI-powered mood analysis!
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
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
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
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
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
- Next.js 16 - React framework with App Router and Server Components
- React 19.2 - Latest React with concurrent features
- TypeScript - Type-safe development
- Tailwind CSS 4 - Utility-first styling
- Lucide React - Beautiful icon library
- Drizzle ORM - TypeScript-first ORM
- Neon PostgreSQL - Serverless Postgres database
- Zod - Schema validation for AI responses
- Google Gemini AI - Advanced language model for mood analysis
- Custom Prompt Engineering - Optimized prompts for accurate sentiment detection
- Clerk - Complete user management and authentication
- Drizzle Kit - Database migrations
- ESLint - Code quality
- PostCSS - CSS processing
- Node.js 20+ installed
- PostgreSQL database (we recommend Neon)
- Clerk account for authentication
- Google Gemini API key
-
Clone the repository
git clone https://github.com/Tareq-Bilal/Mood.git cd mood -
Install dependencies
npm install
-
Set up environment variables
Create a
.env.localfile 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
-
Set up the database
npm run db:push
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
---
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 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 โ โ
โ โโโโโโโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ
-- 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
}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
Handles mood detection:
- Sends entry content to Gemini AI
- Validates response with Zod schema
- Returns structured analysis data
- Error handling for API failures
- 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
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 progressAnalysis 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 invalidComponent 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- Daily reflections and thoughts
- Mood tracking over time
- Identifying emotional patterns
- Monitor sentiment trends
- Flag negative emotional states
- Track progress in therapy
- Brainstorming and ideation
- Capturing fleeting thoughts
- Organizing narrative ideas
- Work reflections
- Project retrospectives
- Learning journal
- 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
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Next.js by Vercel
- AI powered by Google Gemini
- Authentication by Clerk
- Database by Neon
- Icons by Lucide
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!