Skip to content
Umesh-369Public

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

31 Commits

Folders and files

Repository files navigation

πŸŽ“ ExamAI

Next.js Flask Gemini TypeScript Python

ExamAI is a state-of-the-art, AI-powered competitive exam preparation platform designed specifically for students tackling high-stakes engineering exams: JEE Mains, JEE Advanced, GATE, and EAMCET.

By leveraging advanced Gemini models, ExamAI offers an interactive tutoring assistant, dynamic mock test generation, instant question solvers via PDF/Image uploads, similarity-based practice generation, and deep performance diagnostics.


πŸ—οΈ System Architecture

ExamAI splits core logic between a responsive Next.js frontend and an AI-orchestrated Flask backend. The diagram below illustrates how components interact:

graph LR
    %% Styling Definitions
    classDef frontend fill:#eef2ff,stroke:#6366f1,stroke-width:2px,color:#1e1b4b;
    classDef backend fill:#f0fdf4,stroke:#22c55e,stroke-width:2px,color:#14532d;
    classDef ai fill:#faf5ff,stroke:#a855f7,stroke-width:2px,color:#3b0764;
    classDef component fill:#ffffff,stroke:#94a3b8,stroke-dasharray: 4 4,color:#334155;

    subgraph Frontend ["πŸ–₯️ FRONTEND (Next.js & React)"]
        UI("User Interface <br> (Dashboard / Chat / Test)"):::frontend
        Charts(["Performance Charts <br> (Recharts)"]):::component
        Math(["Math Formulator <br> (KaTeX)"]):::component
        
        UI --> Math
        UI --> Charts
    end

    subgraph Backend ["βš™οΈ BACKEND (Flask REST API)"]
        Router("API Blueprint <br> Router"):::backend
        PDF["PDF Text Extractor <br> (pdfplumber)"]:::component
        Img["Image Processor <br> (Pillow)"]:::component
        Env[("Config Loader <br> (.env.local)")]:::component
        
        Router --> Env
        Router --> PDF
        Router --> Img
    end

    subgraph AI ["🧠 AI ENGINE (Google Gemini)"]
        Gemini{"Gemini API <br> (3.1-flash-lite)"}:::ai
    end

    %% Apply Subgraph Styles for Light Mode Aesthetics
    style Frontend fill:#f8fafc,stroke:#cbd5e1,stroke-width:2px,color:#0f172a;
    style Backend fill:#f8fafc,stroke:#cbd5e1,stroke-width:2px,color:#0f172a;
    style AI fill:#f8fafc,stroke:#cbd5e1,stroke-width:2px,color:#0f172a;

    %% Horizontal connections
    UI ==>|"1. REST / SSE Requests"| Router
    Router ==>|"2. Structured Prompts"| Gemini
    Gemini ==>|"3. JSON / SSE Chunks"| Router
    Router ==>|"4. Evaluated Answers"| UI
Loading

✨ Core Features

πŸ’¬ 1. Interactive AI Tutor (Chat)

  • Exam-Specific Personas: Adapts system instructions based on the selected exam (JEE Mains, Advanced, GATE, EAMCET) to customize concept depth and hints.
  • Low-Latency Streaming: Utilizes Server-Sent Events (SSE) stream responses for real-time text delivery.
  • LaTeX Math Rendering: Displays scientific math formulas and equations inline or in display blocks using KaTeX.

πŸ“ 2. Dynamic Mock Test Generator

  • Tailored Tests: Creates customized test papers targeting specific subjects, difficulty levels, and question counts.
  • JSON-Structured Output: Integrates Gemini's Structured Output Mode to serve valid, parsed JSON containing multiple-choice options, correct keys, and explanations.

πŸ”¬ 3. Auto-Evaluation & Performance Diagnostics

  • Syllabus Scoring: Automatically calculates scores according to standard marking schemes (e.g., JEE: +4/-1; GATE: +1/-0.33; EAMCET: +1/0).
  • Weakness Diagnosis: Feeds incorrectly answered questions back to the Gemini model to identify the top 3 specific weak concepts (e.g., Electrostatics, Integration, Kinematics).

πŸ“€ 4. PDF & Image Question Solver

  • Multi-Modal Solving: Parses PDF assignments via pdfplumber or images (PNG, JPEG, WebP) via Gemini Vision API.
  • Step-by-Step Walkthroughs: Provides explanations including concept breakdown, core formulas, and exam tips.

πŸ”„ 5. Similar Question Generator

  • Concept Re-enforcement: Generates 3 customized variants of any selected question with adjusted parameters/values, letting students practice the same concept until mastery.

πŸ› οΈ Tech Stack

Layer Technology Primary Purpose
Frontend Next.js 16 (App Router) Framework & routing architecture
React 19 Component-driven UI rendering
Tailwind CSS v4 Modern, responsive styling system
Framer Motion Premium micro-animations & transitions
Recharts Interactive weakness/strength progression graphs
KaTeX / remark-math Fast, high-quality typesetting of mathematical notation
Backend Flask 3.1.0 Light, scalable Python REST API
Flask-CORS Enforces Cross-Origin Resource Sharing rules
google-generativeai SDK Coordinates with Google's Gemini models
pdfplumber Accurate text extraction from PDF documents
Pillow Multi-modal image analysis preparation

πŸš€ Getting Started

Follow these steps to set up ExamAI locally.

Prerequisites


Step 1: Clone and Configure Environment

In the root of the project, create a file named .env.local and add your Gemini API Key:

GEMINI_API_KEY=your_actual_gemini_api_key_here

Important

The backend automatically searches for .env.local in the root folder, so ensure the path and variable name are exactly as shown.


Step 2: Set Up Backend (Flask)

  1. Navigate to the backend directory:
    cd backend
  2. Create and activate a Python virtual environment:
    # Windows
    python -m venv venv
    .\venv\Scripts\activate
    
    # macOS / Linux
    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Start the server:
    python app.py
    The backend starts running at http://localhost:5000/api/.

Step 3: Set Up Frontend (Next.js)

  1. Open a new terminal in the root directory.
  2. Install npm packages:
    npm install
  3. Start the local development server:
    npm run dev
  4. Open http://localhost:3000 in your browser to view the application.

πŸ”Œ API Endpoints Reference

The Flask backend exposes the following REST/streaming endpoints under the /api prefix:

Endpoint Method Payload (JSON) Description
/health GET None Returns backend status.
/chat POST {"examType": "jee-mains", "message": "..."} Queries the AI Tutor with exam-specific context.
/chat/stream POST {"examType": "gate", "message": "..."} Establishes a server-sent events stream for chat responses.
/generate-test POST {"examType": "gate", "subjects": ["Math"], "difficulty": "hard", "numberOfQuestions": 5} Generates a custom mock test in JSON format.
/submit-test POST {"examType": "jee-advanced", "questions": [...], "userAnswers": [...]} Evaluates test attempts, calculates score, and extracts weak topics.
/upload-question POST FormData containing a file Parses PDF/Image questions and provides step-by-step solutions.
/generate-similar POST {"question": "..."} Returns 3 variations of the input question with options.
/performance POST {"testHistory": [...]} Generates progression data and topic accuracies for graphs.

πŸ“ Directory Structure

exam-ai/
β”œβ”€β”€ backend/                  # Flask REST Service
β”‚   β”œβ”€β”€ routes/               # API Blueprints (chat, evaluation, uploads)
β”‚   β”œβ”€β”€ services/             # Gemini API connector service
β”‚   β”œβ”€β”€ uploads/              # Temporary storage for student documents
β”‚   β”œβ”€β”€ utils/                # PDF parsing scripts
β”‚   β”œβ”€β”€ app.py                # Flask entrypoint
β”‚   β”œβ”€β”€ config.py             # Environment config & AI system instructions
β”‚   └── requirements.txt      # Python dependencies
β”œβ”€β”€ src/                      # Next.js Frontend
β”‚   β”œβ”€β”€ app/                  # Next.js App Router (Layouts & Pages)
β”‚   β”‚   β”œβ”€β”€ (dashboard)/      # Dashboard pages (mock-tests, tutor, performance, results)
β”‚   β”‚   β”œβ”€β”€ (marketing)/      # Landing page / home screen
β”‚   β”‚   └── test-interface/   # Custom UI for active exam attempts
β”‚   β”œβ”€β”€ components/           # Custom UI controls & modules (Tutor chat panel, sidebar)
β”‚   β”œβ”€β”€ lib/                  # Shared utilities (Gemini client, math configuration)
β”‚   └── globals.css           # Global Tailwind CSS definitions
β”œβ”€β”€ .env.local                # Local environment secrets (Shared)
β”œβ”€β”€ package.json              # NPM dependencies & project scripts
└── tsconfig.json             # TypeScript configuration

🀝 Contributing

  1. Fork the repository.
  2. Create a feature branch: git checkout -b feature/NewFeature
  3. Commit your changes: git commit -m 'Add NewFeature'
  4. Push to the branch: git push origin feature/NewFeature
  5. Open a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages