
Most study material is still a static document. A student reads a PDF, maybe highlights it, and has no way to ask it a question or test themselves on it. Meanwhile teachers spend evenings turning that same material into homework and exams by hand. An AI study platform can close both gaps: take whatever document the student or teacher already has, extract the text, and turn it into a tutor, games and assessments. This post explains how we built one with Google Gemini, OCR and Supabase.
The worked example is Tretech AI Study, a full-stack EdTech platform that serves both individual learners and whole institutions. We will go through the stack, the document pipeline, how the AI features fit together, and what to think about before building your own.
What an AI study platform needs to do
The feature list for Tretech came straight from the two audiences:
- For students: upload PDFs, Word files, images and spreadsheets, chat with an AI tutor about the content, and learn through generated games like Jeopardy and Spin-the-Wheel.
- For educators: manage classes and students, assign materials, generate study guides, homework and exams with AI, and track performance with real-time analytics.
The common thread is that everything starts from an uploaded document. That makes the extraction pipeline the foundation of the entire product. If the text coming out of a scanned worksheet is garbage, the tutor, the games and the exams are all garbage too.
Why we chose React and Supabase for an EdTech platform
Tretech is built on React with TypeScript and Vite, styled with Tailwind CSS and shadcn/ui. Redux Toolkit handles app-wide state, TanStack Query handles server data and caching, React Router manages navigation, and React Hook Form manages the many forms educators use. The application spans 123 React components across 48 pages, so a consistent component library and predictable state were not optional.
On the backend, Supabase gives you four things in one service:
- PostgreSQL for relational data. Classes, students, assignments and results are naturally relational, and Tretech uses 15+ tables.
- Auth for student and educator accounts.
- Storage for uploaded documents.
- Edge Functions for server-side logic. Tretech runs 22 of them.
For a product like this, that combination removes a lot of infrastructure work. You do not need to run your own API server, file store and auth system on day one. The trade-off is that you are building on Supabase's model, so you should design your Postgres row-level security policies carefully from the start. In an education product, a student seeing another student's results is not a minor bug.
We are honest with clients that Supabase is not always the right answer. If you need heavy background processing or complex long-running jobs, a dedicated backend may suit you better. For a React application with relational data and modest server logic, it is a very productive choice. Our custom web development team makes this call case by case.
How to extract text from PDFs and images with OCR
Students upload whatever they have: typed PDFs, Word documents, photos of handouts, and spreadsheets. Tretech uses the OCR.space API to extract text so that scanned and photographed material works as well as born-digital files.
The pipeline follows a standard shape:
- The file is uploaded to Supabase Storage from the React client.
- An Edge Function picks it up and sends it for OCR extraction.
- Extracted text is stored against the document record in Postgres.
- Every downstream AI feature reads from that stored text rather than re-processing the file.
Storing the extracted text once is a simple decision with large effects. It keeps OCR costs predictable, makes the tutor and generators faster, and gives you a single place to fix extraction problems. Running OCR inside an Edge Function also keeps the third-party API key off the client entirely, which is where it belongs.
Building an AI chat tutor with Google Gemini
The AI chat tutor is powered by Google Gemini. The core idea is grounding: the tutor answers questions using the student's uploaded material as context, rather than answering from general knowledge alone. That keeps answers relevant to the actual syllabus and makes the tutor far more useful for revision.
A few principles we would apply to any AI tutor:
- Call the model from the server. In Tretech, AI calls run through Supabase Edge Functions, so API keys never reach the browser and usage can be controlled.
- Ground the prompt in the document. Pass the relevant extracted text with the student's question, and instruct the model to say when the material does not cover something.
- Keep conversation history scoped. A tutor session belongs to a student and a document; do not let context leak between them.
Google's Gemini API documentation is the right starting point for the model side. If you want a broader view of conversational AI design, our guide on how to build an AI chatbot for your website covers grounding and guardrails in more detail.
Generating games, study guides and exams from uploaded documents
The same extracted text feeds the generators. From one document, Tretech can produce:
- Educational games such as Jeopardy and Spin-the-Wheel, which turn review into something students actually want to do.
- Study guides summarizing the key ideas.
- Homework and exams for educators to assign to classes.
The engineering trick here is to ask the model for structured output rather than free text. A Jeopardy board is categories, questions, answers and point values; an exam is a list of questions with answer keys. When the model returns structured JSON, the React frontend can render it reliably as a game or a test, and educators can edit individual questions before assigning them. That editing step matters. AI-generated assessments should be a strong first draft that a teacher reviews, not something that goes to students unchecked.
Classroom management and real-time learning analytics
The educator side turns Tretech from a study tool into a platform institutions can adopt. Teachers can manage classes and students, assign materials, and track student performance through real-time analytics and progress tracking. Because everything lives in Postgres, performance data from games and exams can be queried alongside class membership and assignments, which is what makes useful reporting possible.
The platform is also fully responsive, because a lot of student studying happens on phones. Designing the game interfaces to work at small screen sizes took deliberate effort; it is easy to build a Jeopardy board that only works on a laptop.
What to consider before building an AI study platform
- Extraction quality first. Test OCR on the worst documents your users will upload, not the cleanest.
- Keep humans in the loop. Let educators review and edit generated exams.
- Plan data access early. Student data needs strict per-user and per-class access rules.
- Watch AI costs. Cache extracted text and generated content rather than regenerating on every view.
- Start narrow. A tutor plus one generator is a solid first release; games and analytics can follow. Our post on MVP development cost and timeline covers how to scope that first version.
See the full Tretech AI Study case study, or visit the live platform at tretechacademy.app.
Frequently Asked Questions
Can Google Gemini generate quizzes from a PDF?
Yes. Extract the text from the PDF first, then pass it to Gemini with instructions to return structured questions and answers. Structured output makes it easy to render the result as a quiz, game or exam.
How do you handle scanned documents in an AI study app?
Run them through OCR before any AI processing. Tretech uses the OCR.space API so photographed handouts and scanned pages produce usable text, and stores that text so it is extracted only once.
Is Supabase a good backend for an EdTech platform?
For many EdTech products, yes. Postgres suits relational classroom data, and Auth, Storage and Edge Functions cover most backend needs. Design row-level security carefully so students only ever see their own data.
Should AI-generated exams go straight to students?
We recommend against it. Treat generated exams as a draft that an educator reviews and edits. It keeps quality high and keeps teachers in control of what is assessed.
Planning an AI-powered learning product or adding AI to an existing platform? Our AI integration and automation team can help you scope it honestly. Get in touch and tell us about your learners.
