Inspiration

We've all been there staring at a dense PDF the night before an exam, wishing someone would just explain it to you. Study groups are scattered across WhatsApp, Discord, and random Google Docs. There's no single place where students can study together, get instant AI help, quiz themselves, and actually track whether they're learning. Brainspark was born from that frustration the idea that studying should be social, intelligent, and actually kind of fun.

What it does

Brainspark is an all-in-one AI-powered study platform. Here's what a student can do: Upload & Learn — Drop in a PDF and Brainspark reads it, extracts key topics, and lets you generate quizzes instantly. You choose the difficulty (easy/medium/hard), question type (multiple choice or theory/essay), and even which topics to focus on. AI Tutor (Ask-AI) — Ask any academic question in plain English. The AI responds like a knowledgeable friend — with structured explanations, interactive diagrams for visual concepts (physics, biology, chemistry), and even suggests a YouTube video to watch. You can attach images of your notes or handwritten problems and it'll analyze those too. Study Buddies — Find other students studying at your level, in your country, or from your school. Send connection requests, build your academic network. Group Chat & Collaboration — Create or join study groups. Chat in real time, share images, voice notes, and PDFs. Tag @BrainAI in any group message to get an instant AI answer right inside the chat. Brainstorm Sessions — Inside a group, the host can upload a PDF and run a live multiplayer quiz for everyone — questions appear in real time, members answer simultaneously, scores get reported back to the host. Tutor Rooms — A dedicated space where a designated tutor can post lesson notes, expand them with AI, run live quizzes, grade assignments, and chat with students. Dashboard & Progress Tracking — See your quiz history, average scores, daily performance chart, and how many connections you've made. Notifications & Web Push — Real-time in-app notifications for connection requests, quiz launches, reactions, and BrainAI replies — plus browser push notifications so you never miss a study session.

How we built it

The backend is a Flask (Python) application backed by PostgreSQL in production (with SQLite for local dev). We used SQLAlchemy as our ORM across roughly 20+ models — users, quizzes, quiz results, groups, messages, notifications, assignments, polls, and more. The AI layer runs on Google Gemini 2.5 Flash — both a text model and a vision model — which powers question generation, the AI tutor, BrainAI group replies, lesson expansion, and live quiz creation. We wrote detailed, structured system prompts to make the tutor behave like a real teacher, with subject-specific guidance for Physics, Chemistry, Biology, Maths, History, and Literature. Email is handled via Brevo (transactional emails for verification and password resets). Push notifications use VAPID/WebPush. Sessions are filesystem-persisted with 30-day lifetimes. File uploads (images, PDFs, voice notes) are stored both on disk and as base64 in the database for resilience. We deployed on Render, with environment variable guards that prevent the app from starting if critical keys (Google AI, Brevo, Secret Key) are missing.

Challenges we ran into

Keeping AI responses fresh and non-repetitive was harder than expected. We had to hash the source PDF and track every previously generated question in the database, filtering duplicates before returning anything to the user. Real-time multiplayer quizzes without WebSockets was a genuine puzzle. Since we're on a standard Flask/Postgres stack with no Socket.IO, we solved it with a polling model — quiz events (question start, reveal answer, end) are written as special GroupMessage records, and members poll an endpoint every second to pick them up. It works surprisingly well. Structured AI output parsing was fragile at first — Gemini would sometimes wrap JSON in markdown code fences or add commentary before the JSON. We hardened every single parser with find('{') / rfind('}') extraction and fallback error handling so the app never crashes on a bad AI response. Session management at scale — filesystem sessions worked fine locally but needed careful configuration (signing, 30-day TTL, threshold limits) to behave reliably on Render and also money for everything to finally work, for the AI token for the Deployment server and so on and forth

Accomplishments that we're proud of

Built a genuinely full-featured product — auth, social graph, real-time group chat, AI tutoring, live multiplayer quizzes, tutor rooms, and a notification system — all in a single hackathon sprint. The AI tutor system prompt is really thoughtful — it knows to explain Physics intuitively before introducing formulas, to tell History as a story, and to always relate Biology to the human body. It even embeds interactive SVG diagrams for visual concepts. The @BrainAI mention feature inside group chat feels magical — you're mid-conversation with friends and you just tag the AI like a person.

What we learned

Gemini's vision model handles handwritten notes and diagram images remarkably well — significantly better than we expected. Database design matters early. We ended up with 20+ models and if we hadn't been disciplined about foreign keys and relationships from day one, the group chat + notification + quiz systems would have become unmaintainable. Prompting is engineering. Half our AI quality comes from the system prompts, not the model itself. Subject-specific instructions, formatting rules, and tone guidelines all measurably improve output. Maintenance mode and startup guards sound like polish they're actually essential when you're deploying to production mid-hackathon and something breaks.

What's next for Brainspark

Real-time with WebSockets — replace polling with Socket.IO for instant quiz synchronization and live cursors in brainstorm sessions. Spaced repetition — surface questions the user got wrong at scientifically-optimal review intervals, using the WrongAnswer and MasteryProgress models we've already built. Mobile apps — the PWA foundation (VAPID push, responsive design) is already there; native iOS/Android is the next step. Peer tutoring marketplace — let students offer paid tutoring sessions within the platform, using the Tutor Room infrastructure. Analytics for educators — give tutors dashboards showing class-wide mastery gaps, common wrong answers, and engagement trends.

Share this project:

Updates