Skip to content

Latest commit

Β 

History

1,566 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ OpenPrep AI

License: MIT PRs Welcome Contributor Covenant Hacktoberfest

OpenPrep AI is an advanced AI-powered exam preparation platform designed to help students optimize their study habits, analyze previous exam papers, identify knowledge gaps, and study smarter.

Explore Architecture β€’ Getting Started β€’ Contribution Guidelines β€’ API Documentation β€’ Socket.IO Events


🎯 Problem Statement

Most students waste critical preparation hours trying to figure out:

  • What chapters hold the highest exam weightage?
  • Which questions are repeatedly asked?
  • How to schedule daily study topics effectively?
  • Where their weak points lie?

OpenPrep AI resolves these frustrations by utilizing advanced LLMs (Gemini API) and data-driven learning strategies (spaced repetition, adaptive planning) to structure their preparation path automatically.


✨ Features

  • πŸ“„ PDF & Notes Analysis: Extract core themes, chapter summaries, and revision points from academic uploads.
  • πŸ“Š PYQ Intelligence: Parse Previous Year Question Papers (PYQs) to map chapter weightage, extract repeated questions, and detect trends.
  • 🧠 AI Quiz Generator: Dynamically generate MCQ assessments based on custom uploaded notes or specific syllabus topics.
  • πŸ“… Smart Study Planner: Input your exam date, syllabus scope, and study hours to generate a customized, calendarized study schedule.
  • 🎯 Weakness Detection: Tracks performance across quiz attempts to dynamically highlight weak subjects and adapt study goals.
  • πŸ“š Spaced Repetition Flashcards: Memorize complex concepts using flashcards backed by the SuperMemo SM-2 adaptation algorithm.

πŸ› οΈ Tech Stack

Component Technologies Used
Frontend React, Vite, Tailwind CSS, Redux Toolkit, React Router
Backend Node.js, Express.js, JWT Authentication
Database PostgreSQL, Sequelize ORM
AI Integration Gemini API (gemini-1.5-flash)
DevOps & CI Docker, Docker Compose, GitHub Actions

πŸ›οΈ System Architecture

OpenPrep AI is structured as a multi-tier system separating client presentation, server business logic, persistent data storage, and external AI processing.

graph TD
    User["πŸ‘€ Student / Client Browser"] <-->|"HTTP / REST API / JWT"| ReactUI["πŸ“± React UI (Vite + Redux)"]
    
    subgraph Frontend["Client Layer (Frontend)"]
        ReactUI -->|"Axios Client"| APIClient["API Service Layer"]
    end
    
    APIClient <-->|"JSON Payloads & Bearer Auth"| ExpressBackend["βš™οΈ Express.js Server"]
    
    subgraph Backend["Server Layer (Backend)"]
        ExpressBackend -->|"Auth Middleware"| Middleware["JWT Protection"]
        Middleware -->|"Route Request"| Controller["Express Controllers"]
        Controller -->|"ORM Abstraction"| Sequelize["Sequelize ORM"]
        Controller -->|"AI Generation"| GeminiService["Gemini AI Service"]
    end
    
    subgraph Storage["Data & AI Layer"]
        Sequelize <-->|"SQL Queries"| PostgresDB[("🐘 PostgreSQL Database")]
        GeminiService <-->|"NLP Analysis & Summaries"| GoogleGemini["✨ Google Gemini API (gemini-1.5-flash)"]
    end
Loading

For detailed architectural decision records (ADRs) and sequence diagrams, review the System Architecture Documentation.


πŸ“‚ Project Structure

The repository is organized into separate frontend, backend, documentation, and development-support directories.

OpenPrep-AI/
β”œβ”€β”€ .github/                 # GitHub Actions, issue templates, and repository automation
β”œβ”€β”€ backend/                 # Node.js + Express backend
β”‚   β”œβ”€β”€ config/              # Application and database configuration
β”‚   β”œβ”€β”€ controllers/         # Request and business logic controllers
β”‚   β”œβ”€β”€ jobs/                # Background and scheduled jobs
β”‚   β”œβ”€β”€ middleware/          # Authentication, validation, and request middleware
β”‚   β”œβ”€β”€ migrations/          # Database migration files
β”‚   β”œβ”€β”€ models/              # Sequelize database models
β”‚   β”œβ”€β”€ routes/              # API route definitions
β”‚   β”œβ”€β”€ scripts/             # Backend utility and maintenance scripts
β”‚   β”œβ”€β”€ services/            # External service and AI integrations
β”‚   β”œβ”€β”€ sockets/              # Socket.IO event handling
β”‚   β”œβ”€β”€ tests/                # Backend test suites
β”‚   └── utils/                # Shared backend utilities
β”œβ”€β”€ frontend/                # React + Vite frontend application
β”‚   β”œβ”€β”€ e2e/                  # End-to-end tests
β”‚   β”œβ”€β”€ public/               # Static public assets
β”‚   └── src/                  # Frontend source code
β”œβ”€β”€ docs/                     # Project and technical documentation
β”‚   └── adr/                  # Architecture Decision Records
β”œβ”€β”€ issues/                   # Issue-related project resources
β”œβ”€β”€ pr/                       # Pull request-related resources
β”œβ”€β”€ scripts/                  # Repository-level development and automation scripts
β”œβ”€β”€ docker-compose.yml        # Local Docker service configuration
β”œβ”€β”€ package.json              # Root project scripts and dependencies
β”œβ”€β”€ pnpm-workspace.yaml       # pnpm workspace configuration
β”œβ”€β”€ CONTRIBUTING.md           # Contribution guidelines
β”œβ”€β”€ CODE_OF_CONDUCT.md        # Community guidelines
β”œβ”€β”€ SECURITY.md               # Security policy
β”œβ”€β”€ ROADMAP.md                # Project roadmap
β”œβ”€β”€ CHANGELOG.md              # Project change history
└── README.md                 # Project overview and setup instructions

🚦 Getting Started

For a step-by-step setup guide with environment variable details, review the Setup Guide.

Quick Launch with Docker

If you have Docker installed, you can spin up the frontend, backend, and PostgreSQL instances with a single command:

docker-compose up --build

The React frontend will be available at http://localhost:5173 and the Express API at http://localhost:5000.

Manual Local Launch

  1. Clone the Repository:
    git clone https://github.com/yourusername/OpenPrep-AI.git
    cd OpenPrep-AI
  2. Setup Backend:
    cd backend
    npm install
    # Copy the environment template to create your own configuration
    cp .env.example .env  # Or "copy .env.example .env" on Windows CMD
    # Open the new .env file and set your own DB_URI, JWT_SECRET, etc.
    npm run dev
  3. Setup Frontend:
    cd ../frontend
    npm install
    npm run dev

πŸ—„οΈ Database Migrations with Sequelize CLI

We use Sequelize CLI for managing database schema changes.

  • Run all pending migrations:

    npx sequelize-cli db:migrate
  • Revert the last migration:

    npx sequelize-cli db:migrate:undo
  • Revert all migrations:

    npx sequelize-cli db:migrate:undo:all
  • Seed the database with demo users:

    npx sequelize-cli db:seed:all

πŸ› οΈ Troubleshooting

If you encounter problems while setting up or running OpenPrep AI locally, check the common issues and solutions below.

1. SequelizeConnectionRefusedError / SequelizeConnectionError: connect ECONNREFUSED

This error occurs when the Node.js backend cannot connect to your PostgreSQL database instance.

  • Ensure PostgreSQL is running:
    • Windows (PowerShell as Administrator):
      Get-Service postgresql*
      Start-Service postgresql-x64-18  # Replace with your actual service version if different
    • Linux/macOS:
      sudo systemctl status postgresql
      sudo systemctl start postgresql
  • Verify database existence: Make sure you created the openprep database. You can create it with:
    psql -U postgres -c "CREATE DATABASE openprep;"
  • Check .env Connection String: Open backend/.env and verify that DATABASE_URL matches your local database credentials:
    DATABASE_URL=postgres://your_username:your_password@localhost:5432/openprep

2. React Vite Port 5173 (or Backend Port 5000) Already in Use

This happens when another local server or background process is already listening on ports 5173 (frontend) or 5000 (backend).

  • Quickly kill the port: Use npx kill-port to automatically terminate any processes occupying the dev ports:
    npx kill-port 5173 5000
  • Manually find and kill the process:
    • Windows (PowerShell):
      # Find process ID (PID) using the port
      Get-NetTCPConnection -LocalPort 5173 | Select-Object OwningProcess
      # Kill the process
      Stop-Process -Id <PID> -Force
    • Linux/macOS (Terminal):
      # Find PID using the port
      lsof -i :5173
      # Kill the process
      kill -9 <PID>

3. Missing .env / Environment Variable Issues on Startup

The backend will immediately crash or exit if required variables (like JWT_SECRET) are missing or incorrectly configured.

  • Verify .env exists: Check that you copied .env.example to .env in the backend/ directory:
    # Linux/macOS
    cp backend/.env.example backend/.env
    # Windows PowerShell
    Copy-Item backend/.env.example backend/.env
  • Set Required Variables: Make sure JWT_SECRET is set to a long, random string in backend/.env.

4. Dependencies fail to install / npm Cache Errors

This occurs due to outdated Node.js versions, corrupted npm cache, or package conflicts.

  • Clear npm cache & reinstall:
    npm cache clean --force
    npm install
  • Verify Node.js version: Ensure you are using Node v18.x or v20.x:
    node --version

5. Docker: port is already allocated or Volume Mount Issues on Windows

This occurs when local services (like a native PostgreSQL database) are using port 5432, or due to file sharing path permissions in Docker Desktop.

  • Stop native local services:
    • Stop local PostgreSQL so the Docker PostgreSQL container can bind to port 5432:
      # Windows PowerShell
      Stop-Service postgresql*
      # Linux/macOS
      sudo systemctl stop postgresql
  • Line ending errors in Docker (\r: command not found): If shell scripts fail inside the container, configure git to preserve LF line endings and re-clone/re-normalize:
    git config --global core.autocrlf input
    git add --renormalize .
    git checkout-index --force --all
  • WSL2 Setup and Mounting Details: For comprehensive WSL2 configurations, volume mounting, and file system speed enhancements on Windows, see the Windows Setup & Docker Troubleshooting Guide.

7. Windows & Docker specific issues (Line endings & WSL2)

If you are running Docker on Windows and encounter execution errors (like \r: command not found in shell scripts) or hot-reloading volume mounting issues, please refer to the dedicated Windows Setup & Docker Troubleshooting Guide in our documentation.


Still having problems?

If none of the solutions above resolve the issue, open a GitHub issue with:

  1. The error message.
  2. The command that produced the error.
  3. Your Node.js version.
  4. Your operating system.
  5. Relevant Docker or backend logs.
  6. Steps to reproduce the problem.

Providing this information will help maintainers and contributors investigate the problem more efficiently.


πŸ—ΊοΈ Roadmap

  • v1.0: Core authentication, AI study planners, quiz generators, and analytics dashboards.
  • v1.5: Spaced repetition engine, PYQ PDF parser, and attempt history trends.
  • v2.0: Weakness-adapted scheduling, community note pools, and OCR processing.
  • v3.0: Live study battles, AI chat mentors, and React Native mobile client.

For the comprehensive technical roadmap, review docs/project-roadmap.md.


🀝 Contributing

We welcome contributions of all levels! Please check the Contributing Guide to understand how to fork the project, set up formatting rules, and make your first Pull Request.

Please also adhere to the community standards in our Code of Conduct.


πŸ“œ License

This project is licensed under the MIT License. See LICENSE for more details.


❀️ Support

If you love this project, show your support:

  • ⭐ Star our repository on GitHub.
  • 🍴 Fork it to start contributing.
  • πŸ“’ Share it with your classmates and peers!

Built with ❀️ for students worldwide.

About

An advanced AI-powered exam preparation workspace to analyze lecture notes & PYQs, auto-schedule study plans, and master memory retention using spaced repetition

Resources

Code of conduct

Contributing

Security policy

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages