Skip to content

harsh-vardhan3/day-book

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“– DayBook

A modern, AI-powered journaling application that helps you track your thoughts, emotions, and memories. Built with the MERN stack, featuring automatic mood detection, writing streaks, collaboration tools, and insightful analytics.

Live Demo: https://day-book-swart.vercel.app


✨ Features

🧠 Smart Journaling

  • AI-Powered Mood Detection: Automatic sentiment analysis detects your emotional state from entry content
  • Writing Streaks: Build consistency with daily streak tracking and motivational stats
  • Favorites: Mark important memories and filter them easily
  • Word Count & Reading Time: Automatic calculation for each entry

πŸ“Š Analytics & Insights

  • Mood Analytics: Visualize emotional patterns over time with interactive charts
  • Calendar View: Monthly grid showing all entries with mood indicators
  • Sentiment Tracking: Track emotional intensity and comparative scores

🀝 Collaboration

  • Share Entries: Share journal entries with friends or family
  • Real-time Comments: Add comments to shared entries with live updates
  • Permission Control: Grant view or edit access to collaborators
  • Live Collaboration: Socket.io powered real-time updates

🎨 User Experience

  • Responsive Design: Seamless experience across all devices
  • Dark/Light Themes: Multiple theme options with DaisyUI
  • Search Functionality: Quick search across all entries
  • Export Options: Download entries in JSON, Text, or Markdown formats

πŸ”’ Security

  • JWT Authentication: Secure HTTP-only cookie-based auth
  • Password Encryption: bcrypt password hashing
  • Protected Routes: Role-based access control
  • CORS Protection: Configured for production security

πŸ› οΈ Tech Stack

Frontend

  • Framework: React 19.0.0
  • State Management: Redux Toolkit 2.6.1 with RTK Query
  • Routing: React Router 7.2.0
  • Styling: TailwindCSS 4.0.9 + DaisyUI 5.0.0
  • Charts: Recharts for analytics visualization
  • Icons: React Icons 5.5.0
  • Notifications: React-Toastify 11.0.5
  • Build Tool: Vite

Backend

  • Runtime: Node.js with Express.js 4.21.1
  • Database: MongoDB with Mongoose 8.8.3
  • Authentication: JWT 9.0.2 with bcryptjs
  • Real-time: Socket.io 4.8.1
  • AI/ML: Sentiment analysis (sentiment 5.0.2)
  • Validation: Validator.js

πŸ“ Project Structure

daybook/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── database.js              # MongoDB connection
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”‚   β”œβ”€β”€ authController.js        # Authentication logic
β”‚   β”‚   β”‚   β”œβ”€β”€ userController.js        # User profile operations
β”‚   β”‚   β”‚   β”œβ”€β”€ entryController.js       # CRUD + sentiment analysis
β”‚   β”‚   β”‚   └── collaborationController.js # Sharing & comments
β”‚   β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”‚   └── authMiddleware.js        # JWT verification
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ userModel.js             # User schema (with streaks)
β”‚   β”‚   β”‚   β”œβ”€β”€ entryModel.js            # Entry schema (with sentiment)
β”‚   β”‚   β”‚   └── commentModel.js          # Comment schema
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ userRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ entryRoutes.js
β”‚   β”‚   β”‚   └── collaborationRoutes.js
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ generateToken.js
β”‚   β”‚   β”‚   └── sentimentAnalyzer.js     # AI mood detection
β”‚   β”‚   └── index.js                     # Server entry + Socket.io
β”‚   β”œβ”€β”€ .env.example
β”‚   └── package.json
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ entry/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AddEntry.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EditEntry.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ DeleteEntry.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EntryCard.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ReadMore.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ CalendarView.jsx     # Monthly calendar
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ExportEntries.jsx    # Export functionality
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ MoodAnalytics.jsx    # Charts & graphs
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ShareDialog.jsx      # Sharing UI
β”‚   β”‚   β”‚   β”‚   └── Comments.jsx         # Comment section
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.jsx          # With streak stats
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Password.jsx
β”‚   β”‚   β”‚   β”‚   └── Logout.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ navbar/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ NavLinks.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ NavProfile.jsx
β”‚   β”‚   β”‚   β”‚   └── SearchBox.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ StreakDisplay.jsx        # Writing streak counter
β”‚   β”‚   β”‚   β”œβ”€β”€ ThemeController.jsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx                 # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Entries.jsx              # All entries + filters
β”‚   β”‚   β”‚   β”œβ”€β”€ SharedEntries.jsx        # Collaborative entries
β”‚   β”‚   β”‚   β”œβ”€β”€ About.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   └── Signup.jsx
β”‚   β”‚   β”œβ”€β”€ redux/
β”‚   β”‚   β”‚   β”œβ”€β”€ store.js
β”‚   β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ apiSlice.js
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ entriesApiSlice.js
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ usersApiSlice.js
β”‚   β”‚   β”‚   β”‚   └── collaborationApiSlice.js
β”‚   β”‚   β”‚   └── features/
β”‚   β”‚   β”‚       └── userSlice.js
β”‚   β”‚   └── App.jsx
β”‚   β”œβ”€β”€ .env.example
β”‚   └── package.json
β”‚
β”œβ”€β”€ COLLAB_SETUP.md                      # Collaboration feature docs
β”œβ”€β”€ SENTIMENT_SETUP.md                   # Sentiment analysis docs
└── README.md

πŸš€ Installation

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB Atlas account or local MongoDB
  • npm or yarn

Backend Setup

  1. Clone the repository:
git clone https://github.com/harsh-vardhan3/day-book.git
cd day-book/backend
  1. Install dependencies:
npm install
  1. Create .env file:
NODE_ENV=development
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key
FRONTEND_URL=http://localhost:5173
  1. Start the server:
npm run dev

Backend runs on http://localhost:3000

Frontend Setup

  1. Navigate to frontend:
cd ../frontend
  1. Install dependencies:
npm install
  1. Create .env file:
VITE_API_URL=http://localhost:3000
  1. Start the development server:
npm run dev

Frontend runs on http://localhost:5173


🌐 Deployment

Backend (Render)

  1. Create a new Web Service on Render
  2. Connect your GitHub repository
  3. Configure:
    • Root Directory: backend
    • Build Command: npm install
    • Start Command: npm start
  4. Add environment variables:
    • NODE_ENV=production
    • PORT=5000
    • MONGO_URI=<your_mongodb_atlas_uri>
    • JWT_SECRET=<random_secure_string>
    • FRONTEND_URL=<your_vercel_url>

Frontend (Vercel)

  1. Import project on Vercel
  2. Configure:
    • Root Directory: frontend
    • Framework: Vite
  3. Add environment variable:
    • VITE_API_URL=<your_render_backend_url>
  4. Deploy

πŸ“‘ API Endpoints

Authentication

  • POST /api/auth/signup - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/logout - Logout user
  • PATCH /api/auth/password - Update password

Entries

  • GET /api/entries - Get all user entries
  • POST /api/entries - Create new entry (with sentiment analysis)
  • GET /api/entries/:id - Get single entry
  • PATCH /api/entries/:id - Update entry
  • DELETE /api/entries/:id - Delete entry
  • GET /api/entries/search?q=query - Search entries
  • PATCH /api/entries/:id/favorite - Toggle favorite status

User

  • GET /api/users/profile - Get user profile (with streak stats)
  • PATCH /api/users/profile - Update profile

Collaboration

  • POST /api/collaboration/share/:entryId - Share entry
  • GET /api/collaboration/shared - Get shared entries
  • POST /api/collaboration/comments/:entryId - Add comment
  • GET /api/collaboration/comments/:entryId - Get comments

🎯 Key Features Implementation

Sentiment Analysis

Automatic mood detection using natural language processing:

  • Analyzes entry title + content
  • Assigns mood emoji (πŸ˜„ πŸ™‚ 😐 πŸ˜” 😒)
  • Calculates sentiment score, intensity, and comparative metrics
  • Stored in database for analytics

Writing Streaks

Gamified consistency tracking:

  • Increments on consecutive days
  • Resets on missed days
  • Tracks longest streak
  • Displayed in navbar and profile

Real-time Collaboration

Socket.io powered features:

  • Live comment notifications
  • User online status
  • Entry sharing events
  • Instant UI updates

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages