Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

LexiLearn AI - Intelligent Spaced Repetition Flashcards

Python FastAPI React

LexiLearn AI is a full-stack, AI-enhanced web application designed to optimize learning through an intelligent Spaced Repetition System (SRS). It goes beyond traditional flashcards by verifying user answers for semantic correctness and providing dynamic AI-generated hints, ensuring a truly adaptive and effective study experience.


Key Features

LexiLearn AI combines proven learning science with modern AI capabilities:

  • Spaced Repetition System (SRS): Implements an efficient algorithm (based on SM-2 principles) using a Priority Queue (Min-Heap) to intelligently schedule card reviews, prioritizing cards the user is most likely to forget.
  • AI-Powered Answer Verification: Utilizes the Groq API (Llama 3) to perform semantic analysis of user-typed answers, ensuring correctness based on meaning, not just exact string matching.
  • AI-Generated Hints: Provides on-demand, context-aware hints generated by AI to guide users without giving away the answer.
  • Secure User Authentication: Features a robust JWT-based authentication system, ensuring each user's decks and progress are private.
  • Full CRUD Operations: Seamlessly Create, Read, Update, and Delete decks and flashcards.
  • Modern Full-Stack Architecture: Built with a decoupled React frontend and FastAPI backend, following professional design patterns.
  • Dynamic & Responsive UI: Clean, dark-themed interface built with React Hooks and Context API for efficient state management.

Technology Stack & Architecture

LexiLearn AI leverages a modern, robust technology stack chosen for performance, scalability, and developer experience.

Backend (Python / FastAPI)

  • Language: Python 3.9+
  • Framework: FastAPI (async capabilities + Pydantic validation)
  • Server: Uvicorn (ASGI server)
  • Database: SQLAlchemy ORM with SQLite (easily adaptable to PostgreSQL)
  • AI Integration: Groq API (via groq library)
  • Authentication: python-jose (JWT), passlib[bcrypt] (Password Hashing)
  • Data Structures: Python’s built-in heapq for Priority Queue
  • Architecture: MVC-like pattern — Routers, Services, Models, Schemas for clear separation of concerns
Untitled diagram-2025-10-24-101751

Frontend (React / Vite)

  • Language: JavaScript (ES6+)
  • Framework: React 18+ (using Hooks)
  • Build Tool: Vite
  • Routing: react-router-dom
  • State Management: React Context API
  • API Communication: axios
  • Styling: CSS Variables + Component-scoped Inline Styles

Core Algorithms & Concepts

LexiLearn AI isn’t just any CRUD app — it integrates intelligent logic for adaptive learning.

Spaced Repetition System (SRS) & Priority Queue

  • Each flashcard tracks next_review_date, interval, and ease_factor.
  • When fetching the next card, the backend queries all due cards.
  • These cards are inserted into a Min-Heap using Python’s heapq.
  • Extracting the minimum (heapq.heappop) guarantees the most overdue card is selected first. Time complexity: O(log n).

AI Semantic Answer Verification

  1. User input is sent to the backend.
  2. The _verify_answer_with_ai service function sends a crafted prompt to the Groq API.
  3. The AI compares semantic meaning between the user's and correct answer.
  4. Returns a Boolean (True or False) based on conceptual correctness.
  5. The result updates SRS parameters (interval, ease factor, next review).

AI Hint Generation

  • get_hint_for_card sends the card’s question and answer to the Groq API.
  • The AI generates a concise hint that helps without revealing the full answer.

Getting Started

Follow these steps to get LexiLearn AI running locally.

Prerequisites

  • Python 3.9+
  • Node.js (v16+) & npm
  • Git

Backend Setup

  1. Clone the Repository
    git clone [https://github.com/your-username/lexilearn-ai.git](https://github.com/your-username/lexilearn-ai.git)
    cd lexilearn-ai
  2. Navigate to Backend Directory
    cd backend
  3. Create and Activate Virtual Environment
    # For Windows
    python -m venv venv
    .\venv\Scripts\activate
    
    # For macOS/Linux
    python3 -m venv venv
    source venv/bin/activate
  4. Install Dependencies
    pip install -r requirements.txt
  5. Configure Environment Variables Create a .env file in the backend directory and add your Groq API key:
    DATABASE_URL="sqlite:///./lexilearn.db"
    GROQ_API_KEY="your_groq_api_key_here"
  6. Start the Backend Server (Leave this terminal running)
    python -m uvicorn app.main:app --reload
    The backend API will be available at http://localhost:8000.

Frontend Setup

  1. Open a New Terminal
  2. Navigate to Frontend Directory
    cd frontend
  3. Install Dependencies
    npm install
  4. Start the Frontend Server (Leave this terminal running)
    npm run dev
    The frontend application will be available at http://localhost:5173.

API Documentation

The backend API includes automatically generated, interactive documentation powered by Swagger UI. Once the backend server is running, you can access it at:

http://localhost:8000/docs

This allows you to explore and test all available API endpoints directly.


Acknowledgements

  • AI Models: Groq
  • Frameworks: FastAPI, React, Vite
  • Concept Inspiration: Based on the principles of Spaced Repetition pioneered by Piotr Woźniak (SuperMemo/SM-2 algorithm).

About

Flashcards with context. LexiLearn knows when you almost got it, hints without spoiling, and resurfaces cards right before you'd forget.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages