DEV Community

Cover image for From Chaos to Clarity: How I Built CrammAI, the AI Study Copilot I Wish I Had in University
kareemblessed
kareemblessed

Posted on

From Chaos to Clarity: How I Built CrammAI, the AI Study Copilot I Wish I Had in University

The Spark Behind CrammAI

Back in university, my classmates probably thought I never slept ๐Ÿ˜…. I was always neck-deep in coding projects ๐Ÿ’ป, tinkering with the latest AI tools ๐Ÿค–, and still somehow crushing my exams ๐ŸŽฏ.

But hereโ€™s the truth: my bottleneck wasnโ€™t understanding the concepts ๐Ÿง . I could pick those up fast.

The real struggle was wading through endless PDFs ๐Ÿ“‘, lecture notes ๐Ÿ“, and convoluted study guides ๐Ÿ“˜ just to find the critical info.

Studying for Exams

I kept thinking: โ€œ_If only I had an AI that could automate this process. Something that could ingest all my materials and tell me exactly what to focus on.โ€

Fast forward a few years later โ€” I finally built it. ๐ŸŽ‰

The Aha! Moment

Meet CrammAI โ€” the study co-pilot I wish I had in uni ๐Ÿง‘โ€๐ŸŽ“. Born out of my obsession with automation โšก, it transforms pre-exam chaos into a clear, tactical, and automated study plan ๐Ÿš€.

Hereโ€™s how I built this personal study automation engine.

๐Ÿ› ๏ธ The Tech Stack: My Automation Pipeline

To bring this to life, I needed a stack that was fast, modern, and could seamlessly integrate powerful AI capabilities. The goal was to build an automated content analysis and generation pipeline.

Frontend: React with TypeScript for a dynamic and type-safe user interface.

AI Engine: The Google Gemini API (@google/genai) is the core of the automation. It handles document analysis, topic prioritization, and content generation.

Styling: Good old-fashioned CSS. Clean, simple, and effective.

Step 1: ๐Ÿ•น๏ธ The User Input: Setting the Automation Parameters

Every good automation workflow starts with clear inputs. For CrammAI, the user defines the parameters by choosing a "study mode" based on their timeline. This was crucial because how you study with a week to spare is completely different from how you study the night before.

๐Ÿง˜ Cruise Control (1+ week): Comprehensive, deep-dive automation.
๐Ÿš€ Turbo Mode (~2 days): Strategic automation focusing on high-impact topics.
**โšก Zoom Mode (Due tonight): **A tactical strike plan. The AI automates the process of finding only the absolute must-know concepts for a last-minute cram session.

This initial choice acts as the primary instruction for the AI automation pipeline that follows.
code

Tsx
// Simplified React component for mode selection
const HomePage = ({ onSelectMode }) => (
    <div className="mode-selection">
        {/* The "Zoom Mode" card for last-minute crammers like me! */}
        <div className="mode-card zoom" onClick={() => onSelectMode('zoom')}>
            <div className="mode-icon">โšก</div>
            <h2 className="mode-title">Zoom Mode</h2>
            <p className="mode-description">Due tonight. Maximum focus, maximum efficiency.</p>
        </div>
        {/* Other modes follow the same pattern... */}
    </div>
);
Enter fullscreen mode Exit fullscreen mode

Step 2: ๐Ÿ“ค Automating File Ingestion and Preparation

My AI co-pilot needed to read my study materials. The Gemini API can process various file types, but it requires them in a specific format (base64 encoded strings). To make this seamless, I wrote a helper function to automate the conversion.

This function takes a standard File object from the browser, reads it, and automatically converts it into the JSON structure the Gemini API expects.


Tsx
/**
 * An automated utility to convert a browser File object
 * into the Gemini API's expected Part format.
 */
import { Part } from "@google/genai";

const fileToGenerativePart = (file: File): Promise<Part> => {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => {
      // The result is a Data URL, e.g., "data:image/png;base64,iVBORw..."
      // We automate splitting and extracting the necessary base64 data.
      const base64Data = (reader.result as string).split(',')[1];
      resolve({
        inlineData: {
          mimeType: file.type,
          data: base64Data
        }
      });
    };
    reader.onerror = error => reject(error);
  });
};
Enter fullscreen mode Exit fullscreen mode

Step 3: ๐Ÿง  The Core Automation: AI-Powered Analysis and Planning

This is where the real magic happens. The app sends the user's files and the selected study mode to the Gemini API. The key to successful automation here is enforcing a strict output format.

You canโ€™t build a reliable automation pipeline if you're just hoping the AI gives you good data. The Gemini APIโ€™s responseSchema feature is a lifesaver. It forces the AI to return clean, predictable JSON every single time.

This completely automates the data-parsing step and makes the app incredibly robust.

Tsx
// Inside the main plan generation function
import { GoogleGenAI, Type } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.API_KEY });

// 1. Get user-defined parameters (mode) and prepare files
const prompt = getPromptForMode(mode);
const fileParts = await Promise.all(uploadedFiles.map(fileToGenerativePart));

// 2. Define the automation's output contract (the JSON schema)
const responseSchema = {
    type: Type.OBJECT,
    properties: {
        study_these: {
            type: Type.ARRAY,
            description: "A list of the most critical topics to study.",
            items: { /*... topic, reason, key_points ...*/ }
        }
    }
};

// 3. Trigger the AI automation pipeline
const response = await ai.models.generateContent({
    model: 'gemini-2.5-flash',
    contents: [prompt, ...fileParts],
    config: {
        responseMimeType: 'application/json',
        responseSchema: responseSchema, // Enforce the contract!
    },
});

// 4. The result is clean, structured data, ready for the UI. No messy parsing needed.
const result = JSON.parse(response.text);
setAnalysisResult(result); %}

Enter fullscreen mode Exit fullscreen mode

Step 4: โšก Automating Active Recall: Flashcards & AI Grading

A study plan is just the start ๐Ÿ“…. To really learn, you need active recall ๐Ÿ’ก. CrammAI automates this by generating โ€œFlashcard Sprintsโ€ for each topic ๐Ÿƒ.

But the coolest automation? The grading โœ….

When a user submits an answer, I donโ€™t just do a basic string comparison. Instead, I send both the userโ€™s answer and the correct answer to the Gemini API ๐ŸŒ, asking it to grade for conceptual correctness. This makes the system feel way more intelligent โ€” almost human ๐Ÿค–.

And yes, this is fully automated with a response schema ๐Ÿ“ to guarantee a simple true/false plus clear feedback ๐Ÿ“.

Tsx
// The prompt for the automated AI grader
const prompt = `You are an AI grader. Be lenient with phrasing but strict on the core concept.

**Question:** ${currentCard.question}
**Correct Answer:** ${currentCard.answer}
**User's Answer:** ${userAnswer}

Is the user's answer substantially correct?`;

// The schema for a simple, automated response
const evaluationSchema = {
    type: Type.OBJECT,
    properties: {
        is_correct: { type: Type.BOOLEAN },
        feedback: { type: Type.STRING }
    }
};

// The API call uses this prompt and schema to automate the grading process.
const response = await ai.models.generateContent({ /* ... */ });
const result = JSON.parse(response.text); // e.g., { is_correct: true, feedback: "Spot on!" }

Enter fullscreen mode Exit fullscreen mode

๐Ÿง  CrammAI Features That Make Learning Stick

๐Ÿ“โœจ AI-Generated Cram Notes

Forget dull summaries โ€” this is next-level note-taking. For every high-priority topic, CrammAI creates study notes engineered for rapid learning and retention. Each note is crafted with:

๐Ÿ”Ž Quick Summary: The big idea in just a few sentences.

๐Ÿš€ Key Breakdowns: Complex concepts split into bite-sized, structured chunks.

๐Ÿ’ก Real-World Examples: See how theories work in practice for easier understanding.

**๐Ÿง  Memory Hooks: **Clever metaphors, visuals, or โ€œRemember tipsโ€ to make facts stick.

Itโ€™s like having a world-class tutor turn dense material into simple, usable cheat sheets.

Ai Study Notes Section

๐ŸŽจ The Mnemonic Studio โ€“ Learning Made Fun

Tricky topic? No problem. The Mnemonic Studio creates catchy, memorable acronyms using famous names โ€” cities ๐Ÿ—ฝ, brands ๐Ÿท๏ธ, even celebrities ๐ŸŒŸ.

Instead of random letters, think TESLA โšก for the principles of electromagnetism. Donโ€™t like the first idea? Just say, โ€œMake it based on a movie character!โ€
๐ŸŽฌ Youโ€™ll always get a version that sticks.

The Chat Studio

๐Ÿ’ฌ The Chat Studio โ€“ Your 24/7 AI Tutor

This is your always-available study buddy ๐Ÿค“. Right under your notes, you can ask:

โ€œWhat were the three main points from the Cellular Respiration lecture?โ€

โ€œCan you explain this concept in simpler words?โ€

The AI only pulls from the materials you uploaded ๐Ÿ“š โ€” so answers are accurate, relevant, and tailored to your course.

The Mnemonic Studio Section

โœ… Instant Practice Quizzes (with Explanations!)

Skip boring flashcards โ€” test yourself with smart, interactive quizzes ๐ŸŽฏ. CrammAI automatically generates multiple-choice questions from your notes.

But hereโ€™s the real game-changer: every time you answer, you get instant, clear explanations of why the correct answer is right ๐Ÿ’ก.

Itโ€™s the fastest way to lock knowledge into long-term memory.

Practice Quizz Section

๐Ÿค” Challenges & Lessons Learned

โšก Automation Loves Specificity

Prompt engineering is everything. To get reliable output from the AI, I had to be super precise. My prompts are filled with rules, examples, and format instructions. The more specific the prompt, the better the AI agent performs. ๐ŸŽฏ

๐Ÿ“ Schema is Non-Negotiable

For any serious app, responseSchema is your best friend. It turns the AI from a creative but unpredictable partner into a reliable, deterministic teammate ๐Ÿค.

๐Ÿš€ Conclusion & Next Steps

Building CrammAI was an absolute blast ๐Ÿค–๐Ÿ’ก. Itโ€™s proof that with todayโ€™s tools, you can create powerful automation pipelines for almost anything โ€” even those frantic last-minute cram sessions before exams. ๐Ÿ“š๐Ÿ”ฅ

So whatโ€™s next for my AI study co-pilot?

๐Ÿ’ฌ Conversational Automation โ€“ A chat interface so users can ask things like: โ€œExplain this like Iโ€™m five.โ€

๐ŸŽง Expanding the Pipeline โ€“ Support for video transcripts ๐ŸŽฅ and audio notes ๐ŸŽ™๏ธ.

โšก More Personalization โ€“ Tailored study strategies for different learning styles.

At the end of the day, this project taught me one big lesson: if something feels tedious, automate it. ๐Ÿ› ๏ธโœจ

Dancing
Ever wish AI could just tell you what to study before an exam? Thatโ€™s why I built CrammAI. Check it out ๐Ÿ‘‰ Here!

Soโ€ฆ what could you automate in your own life? ๐Ÿš€

Happy coding, and happy cramming! ๐Ÿ˜Ž๐Ÿ’ป๐Ÿ“–

AI #Automation #MachineLearning #EdTech #TypeScript #ReactJS #GeminiAPI #FrontendDevelopment #PortfolioProject

Top comments (0)