Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LEARNBYAI

GitHub stars GitHub forks GitHub issues Last commit

πŸ“‘ Table of Contents

πŸ“š LearnWithAI

An AI-powered learning platform that transforms PDFs into an interactive study experience using Retrieval-Augmented Generation (RAG).

πŸ—οΈ Architecture

A high-level view of how the main pieces fit together:

flowchart LR
    User["πŸ‘€ User / Browser"]

    FE["πŸ–ΌοΈ React + Vite Frontend"]

    API["πŸš€ Express.js API Server"]

    Auth["πŸ” JWT Authentication"]

    Mongo["πŸƒ MongoDB"]

    Cloud["☁️ Cloudinary\n(PDF Storage)"]

    Queue["πŸ“¬ BullMQ Queue"]

    Redis["⚑ Redis"]

    Worker["βš™οΈ Background Worker"]

    Parse["πŸ“„ PDF Parser"]

    Embed["🧠 Embedding Generator"]

    Pinecone["πŸ“Œ Pinecone Vector DB"]

    OpenAI["πŸ€– OpenAI API"]

    User --> FE
    FE --> API

    API --> Auth
    API --> Mongo
    API --> Cloud

    API --> Queue
    Queue --> Redis
    Redis --> Worker

    Worker --> Parse
    Parse --> Embed
    Embed --> OpenAI
    Embed --> Pinecone

    FE -->|"Chat with PDF"| API
    API --> Pinecone
    API --> OpenAI
    API --> Mongo
    API --> FE
Loading

✨ Overview

LearnWithAI allows users to upload PDF documents and instantly interact with them using AI. Instead of reading hundreds of pages manually, users can:

  • πŸ’¬ Chat with their PDFs
  • πŸ“ Generate AI summaries
  • 🎯 Create flashcards
  • ❓ Generate quizzes
  • πŸ“– Take smart notes

Large PDF processing is handled asynchronously using BullMQ and Redis, ensuring the application remains fast and responsive.


πŸš€ Features

πŸ“„ PDF Management

  • Upload PDFs securely
  • Cloudinary storage
  • View uploaded PDFs
  • Delete PDFs
  • Processing status tracking

πŸ€– AI Features

  • Chat with PDF using RAG
  • AI-generated summaries
  • Flashcard generation
  • Quiz generation
  • Context-aware responses
  • Semantic document search

πŸ” Authentication

  • JWT Authentication
  • Secure HTTP-only cookies
  • Protected routes
  • User-specific documents

⚑ Background Processing

PDF processing runs in the background:

  • Text extraction
  • Text chunking
  • Embedding generation
  • Pinecone indexing
  • Status updates

This prevents long upload requests and improves scalability.


🧠 How It Works

                Upload PDF
                     β”‚
                     β–Ό
              Express Backend
                     β”‚
                     β–Ό
        Store PDF in Cloudinary
                     β”‚
                     β–Ό
          Save Metadata in MongoDB
                     β”‚
                     β–Ό
          Create BullMQ Processing Job
                     β”‚
                     β–Ό
               Redis Queue
                     β”‚
                     β–Ό
            Background Worker
                     β”‚
                     β–Ό
            Extract PDF Text
                     β”‚
                     β–Ό
             Split into Chunks
                     β”‚
                     β–Ό
      Generate OpenAI Embeddings
                     β”‚
                     β–Ό
      Store Embeddings in Pinecone
                     β”‚
                     β–Ό
          PDF Ready for Chat

πŸ’¬ Chat Flow

User Question
      β”‚
      β–Ό
Generate Query Embedding
      β”‚
      β–Ό
Search Similar Chunks
      β”‚
      β–Ό
Retrieve Context
      β”‚
      β–Ό
Send Context + Prompt
      β”‚
      β–Ό
OpenAI Response
      β”‚
      β–Ό
Answer Returned to User

πŸ› οΈ Tech Stack

JavaScript React Tailwind CSS Vite

⚑ Quick Start

# 1. Clone the repository
git clone https://github.com/Garv978/LEARNBYAI.git

# 2. Install dependencies
npm install

# 3. Start the dev server
npm run dev

πŸ“¦ Key Dependencies

🎨 Frontend

react: ^19.2.7
react-dom: ^19.2.7
react-router-dom: ^7.18.1
axios: ^1.18.1
jwt-decode: ^4.0.0
lucide-react: ^1.24.0
tailwindcss: ^4.3.2
@tailwindcss/vite: ^4.3.2

πŸš€ Backend

express
mongoose
jsonwebtoken
bcryptjs
cookie-parser
cors
dotenv
helmet
morgan
express-rate-limit
express-fileupload
cloudinary
multer
streamifier
http-status-codes

πŸ€– AI & RAG

