📘 FocusFlow AI — Smart Productivity & Routine Intelligence
FocusFlow AI is a smart productivity dashboard designed to help students optimize their time, track habits, and receive AI-powered study recommendations — all in one place.
It integrates:
✔ Task Management
✔ Daily Routine Logging
✔ Productivity Analytics
✔ AI Recommendations (Ollama + fallback system)
✔ Google OAuth Login
✔ Supabase Database
✔ Beautiful React + Tailwind UI
✔ Real-time charts & insights
🚀 Features 🔹 1. Smart Task Manager
Add, edit, categorize tasks
Priority levels (low/medium/high)
Tracks completion & auto-saves completion timestamps
Dynamic weekly task completion graph
🔹 2. Daily Routine Tracking
Log daily habits:
Wake time
Sleep time
Study duration
Exercise
Screen time
Number of breaks
Notes
Stored in routine_logs table.
🔹 3. AI Productivity Engine
Using Ollama (local LLM) with a rule-based fallback, the system analyzes:
Study time habits
Sleep quality
Screen exposure
Weekly consistency
Generates:
Productivity score
Focus score
A personalized recommendation
Stored in productivity_scores table for history tracking.
🔹 4. Google OAuth Authentication
Fully integrated using Supabase Auth Providers. Secure sign-in with Google.
🔹 5. Dynamic Dashboard
Shows real-time:
Total, completed, pending tasks
Today’s study time
Weekly charts:
Task completions
Study duration
AI Insights (productivity + focus score)
🧱 Tech Stack Frontend
React (Vite)
TypeScript
Tailwind CSS
ShadCN UI Components
Lucide Icons
Recharts (graphs & charts)
Backend
Supabase (Auth, DB, RLS)
PostgreSQL
Supabase Policies for User-level Access
AI
Ollama (local LLM)
Rule-based productivity fallback
AI Recommendation Framework
🗄 Database Schema Overview tasks Column Type Description id uuid primary key user_id uuid FK → auth.users title text task title description text optional category text custom labels priority text low/medium/high duration int estimated minutes deadline date due date status text pending/completed completed_at timestamptz automatically saved created_at timestamptz default now() updated_at timestamptz default now() routine_logs Column Type id uuid user_id uuid log_date date wake_time time sleep_time time study_duration integer exercise_minutes integer screen_time integer breaks_taken integer notes text created_at timestamptz productivity_scores Column Type id uuid user_id uuid log_date date productivity_score int focus_score int recommendation text created_at timestamptz 🔐 Supabase Setup 1️⃣ Create a Supabase Project
2️⃣ Add Tables
Run SQL:
(You already have this — included here for completeness.)
-- tasks table ALTER TABLE tasks ADD COLUMN completed_at timestamptz;
-- productivity scores CREATE TABLE IF NOT EXISTS productivity_scores ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE, log_date date NOT NULL, productivity_score int, focus_score int, recommendation text, created_at timestamptz DEFAULT now(), UNIQUE (user_id, log_date) );
3️⃣ Enable Row Level Security ALTER TABLE tasks ENABLE ROW LEVEL SECURITY; ALTER TABLE routine_logs ENABLE ROW LEVEL SECURITY; ALTER TABLE productivity_scores ENABLE ROW LEVEL SECURITY;
4️⃣ Add Policies
Example:
create policy "Users can insert their own tasks" on tasks for insert with check (auth.uid() = user_id);
Repeat for UPDATE/SELECT/DELETE where needed.
🔧 Environment Variables
Create .env:
VITE_SUPABASE_URL="https://xxxxx.supabase.co" VITE_SUPABASE_PUBLISHABLE_KEY="your-anon-key" VITE_OLLAMA_URL="http://localhost:11434"
Restart the dev server after setting environment variables.
🤖 AI Recommendation System
Path: src/services/aiRecommendations.ts
✔ Pulls last 7 days of routines ✔ Calculates averages ✔ Generates:
productivity score
focus score
recommendation text
✔ Tries Ollama first POST http://localhost:11434/api/generate
✔ If Ollama is offline → fallback rule-based productivity logic. ✔ Saves to Supabase (productivity_scores) 🏗 Project Structure src/ ├─ components/ │ ├─ Navigation.tsx │ └─ ui/ ├─ pages/ │ ├─ Dashboard.tsx │ ├─ Tasks.tsx │ ├─ AddTask.tsx │ ├─ Routine.tsx │ ├─ RoutineHistory.tsx │ └─ Auth.tsx ├─ services/ │ └─ aiRecommendations.ts <-- AI Engine ├─ integrations/ │ └─ supabase/ │ └─ client.ts ├─ hooks/ │ └─ use-toast.ts └─ App.tsx
Run development server npm run dev
Access: http://localhost:8080
🌐 OAuth Setup (Google)
In Supabase:
Go to Authentication → Providers → Google
Enable Google Sign-In
Add callback:
https://your-project-id.supabase.co/auth/v1/callback
Add keys to .env
🧪 Testing AI Locally (Ollama) Install:
Pull a model: ollama pull llama3
Test: curl http://localhost:11434/api/tags
If you see model list → OK. 📈 Future Improvements (Optional)
AI weekly performance summaries
Calendar-based routine timeline
Pomodoro timer with productivity scoring
Focus mode blocker
Study streaks system
Offline mode
Mobile app (Expo)
🤝 Contributing
Fork the repository
Create a feature branch
Commit changes
Open a Pull Request
Follow coding standards (ESLint + TS)
📄 License
MIT License — free to use, modify, and distribute.
⭐ Made with passion for students & productivity. Enjoy FocusFlow AI!