
Overview
StudyUp is a study workspace with a planner and a Geminitutor that answers from the course material you’ve added.
The Problem
A student’s semester is spread across five tools that don’t know about each other. The syllabus is a PDF in the course portal, deadlines are in a calendar, notes are in a notebook app, slides are in a cloud drive, and whatever does the explaining is a general-purpose chatbot in another tab.
That last one is the real gap. A generic assistant can explain Fourier series in the abstract, but it has no idea what your lab handout asks for, when it’s due, or what your professor called the thing. So you paste the handout in, lose the conversation when the tab closes, and do it again next week. The help exists; it’s just never attached to the coursework it’s meant to help with.
Four Hours
StudyUp started at the Lovable x Roam International Hackathon, hosted by UTMIST. The team found the idea at the Myhal Centre, looking back at their own late nights and how scattered their studying had become. With under four hours left, they committed to one product: a single place to organise academic life, with help from Gemini that could see all of it.
Most of that first version was built through Lovable, the event’s sponsor, from prompts, and 127 of the repository’s commits are Lovable’s. It was pitched to a panel of industry judges and won the hackathon overall.
What a four-hour build doesn’t have is anything behind the demo. The tutor function accepted requests from any origin and fetched whatever URL it was handed, course files sat in a public bucket, and nothing capped what one account could spend on Gemini. That was the right trade for a weekend and the wrong one for real coursework, which is what most of this page is about.
The Rule
The model proposes, and the student decides. Nothing Gemini writes lands in your workspace until you put it there.
A study plan arrives as a proposal with its reasoning, and reaches the planner only when you add it. A summary sits beside your note instead of replacing it. A tutor conversation is gone when you leave unless you save it, to the assignment you choose. That matters more in a study tool than almost anywhere: the workspace should reflect what you actually understand, and if a model could quietly fill it in, it would stop being a reliable record of where you are.
The Workspace
Everything hangs off a course: its code and description, its assignments with due dates and a completion state, and its materials, slides, handouts, readings, and images, uploaded to the course or to a single assignment. The dashboard rolls it up into what’s due this week and what’s done.
When a PDF is uploaded, its text is extracted in the browser with pdf.js, up to a hundred pages, and stored with the file. The tutor can read the material later without the server ever parsing a document, and a scanned PDF with no text layer simply arrives with nothing to read instead of failing the upload.
ECE216
Signals and Systems
Continuous- and discrete-time signals, LTI systems, convolution, Fourier series and transforms.
Assignments
Problem Set 4: Convolution
Due 9/26/2026
Lab 3: Fourier Series
Due 9/30/2026
Course Materials
ECE216 Course Outline
Problem Set 4 handout
Lecture 9: Fourier Series
Uploading · 0%
The Tutor
Open the tutor from an assignment and it already knows where you are: the course, the assignment and its description, the handout, and the course’s other materials. A banner says exactly how much it can see, down to the number of documents, so you never wonder whether it read the handout. Images go along as images, so a photographed whiteboard or a circuit diagram is something Gemini looks at, not a filename it’s told about.
That’s what makes the answer about your lab instead of the topic. Ask why the overshoot won’t go away and it explains the Gibbs phenomenon, then points at the four values of N your handout asks you to measure. Answers render as Markdown and type out as they appear, and a conversation can be saved to an assignment, where it waits on that page next time.
StudyUp Tutor
Powered by Gemini
Course context is connected
The tutor can reference 2 course and 1 assignment material for “Lab 3: Fourier Series”.
Study Plans and the Planner
Any assignment with a due date can become a plan. The server reads the assignment and up to five of its materials under your own permissions, asks Gemini for a JSON schedule, then checks what came back. Every session has to parse, run between thirty minutes and two hours, and land before the deadline. A plan with even one session after the due date is rejected outright, not quietly repaired, because a plan that’s almost right about a deadline is worse than none.
Generated Study Plan for “Lab 3: Fourier Series”
Here is a suggested study plan. Review it and add it to your planner if it looks good.
Pre-lab derivation
Sep 21, 10:00 AM · 90 mins
MATLAB synthesis
Sep 23, 11:00 AM · 120 mins
Gibbs overshoot
Sep 25, 10:00 AM · 60 mins
Write up the report
Sep 28, 4:00 PM · 90 mins
Every session checks out.
Add to PlannerAccepted sessions land in the planner, a week grid beside your assignments’ due dates. Select one and the sidebar shows what it’s for and which assignment it came from, where it can be completed, edited, or deleted. The grid works from the keyboard and by touch, not only with a mouse.
September 2026
Convolution review
Signals and Systems
Pre-lab derivation
Signals and Systems
Gibbs overshoot
Signals and Systems
MATLAB synthesis
Signals and Systems
Power series
Calculus II
Series convergence
Calculus II
Heap operations
Data Structures
Build-heap proof
Data Structures
MATLAB synthesis
Description
For assignment: “Lab 3: Fourier Series”
The Notebook
Notes are tagged and can belong to a course, with search and filtering by either. One click summarises a note into a short paragraph of its key ideas, shown on the card rather than written into the note. Each note keeps one current summary; early versions created a new one every time, so the rebuild removed the duplicates and added a unique index so it can’t happen again.
Fourier series intuition
Signals and Systems
A periodic signal is a weighted sum of harmonics. The analysis equation picks out each weight…
Generate AI SummaryHeaps
Data Structures and Analysis
Array-backed complete binary tree. Build-heap is O(n) because most nodes are near the bottom.
Generate AI SummaryConvergence tests
Calculus II
Ratio test: L < 1 converges. Compare to p-series when terms look like 1/n^p.
Generate AI SummaryArchitecture
StudyUp has no application server of its own. The front end is a static React 19 app built with Vite and served from Vercel, with TanStack Query handling data. Everything behind it is Supabase: Postgres, Auth, Storage, and two Deno Edge Functions that talk to Gemini.
Web
A static React 19 app built with Vite and served from Vercel. It holds only a publishable key anyone can read.
Postgres
Row-level security on every table decides who sees each row, with ownership checked across tables.
Storage
A private bucket, 20 MB a file, with uploads checked against the course in the path and downloads through hour-long signed URLs.
Edge Functions
Two Deno functions, the only code that holds the Gemini key: one for the tutor, one for study plans.
That shape makes the security model simple to state and easy to get wrong. The browser holds a publishable key anyone can read out of the JavaScript, so the key can’t be what protects anything. The database has to decide, on every row, who may see it, and only server code may hold the Gemini key.
Access
Row-level security is the authorisation boundary. Every table has policies keyed to the signed-in user, and ownership is checked across tables, not just on the row in front of you: a note can only point at a course you own, a study session only at your course, a saved chat only at your assignment. Those checks run through two helpers, is_course_owner and is_course_owner_for_assignment, pinned to an empty search path so they can’t be redirected at a lookalike table.
Files follow the same rule. The materials bucket is private and capped at 20 MB a file, and its policies read the object’s path, so an upload into a course folder is only allowed if you own that course. Downloads go through signed URLs that expire after an hour.
Edge Functions
The two Edge Functions now treat every request as hostile until proven otherwise. A caller must present a real user session, not just the public key. Bodies are read with a 100 KB ceiling enforced while streaming, messages and context have hard lengths, and CORS answers only the exact production origins plus one narrow, HTTPS-only pattern for preview deployments. Anything unrecognised fails closed.
Images were the subtle one. The hackathon version fetched whatever URL the browser sent, a server-side request forgery waiting to happen. Now an image has to come from this project’s own Storage, over HTTPS, with redirects refused, a ten-second timeout, and the 5 MB limit enforced on the bytes actually read, not on a header that claims a size.
A photo from the student's own upload
https://abcd.supabase.co/storage/v1/object/sign/materials/…/whiteboard.jpg- https
- this project's host
- a Storage object path
- no redirects
- answers within 10 s
- an image, 5 MB read at most
const fetchSupabaseImage = async (rawUrl: string, supabaseUrl: string) => {
const imageUrl = new URL(rawUrl);
const projectUrl = new URL(supabaseUrl);
if (
imageUrl.protocol !== "https:" ||
imageUrl.hostname !== projectUrl.hostname ||
!imageUrl.pathname.startsWith("/storage/v1/object/")
) {
throw new HttpError(400, "Images must come from this project's Supabase Storage");
}
const response = await fetch(imageUrl, {
redirect: "error",
signal: AbortSignal.timeout(10_000),
});
const contentType = response.headers.get("content-type")?.split(";")[0];
if (!response.ok || !contentType?.startsWith("image/")) {
throw new HttpError(400, "Could not load a valid image");
}
// The 5 MB cap is enforced on the bytes read, not the declared length.
return { contentType, bytes: await readLimitedBody(response) };
};supabase/functions/chat-with-gemini/index.ts — an image is only fetched from the project's own Storage.
The key moved too. It used to ride in the request URL, where URLs end up in logs; now it goes in a header. The model is configuration, not code, and every Gemini call runs under a thirty-second deadline.
Quotas
Every Gemini call costs money, and a public sign-up form means anyone can make an account. So each user gets 30 tutor messages an hour and 200 a day, and 10 study plans an hour and 40 a day, enforced in Postgres rather than in the function.
chat-with-gemini · this hour
30 an hour and 200 a day per user, counted in Postgres
-- Serialize quota consumption for one user/function pair. This prevents two
-- concurrent requests from both observing the final available slot.
PERFORM pg_catalog.pg_advisory_xact_lock(
pg_catalog.hashtextextended(v_user_id::text || ':' || p_function_name, 0)
);
IF v_hour_count >= v_hour_limit THEN
RETURN QUERY SELECT false, 0, v_hour_start + interval '1 hour';
RETURN;
END IF;
INSERT INTO public.ai_usage_windows
(user_id, function_name, window_type, window_start, request_count)
VALUES
(v_user_id, p_function_name, 'hour', v_hour_start, 1),
(v_user_id, p_function_name, 'day', v_day_start, 1)
ON CONFLICT (user_id, function_name, window_type, window_start)
DO UPDATE SET request_count = public.ai_usage_windows.request_count + 1;supabase/migrations/20260730010000_ai-usage-quotas.sql — one user, one function, one caller at a time.
The lock is what matters. Two requests arriving together would otherwise both read the last free slot and both get through; serialising on a per-user, per-function advisory lock makes the check and the increment one step. The usage table is invisible to users, and if the quota check fails for any reason, the function refuses with a 503 instead of letting the call through unmetered.
Verification
Security that lives in database policies is only as good as the tests that replay them. Every migration is replayed against a disposable local Supabase stack, and 71 pgTAP assertions check the schema, row-level security, storage rules, tenant isolation, and quotas. Integration tests then sign in as two users and confirm neither can see the other’s courses, and upload a private file and download it back to compare the exact bytes.
The rest is layered to match. Vitest covers components and hooks with 100% thresholds on the pure utilities, Deno tests cover request parsing, CORS, and quota handling, and Playwright runs the product across Chromium, Firefox, WebKit, a Pixel, and an iPhone. It fails on console errors, accessibility regressions, horizontal overflow down to 320 pixels, offline-state bugs, and drift from a reviewed visual baseline. Performance has a budget too: bundle ceilings, a 125 KB stylesheet cap, and a load test that must hold a 500 ms p95.
Changes reach production through a permanent staging branch, and merging to main needs seven independent checks. Actions are pinned to commits, secrets are scanned on push, and live verification runs against a deployment with two dedicated low-privilege accounts, so the cross-user checks can never silently skip.
Design
The hackathon build looked like what it was: stock components, a Lovable favicon, and a slightly different idea of spacing on every page. The redesign pulled it into one navigation shell, one page header, and one set of actions, with the brain mark carrying through the landing page, the tutor, and the primary buttons.
It’s built for the laptop on a library desk first, and on a phone the sidebar folds into a rail of icons instead of disappearing. The tutor’s typing stops when the system asks for reduced motion, and the accessibility and layout checks in CI keep contrast, labelling, and narrow screens correct as pages change.
Decisions
Harden it, don't rewrite it
The product that won worked, and a room of judges understood it from a single pitch. Rewriting it would have spent the effort on the part that was already right, so the rebuild kept the interface and replaced what sat underneath it: policies, functions, quotas, tests, and deployment.
Extraction in the browser
PDFs are read on the student’s own machine, once, at upload. The server never parses an untrusted document, and the text is there for every later question. The cost is coverage: PDFs and plain text are read, while Word and PowerPoint files are stored for download without the tutor being able to see inside them.
Staging shares production's database
Supabase branching is not on the current plan, so the staging deployment runs against the main project, with row-level security and dedicated test accounts keeping users apart. The isolated topology is written down in the repo, but it is not live, and the docs say so rather than implying a separation that does not exist.
What’s Next
Retrieval comes next. The tutor sends each connected material whole, and a question’s context is capped at 50,000 characters, so a course with a long lecture PDF can push every question over the limit. Picking out the relevant passages fixes that, cuts the cost of each answer, and lets the tutor say which page an answer came from.
Then streaming. Answers are generated in full and typed out afterwards, which looks live without being live; a real stream would put the first words on screen as soon as Gemini has them. Reading Word and PowerPoint files, and a staging database of its own once the plan allows, round out the list.