openai
langchain
@langchain/openai
@langchain/community
@langchain/textsplitters
@langchain/pinecone
@pinecone-database/pinecone
pdf-parse

⚑ Background Jobs

bullmq
ioredis

πŸ” Validation

zod

πŸ› οΈ Development

nodemon
eslint
vite

πŸš€ Available Scripts

  • dev β€” npm run dev
  • build β€” npm run build
  • lint β€” npm run lint
  • preview β€” npm run preview

πŸ“ Project Structure

.
β”œβ”€β”€ client
β”‚   β”œβ”€β”€ eslint.config.js
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ public
β”‚   β”‚   β”œβ”€β”€ favicon.svg
β”‚   β”‚   └── icons.svg
β”‚   β”œβ”€β”€ src
β”‚   β”‚   β”œβ”€β”€ App.css
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   β”œβ”€β”€ components
β”‚   β”‚   β”‚   β”œβ”€β”€ HeroSection.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Pdfnavbar.jsx
β”‚   β”‚   β”‚   └── Sidebar.jsx
β”‚   β”‚   β”œβ”€β”€ context
β”‚   β”‚   β”‚   └── AuthContext.jsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   β”œβ”€β”€ layouts
β”‚   β”‚   β”‚   β”œβ”€β”€ PdfLayout.jsx
β”‚   β”‚   β”‚   └── UserLayout.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   β”œβ”€β”€ pages
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ForgotPassword.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ NotFound.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PdfList.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ResetPassword.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ VerifyEmail.jsx
β”‚   β”‚   β”‚   └── pdf
β”‚   β”‚   β”‚       β”œβ”€β”€ Chat.jsx
β”‚   β”‚   β”‚       β”œβ”€β”€ Flashcards.jsx
β”‚   β”‚   β”‚       β”œβ”€β”€ Notes.jsx
β”‚   β”‚   β”‚       β”œβ”€β”€ Quiz.jsx
β”‚   β”‚   β”‚       └── Summary.jsx
β”‚   β”‚   β”œβ”€β”€ services
β”‚   β”‚   β”‚   └── AuthServices.js
β”‚   β”‚   └── utils
β”‚   β”‚       └── ProtectedRoute.jsx
β”‚   └── vite.config.js
└── server
    β”œβ”€β”€ api.js
    β”œβ”€β”€ app.js
    β”œβ”€β”€ config
    β”‚   β”œβ”€β”€ cloudinary.js
    β”‚   └── redis.js
    β”œβ”€β”€ controllers
    β”‚   β”œβ”€β”€ authController.js
    β”‚   β”œβ”€β”€ pdfController.js
    β”‚   └── userController.js
    β”œβ”€β”€ db
    β”‚   └── connect.js
    β”œβ”€β”€ errors
    β”‚   β”œβ”€β”€ bad-request.js
    β”‚   β”œβ”€β”€ custom-api.js
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ not-found.js
    β”‚   β”œβ”€β”€ unauthenticated.js
    β”‚   └── unauthorized.js
    β”œβ”€β”€ middleware
    β”‚   β”œβ”€β”€ authentication.js
    β”‚   β”œβ”€β”€ error-handler.js
    β”‚   β”œβ”€β”€ not-found.js
    β”‚   └── upload.js
    β”œβ”€β”€ models
    β”‚   β”œβ”€β”€ Pdf.js
    β”‚   β”œβ”€β”€ Token.js
    β”‚   └── User.js
    β”œβ”€β”€ package.json
    β”œβ”€β”€ queues
    β”‚   └── pdfQueue.js
    β”œβ”€β”€ routes
    β”‚   β”œβ”€β”€ authRoutes.js
    β”‚   β”œβ”€β”€ pdfRoutes.js
    β”‚   └── userRoutes.js
    β”œβ”€β”€ utils
    β”‚   β”œβ”€β”€ checkPermissions.js
    β”‚   β”œβ”€β”€ createTokenUser.js
    β”‚   β”œβ”€β”€ index.js
    β”‚   β”œβ”€β”€ jwt.js
    β”‚   └── sendEmail.js
    └── workers
        └── pdfworker.js

πŸ› οΈ Development Setup

Node.js / JavaScript

  1. Install Node.js (v18+ recommended)
  2. Install dependencies: npm install (or yarn / pnpm install / bun install)
  3. Start the dev server: see the Quick Start above

πŸ‘₯ Contributors

Thanks to everyone who has contributed to this project:

Garv978

See the full list of contributors β†’

πŸ‘₯ Contributing

Contributions are welcome! Here's the standard flow:

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/Garv978/LEARNBYAI.git
  3. Branch: git checkout -b feature/your-feature
  4. Commit: git commit -m 'feat: add some feature'
  5. Push: git push origin feature/your-feature
  6. Open a pull request

Please follow the existing code style and include tests for new behavior where applicable.


About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages