Skip to content

PREMRAJESH/StudyFLow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š StudyFlow

AI-Powered Study Planner & Productivity Platform

Next.js TypeScript Supabase Gemini AI Tailwind CSS Vercel

StudyFlow transforms how students plan, track, and optimize their study sessions using AI-generated schedules, an intelligent study assistant, and deep productivity analytics.

Live Demo Β· Report Bug Β· Request Feature


πŸ“‹ Table of Contents


✨ Features

Category Feature Description
πŸ€– AI Schedule Generation Smart Scheduling Generates optimized daily study plans using Gemini AI based on subject priority, weekly targets, and syllabus content
πŸ’¬ AI Study Assistant Chat Interface Context-aware AI chatbot that knows your subjects, tasks, and progress to provide personalized study advice
πŸ“Š Analytics Dashboard Progress Tracking Visual charts and statistics showing study hours, weekly progress, completion rates, and study streaks
⏱️ Pomodoro Timer Focus Sessions Integrated Pomodoro timer with subject/task linking, automatic session tracking, and break management
πŸ“ Task Management Smart Tasks Create, prioritize, and track study tasks with due dates, estimated durations, and subject associations
πŸ“š Subject Management Course Organizer Manage subjects with color coding, priority levels, weekly hour targets, and PDF syllabus upload
πŸ“„ Syllabus Parsing PDF Intelligence Upload PDF syllabi for automatic text extraction β€” AI uses this context to generate topic-specific study sessions
πŸ““ Notes Management Document Store Upload and manage study notes with PDF support and text extraction
πŸŒ“ Dark/Light Mode Theme System Full dark mode support with system preference detection
πŸ” Authentication Secure Auth Email/password authentication with Supabase Auth, including signup confirmation flow
πŸ“± Responsive Design Mobile Ready Fully responsive layout optimized for desktop, tablet, and mobile viewports

πŸ›  Tech Stack

Core Framework

Technology Version Purpose
Next.js 16.2 React framework with App Router, RSC, and API routes
React 19 UI library with Server Components
TypeScript 5.7 Type-safe development

Backend & Data

Technology Purpose
Supabase PostgreSQL database, Auth, Row Level Security, Storage
Google Gemini AI gemini-2.5-flash for schedule generation, gemini-2.5-flash-lite for chat
Vercel AI SDK Structured AI output generation (generateText, generateObject)
Zod Runtime schema validation for AI responses

UI & Styling

Technology Purpose
Tailwind CSS 4 Utility-first CSS framework
Radix UI Accessible headless UI primitives
shadcn/ui Pre-built component library
Framer Motion Animations and transitions
Recharts Data visualization and analytics charts
Lucide React Icon library
Geist Font Typography (Sans + Mono)

Utilities

Technology Purpose
pdf-parse PDF text extraction for syllabus processing
react-markdown Markdown rendering in AI assistant
date-fns Date manipulation and formatting
SWR Data fetching and caching
Sonner Toast notifications
React Hook Form Form state management

πŸ— Architecture

The platform architecture follows a modern, decoupled structure utilizing Next.js as the core application engine, Supabase as the backend/database layer, and Google Gemini AI for advanced intelligent services.

StudyFlow System Architecture

πŸ“ View PlantUML / PlantText Code
@startuml StudyFlow_Architecture
!theme slate
skinparam linetype ortho
skinparam PackageStyle rectangle
skinparam shadowing false
skinparam ArrowThickness 2
skinparam ArrowColor #4285F4

package "Client Layer (Frontend)" {
  [Landing Page\n(SSR)] as Landing
  [Dashboard\n(SSR + CSR)] as Dashboard
  [Auth Pages\n(SSR)] as AuthPages
}

package "Next.js App Router (Middleware & API)" {
  [Middleware\n(Session Guard)] as Middleware
  [API Routes\n(/api/*)] as APIRoutes
  [Server Components\n(Data Fetching)] as RSC
}

package "Supabase (Backend-as-a-Service)" {
  [Supabase Auth\n(JWT Tokens)] as SupaAuth
  [PostgreSQL DB\n(RLS Policies)] as DB
  [Storage\n(Syllabi & Notes PDFs)] as Storage
}

package "AI Engine (Google Gemini)" {
  [gemini-2.5-flash\n(Smart Schedule Gen)] as GeminiFlash
  [gemini-2.5-flash-lite\n(Intelligent Study Chat)] as GeminiLite
}

Landing --> Middleware
Dashboard --> Middleware
AuthPages --> Middleware

Middleware --> APIRoutes : Path Guards
Middleware --> RSC : Session Props

APIRoutes --> SupaAuth : Verify Token
APIRoutes --> DB : Mutate Data
APIRoutes --> Storage : Read/Write PDFs

RSC --> DB : Server-side queries

APIRoutes --> GeminiFlash : Structured Output
APIRoutes --> GeminiLite : Streamed Chat
@endum

Authentication Flow

  1. User signs up/in β†’ Supabase Auth issues JWT
  2. Middleware (middleware.ts) refreshes session on every request
  3. Server Components validate user via supabase.auth.getUser()
  4. API routes authenticate requests server-side before processing
  5. Row Level Security (RLS) enforces data isolation at the database level

πŸ“¦ Prerequisites

Requirement Version
Node.js β‰₯ 18.17
pnpm β‰₯ 9.x (recommended) or npm
Supabase Account Free tier
Google AI API Key Get key
Vercel Account Free tier (for deployment)

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/PREMRAJESH/StudyFLow.git
cd StudyFLow

2. Install Dependencies

# Using pnpm (recommended β€” matches CI lockfile)
pnpm install

# OR using npm
npm install

⚠️ Important: This project uses pnpm-lock.yaml as the lockfile. Vercel auto-detects this and uses pnpm for CI builds. Always commit pnpm-lock.yaml after adding/removing dependencies.

3. Configure Environment Variables

cp .env.local.example .env.local

Fill in the values (see Environment Variables below).

4. Set Up the Database

Run the full schema in your Supabase SQL Editor β€” see Database Setup.

5. Start the Development Server

pnpm dev
# or
npm run dev

Open http://localhost:3000 to view the app.


πŸ”‘ Environment Variables

Create a .env.local file in the project root with the following variables:

# ─── Supabase ───────────────────────────────────────────
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key

# ─── Google Gemini AI ───────────────────────────────────
GOOGLE_GENERATIVE_AI_API_KEY=your-google-ai-api-key

Where to Get These Values

Variable Source
NEXT_PUBLIC_SUPABASE_URL Supabase Dashboard β†’ Project β†’ Settings β†’ API β†’ Project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY Supabase Dashboard β†’ Project β†’ Settings β†’ API β†’ anon / public key
GOOGLE_GENERATIVE_AI_API_KEY Google AI Studio β†’ Create API Key

πŸ”’ Security: The NEXT_PUBLIC_ prefix makes variables available client-side. The Supabase anon key is safe to expose β€” it's rate-limited and gated by RLS policies. The GOOGLE_GENERATIVE_AI_API_KEY is server-only and never exposed to the client.


πŸ—„ Database Setup

Quick Setup

  1. Go to your Supabase Dashboard
  2. Select your project β†’ SQL Editor
  3. Paste the entire contents of supabase-schema.sql
  4. Click Run

Schema Overview

The database includes 7 tables with full Row Level Security:

profiles          ← User profiles (auto-created on signup via trigger)
subjects          ← Study subjects with color, priority, syllabus
study_sessions    ← Scheduled/completed study sessions
tasks             ← Study tasks with due dates and priorities
pomodoro_sessions ← Pomodoro timer session tracking
ai_chat_messages  ← AI assistant conversation history
study_goals       ← Long-term study goals with progress tracking
notes_documents   ← Uploaded notes with extracted text

Storage Buckets

Bucket Purpose Max Size MIME Types
syllabi Subject syllabus PDFs 10 MB application/pdf
notes Study notes PDFs 10 MB application/pdf

Key Database Features

  • Row Level Security (RLS): Every table enforces user-level data isolation
  • Auto-profile creation: A Postgres trigger creates a profile row on user signup
  • Computed columns: study_sessions.duration_minutes auto-calculates from start/end times
  • Performance indexes: All tables indexed on user_id and frequently-queried columns

πŸ’» Development

Available Scripts

pnpm dev          # Start development server (Next.js with hot reload)
pnpm build        # Create production build
pnpm start        # Start production server
pnpm lint         # Run ESLint

Code Organization Conventions

  • Server Components are the default β€” used for data fetching in page/layout files
  • Client Components use "use client" directive β€” used for interactivity (forms, timers, etc.)
  • API Routes in app/api/ handle server-side AI processing and data mutations
  • Path aliases use @/* mapping to the project root

🌐 Deployment

Deploy to Vercel (Recommended)

Option A: One-Click Deploy

Deploy with Vercel

Option B: CLI Deploy

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

Option C: Git Integration

  1. Push your code to GitHub
  2. Import the repo in Vercel Dashboard
  3. Vercel auto-detects Next.js and pnpm
  4. Add environment variables in Vercel β†’ Project β†’ Settings β†’ Environment Variables
  5. Deploy πŸš€

Vercel Configuration

Setting Value
Framework Preset Next.js (auto-detected)
Build Command next build (default)
Output Directory .next (default)
Install Command pnpm install (auto-detected from lockfile)
Node.js Version 18.x or 20.x

Required Environment Variables on Vercel

Add these in Vercel β†’ Project β†’ Settings β†’ Environment Variables:

NEXT_PUBLIC_SUPABASE_URL       = https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY  = your-supabase-anon-key
GOOGLE_GENERATIVE_AI_API_KEY   = your-google-ai-api-key

Post-Deployment Checklist

  • Verify all environment variables are set on Vercel
  • Run the database schema in Supabase SQL Editor
  • Configure Supabase Auth β†’ URL Configuration:
    • Site URL: https://your-app.vercel.app
    • Redirect URLs: https://your-app.vercel.app/auth/callback
  • Test signup/login flow end-to-end
  • Test AI schedule generation with at least one subject
  • Verify PDF upload works (Supabase Storage buckets exist)

πŸ“ Project Structure

StudyFlow/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ chat/route.ts              # AI chat assistant endpoint
β”‚   β”‚   β”œβ”€β”€ generate-schedule/route.ts # AI schedule generation endpoint
β”‚   β”‚   β”œβ”€β”€ generate-tasks/            # AI task generation endpoint
β”‚   β”‚   β”œβ”€β”€ upload-syllabus/route.ts   # PDF upload & text extraction
β”‚   β”‚   └── notes/                     # Notes CRUD operations
β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”œβ”€β”€ login/                     # Login page
β”‚   β”‚   β”œβ”€β”€ sign-up/                   # Signup page
β”‚   β”‚   β”œβ”€β”€ sign-up-success/           # Post-signup confirmation
β”‚   β”‚   β”œβ”€β”€ callback/                  # OAuth/email callback handler
β”‚   β”‚   └── error/                     # Auth error page
β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ page.tsx                   # Main dashboard with stats
β”‚   β”‚   β”œβ”€β”€ layout.tsx                 # Sidebar + header layout
β”‚   β”‚   β”œβ”€β”€ analytics/                 # Charts & progress analytics
β”‚   β”‚   β”œβ”€β”€ assistant/                 # AI chat interface
β”‚   β”‚   β”œβ”€β”€ focus/                     # Pomodoro timer page
β”‚   β”‚   β”œβ”€β”€ schedule/                  # Study schedule management
β”‚   β”‚   β”œβ”€β”€ subjects/                  # Subject management
β”‚   β”‚   β”œβ”€β”€ tasks/                     # Task management
β”‚   β”‚   β”œβ”€β”€ notifications/             # Notification center
β”‚   β”‚   └── settings/                  # User preferences
β”‚   β”œβ”€β”€ layout.tsx                     # Root layout (fonts, theme, analytics)
β”‚   β”œβ”€β”€ page.tsx                       # Landing page
β”‚   └── globals.css                    # Global styles & Tailwind config
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ dashboard/                     # Dashboard widgets (overview, streak, etc.)
β”‚   β”œβ”€β”€ focus/                         # Pomodoro timer component
β”‚   β”œβ”€β”€ landing/                       # Landing page sections (hero, features, CTA)
β”‚   β”œβ”€β”€ schedule/                      # Schedule management components
β”‚   β”œβ”€β”€ subjects/                      # Subject CRUD dialogs
β”‚   β”œβ”€β”€ tasks/                         # Task CRUD dialogs
β”‚   β”œβ”€β”€ ui/                            # shadcn/ui base components
β”‚   β”œβ”€β”€ theme-provider.tsx             # next-themes provider
β”‚   └── theme-toggle.tsx               # Dark/light mode toggle
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ ai/errors.ts                   # AI error handling utilities
β”‚   β”œβ”€β”€ supabase/
β”‚   β”‚   β”œβ”€β”€ client.ts                  # Browser Supabase client
β”‚   β”‚   β”œβ”€β”€ server.ts                  # Server Supabase client
β”‚   β”‚   └── middleware.ts              # Auth session refresh middleware
β”‚   β”œβ”€β”€ types.ts                       # TypeScript type definitions
β”‚   └── utils.ts                       # Utility functions (cn, etc.)
β”œβ”€β”€ hooks/                             # Custom React hooks
β”œβ”€β”€ middleware.ts                      # Next.js middleware (auth guard)
β”œβ”€β”€ supabase-schema.sql                # Complete database schema
β”œβ”€β”€ next.config.mjs                    # Next.js configuration
β”œβ”€β”€ tsconfig.json                      # TypeScript configuration
β”œβ”€β”€ postcss.config.mjs                 # PostCSS configuration
β”œβ”€β”€ package.json                       # Dependencies and scripts
└── pnpm-lock.yaml                     # pnpm lockfile (commit this!)

πŸ“‘ API Reference

POST /api/chat

AI-powered study assistant. Requires authentication.

Request:

{
  "messages": [
    { "role": "user", "content": "How should I study for my math exam?" }
  ]
}

Response:

{
  "reply": "Here are some effective strategies for your math exam..."
}

POST /api/generate-schedule

Generates an AI-optimized study schedule for a given day. Requires authentication.

Request:

{
  "date": "2026-05-18",
  "preferences": {
    "studyHoursGoal": 4,
    "startTime": "09:00",
    "endTime": "18:00",
    "sessionLength": 45,
    "breakDuration": 15
  }
}

Response:

{
  "sessions": [
    {
      "id": "uuid",
      "title": "Linear Algebra - Matrix Operations",
      "subject_id": "uuid",
      "start_time": "2026-05-18T09:00:00.000Z",
      "end_time": "2026-05-18T09:45:00.000Z",
      "is_ai_generated": true
    }
  ],
  "reasoning": "Schedule explanation from AI..."
}

POST /api/upload-syllabus

Upload a PDF syllabus for a subject. Extracts text for AI context.

Request: multipart/form-data with file field


POST /api/notes

Upload and manage study notes with PDF text extraction.


πŸ”§ Troubleshooting

Vercel Build: ERR_PNPM_OUTDATED_LOCKFILE

Cause: Dependencies were added to package.json without updating pnpm-lock.yaml.

Fix:

pnpm install
git add pnpm-lock.yaml
git commit -m "chore: sync pnpm lockfile"
git push

Vercel Build: Using wrong pnpm version

Cause: Vercel auto-selects pnpm version based on project creation date.

Fix: Pin the pnpm version via packageManager in package.json:

{
  "packageManager": "pnpm@9.15.0"
}

Or use Corepack:

corepack enable
corepack prepare pnpm@9.15.0 --activate

Auth Redirect Errors

Cause: Supabase redirect URLs not configured for your deployment domain.

Fix:

  1. Go to Supabase Dashboard β†’ Authentication β†’ URL Configuration
  2. Set Site URL to your production URL
  3. Add your domain to Redirect URLs: https://your-app.vercel.app/auth/callback

AI Features Return 401

Cause: Missing or invalid GOOGLE_GENERATIVE_AI_API_KEY.

Fix:

  1. Get a key from Google AI Studio
  2. Add it to Vercel environment variables
  3. Redeploy

AI Schedule Generation Fails

Cause: No subjects added, or Gemini API quota exceeded.

Fix:

  1. Add at least one subject before generating schedules
  2. Check Google AI Studio for quota/usage limits
  3. The gemini-2.5-flash model has generous free-tier limits

Supabase RLS Errors (403)

Cause: Row Level Security policies are blocking access.

Fix:

  1. Ensure you ran the complete supabase-schema.sql (includes all RLS policies)
  2. Verify the user is authenticated before making requests
  3. Check that user_id matches auth.uid() in your insert operations

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'feat: add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


Built with ❀️ by Prem Rajesh

About

πŸ“š AI-powered study planner & productivity platform. Generates optimized study schedules with Google Gemini AI, features an intelligent study chatbot, Pomodoro session tracker, PDF syllabus parser, and deep progress analytics. Built using Next.js 16, Supabase, and Tailwind CSS. πŸš€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors