StudyFlow is a production-quality, modern AI-powered study planner application built with FastAPI, MongoDB Atlas, Google Gemini AI, and a React + TypeScript + Vite + Tailwind CSS frontend.
It helps college students and technical learners turn subjects, exam deadlines, and available daily study hours into customized, day-by-day learning roadmaps and track their mastery.
-
Authentication & Multi-Tenant Security
- User registration and login with bcrypt password hashing.
- Stateless JWT Bearer token authentication.
- Strict data isolation ensuring users can only ever access their own subjects and study plans.
-
Subject Management (CRUD)
- Create, list, inspect, update, and delete courses/subjects.
- Configurable deadlines (ISO dates) and daily available study hours.
- Cascading cleanup of associated plans upon subject deletion.
-
AI-Powered Structured Study Plan Generation
- Seamless integration with Google Gemini via the official
google-genaiSDK. - Strict Pydantic response schema validation ensuring AI output is deterministic, structured, and never violates daily study duration caps.
- Day-by-day breakdowns with concrete topic titles, actionable descriptions, and time estimates.
- Seamless integration with Google Gemini via the official
-
Task & Progress Tracking
- Interactive topic/task completion toggle with real-time recalculated progress percentages.
- Automated completion status aggregation per day and overall plan.
-
AI Concept Explainer
- Instant tutor assistance for difficult concepts with analogies, real-world code/use-case examples, and key takeaways.
- Direct 1-click shortcuts from any topic in a study plan to the AI explainer.
-
Responsive, Modern UI/UX
- Clean, light aesthetic with subtle borders, smooth micro-animations, accessible labels, empty states, and loading spinners.
- Fully responsive for mobile, tablet, and desktop viewports.
graph TD
Client[React + TypeScript + Vite + Tailwind CSS]
API[FastAPI Backend Application]
Auth[JWT Security & Bcrypt]
DB[(MongoDB Atlas / Motor Async)]
Gemini[Google Gemini AI Engine]
Client -->|REST API over JSON| API
API -->|Verify Token & Authenticate| Auth
API -->|Async Non-blocking Queries| DB
API -->|Structured Schema Generation| Gemini
- Python 3.12+ / 3.14
- FastAPI: Modern, high-performance async REST API framework with automatic Swagger OpenAPI documentation.
- Motor / PyMongo: Async non-blocking MongoDB driver.
- Pydantic v2 & Pydantic Settings: Request/response validation and environment config.
- PyJWT & Bcrypt: Password hashing and token security.
- Google GenAI SDK (
google-genai): Official Gemini API integration. - Pytest & Pytest-Asyncio & HTTPX: Comprehensive automated unit and integration testing suite.
- React 18 & TypeScript
- Vite: Ultra-fast frontend build tooling and dev server.
- Tailwind CSS: Utility-first styling with custom palette and component tokens.
- React Router DOM: Client-side single-page app routing and protected routes.
- Axios: HTTP client with request interceptors for token management.
- Lucide React: Clean, modern icons.
- Vitest & React Testing Library: Component and form validation test suite.
studyflow/
βββ backend/
β βββ app/
β β βββ core/ # App configuration, DB connection & security
β β β βββ config.py
β β β βββ database.py
β β β βββ security.py
β β βββ dependencies/ # Auth and user session dependencies
β β β βββ auth.py
β β βββ models/ # Data models
β β βββ routers/ # API endpoints (health, auth, subjects, plans, ai)
β β β βββ health.py
β β β βββ auth.py
β β β βββ subjects.py
β β β βββ plans.py
β β β βββ ai.py
β β βββ schemas/ # Pydantic validation schemas
β β β βββ auth.py
β β β βββ subject.py
β β β βββ plan.py
β β β βββ ai.py
β β βββ services/ # External service wrappers
β β β βββ gemini_service.py
β β βββ main.py # FastAPI entrypoint & middleware
β βββ tests/ # Pytest test suite
β β βββ conftest.py
β β βββ test_health.py
β β βββ test_database.py
β β βββ test_auth.py
β β βββ test_subjects.py
β β βββ test_gemini.py
β β βββ test_plans.py
β β βββ test_ai.py
β βββ requirements.txt
β βββ pytest.ini
β βββ .env.example
βββ frontend/
β βββ src/
β β βββ components/ # Reusable UI components (Button, Input, Card, Navbar, etc.)
β β βββ hooks/ # useAuth context hook
β β βββ layouts/ # MainLayout wrapper
β β βββ pages/ # Pages: Login, Register, Dashboard, Subjects, SubjectDetail, PlanDetail, Explain
β β βββ services/ # Axios API client
β β βββ test/ # Vitest & React Testing Library suites
β β βββ types/ # TypeScript definitions
β β βββ App.tsx # Route configuration
β β βββ main.tsx
β β βββ index.css
β βββ package.json
β βββ vite.config.ts
β βββ tsconfig.json
β βββ tailwind.config.js
β βββ .env.example
βββ docs/
β βββ architecture.md
βββ .gitignore
βββ README.md
- Python 3.12+ (tested on Python 3.14)
- Node.js 18+ and npm
- MongoDB Atlas connection string (or local MongoDB server)
- Google Gemini API Key
cd backend
# Create virtual environment & activate
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your MONGODB_URL and GEMINI_API_KEY
# Start development server
uvicorn app.main:app --reload --port 8000Backend will be live at http://localhost:8000.
- Swagger Interactive Documentation:
http://localhost:8000/api/docs - Health Check:
http://localhost:8000/health
cd ../frontend
# Install dependencies
npm install
# Configure environment variables
cp .env.example .env
# Start development server
npm run devFrontend will be live at http://localhost:5173.
cd backend
source .venv/bin/activate
pytest -vcd frontend
npm run testcd frontend
npm run build| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/health |
API Health Check | No |
POST |
/api/auth/register |
Register new user account | No |
POST |
/api/auth/login |
Login and obtain JWT Bearer token | No |
GET |
/api/auth/me |
Fetch authenticated user profile | Yes |
POST |
/api/subjects |
Create a new study subject | Yes |
GET |
/api/subjects |
List subjects for current user | Yes |
GET |
/api/subjects/{id} |
Get subject details | Yes |
PATCH |
/api/subjects/{id} |
Update subject | Yes |
DELETE |
/api/subjects/{id} |
Delete subject and its plans | Yes |
POST |
/api/subjects/{id}/generate-plan |
Generate AI study plan with Gemini | Yes |
GET |
/api/plans |
List study plans for current user | Yes |
GET |
/api/plans/{id} |
Get detailed study plan roadmap | Yes |
DELETE |
/api/plans/{id} |
Delete study plan | Yes |
PATCH |
/api/plans/{id}/topics/{topicId}/complete |
Mark topic complete | Yes |
PATCH |
/api/plans/{id}/topics/{topicId}/uncomplete |
Mark topic incomplete | Yes |
PATCH |
/api/tasks/{taskId}/complete |
Mark task complete by ID | Yes |
PATCH |
/api/tasks/{taskId}/uncomplete |
Mark task incomplete by ID | Yes |
POST |
/api/ai/explain |
Explain concept with AI tutor | Yes |
FastAPI provides native asynchronous I/O (async/await), automatic Pydantic request/response data validation, and built-in interactive OpenAPI/Swagger documentation. For an AI application where network calls to AI APIs and databases are I/O bound, FastAPI's async runtime ensures high throughput without blocking threads.
Study plans are hierarchical, document-oriented structures (a plan contains days, and days contain topics/tasks). MongoDB naturally stores and indexes hierarchical documents without expensive relational table joins, while allowing flexible queries and atomic sub-document updates with array filters.
Google Gemini provides industry-leading reasoning performance and native structured JSON schema output support (response_schema), allowing us to enforce strict Pydantic schemas so that AI output is always valid JSON matching our exact domain structure.
- The user registers with name, email, and password. The password is encrypted with a unique salt using
bcrypt. - Upon login, credentials are verified and a signed JWT access token containing the user's ID as subject (
sub) and an expiration timestamp is returned. - The frontend stores this token and includes
Authorization: Bearer <token>on subsequent API calls. - FastAPI's
get_current_userdependency decodes and verifies the JWT signature on every protected route.
The React frontend triggers actions through typed Axios services in src/services/api.ts. The request passes through FastAPI routers, where Pydantic schemas validate types. The business logic executes asynchronously against MongoDB Atlas using motor, ensuring strict user_id filtering.
We enforce a multi-layer validation pipeline:
- Gemini is given a strict JSON schema via Pydantic model (
StudyPlanGeneratedSchema). - The response is parsed and checked with Pydantic
model_validate. - Post-validation algorithms check that topic durations do not exceed the student's daily available study hours.
- Only fully validated plans are transformed and stored in MongoDB.
- Ensuring AI Output Quality: Prevented hallucinations and invalid time allocations by designing structured schema prompts and auto-scaling topic minutes to fit within the user's daily budget.
- Strict Data Isolation: Implemented query scoping across every database query ensuring zero cross-tenant data leaks.
- Graceful Error Resilience: Implemented fallback model handling and sanitized error responses so internal stack traces or API keys are never exposed.