StudyFlow transforms how students plan, track, and optimize their study sessions using AI-generated schedules, an intelligent study assistant, and deep productivity analytics.
- Features
- Tech Stack
- Architecture
- Prerequisites
- Getting Started
- Environment Variables
- Database Setup
- Development
- Deployment
- Project Structure
- API Reference
- Troubleshooting
- Contributing
- License
| 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 |
| 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 |
| 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 |
| 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) |
| 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 |
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.
π 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- User signs up/in β Supabase Auth issues JWT
- Middleware (
middleware.ts) refreshes session on every request - Server Components validate user via
supabase.auth.getUser() - API routes authenticate requests server-side before processing
- Row Level Security (RLS) enforces data isolation at the database level
| 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) |
git clone https://github.com/PREMRAJESH/StudyFLow.git
cd StudyFLow# Using pnpm (recommended β matches CI lockfile)
pnpm install
# OR using npm
npm install
β οΈ Important: This project usespnpm-lock.yamlas the lockfile. Vercel auto-detects this and uses pnpm for CI builds. Always commitpnpm-lock.yamlafter adding/removing dependencies.
cp .env.local.example .env.localFill in the values (see Environment Variables below).
Run the full schema in your Supabase SQL Editor β see Database Setup.
pnpm dev
# or
npm run devOpen http://localhost:3000 to view the app.
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| 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. TheGOOGLE_GENERATIVE_AI_API_KEYis server-only and never exposed to the client.
- Go to your Supabase Dashboard
- Select your project β SQL Editor
- Paste the entire contents of
supabase-schema.sql - Click Run
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
| Bucket | Purpose | Max Size | MIME Types |
|---|---|---|---|
syllabi |
Subject syllabus PDFs | 10 MB | application/pdf |
notes |
Study notes PDFs | 10 MB | application/pdf |
- 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_minutesauto-calculates from start/end times - Performance indexes: All tables indexed on
user_idand frequently-queried columns
pnpm dev # Start development server (Next.js with hot reload)
pnpm build # Create production build
pnpm start # Start production server
pnpm lint # Run ESLint- 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
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel- Push your code to GitHub
- Import the repo in Vercel Dashboard
- Vercel auto-detects Next.js and pnpm
- Add environment variables in Vercel β Project β Settings β Environment Variables
- Deploy π
| 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 |
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
- 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
- Site URL:
- Test signup/login flow end-to-end
- Test AI schedule generation with at least one subject
- Verify PDF upload works (Supabase Storage buckets exist)
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!)
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..."
}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..."
}Upload a PDF syllabus for a subject. Extracts text for AI context.
Request: multipart/form-data with file field
Upload and manage study notes with PDF text extraction.
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 pushCause: 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 --activateCause: Supabase redirect URLs not configured for your deployment domain.
Fix:
- Go to Supabase Dashboard β Authentication β URL Configuration
- Set Site URL to your production URL
- Add your domain to Redirect URLs:
https://your-app.vercel.app/auth/callback
Cause: Missing or invalid GOOGLE_GENERATIVE_AI_API_KEY.
Fix:
- Get a key from Google AI Studio
- Add it to Vercel environment variables
- Redeploy
Cause: No subjects added, or Gemini API quota exceeded.
Fix:
- Add at least one subject before generating schedules
- Check Google AI Studio for quota/usage limits
- The
gemini-2.5-flashmodel has generous free-tier limits
Cause: Row Level Security policies are blocking access.
Fix:
- Ensure you ran the complete
supabase-schema.sql(includes all RLS policies) - Verify the user is authenticated before making requests
- Check that
user_idmatchesauth.uid()in your insert operations
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'feat: add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is open source and available under the MIT License.
