Skip to content

AKillerPanda/NeuraLearn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NeuraLearn

AI-powered learning path generator that turns any skill into an interactive knowledge graph with optimised study routes β€” powered by spectral graph theory, ant colony optimisation, and stochastic diffusion search.

Type a topic. Get a complete curriculum. See how everything connects.

Python React TypeScript Tests


What It Does

  1. You type a skill β€” "Machine Learning", "Piano", "Web Development", anything
  2. NeuraLearn scrapes the web concurrently (Wikipedia, GeeksforGeeks, GitHub, DuckDuckGo) to discover subtopics and resources
  3. Builds a knowledge graph β€” a DAG where nodes are topics and edges are prerequisite relationships, with real fan-in/fan-out structure
  4. Finds the best learning path using Ant Colony Optimisation with spectral heuristics β€” not just any valid order, but the one that minimises cognitive load
  5. Visualises everything as an interactive graph you can explore, with multiple path options, progress tracking, gamification, and study tools

Features

Core

  • Knowledge Graph Generation β€” webscrape β†’ DAG β†’ spectral layout β†’ ACO-optimised paths, all in < 3 seconds
  • Multiple Learning Paths β€” prerequisite-respecting routes at beginner / intermediate / advanced difficulty
  • Sub-Graph Deep Dives β€” click any topic node to generate a detailed breakdown of that sub-skill
  • Server-Side Mastery Tracking β€” prerequisite-validated completion with cascade unmastering
  • Shortest Path Finder β€” find the minimum-topic route to reach any target node
  • Live Spell Correction β€” SDS-powered real-time spell-check as you type on the home page
  • GAT Difficulty Analysis β€” Graph Attention Network predicts per-topic difficulty based on graph structure and mastery state, powering smart "next topic" recommendations

University Student Features

  • Pomodoro Timer β€” 25/5/15-minute focus/break modes with SVG progress ring, auto-mode-switch, and session counter
  • Gamification System β€” XP (100 per topic, 25 per Pomodoro), quadratic levelling, 8 achievements, streak tracking
  • Anki Flashcard Export β€” one-click TSV download of all topics for spaced repetition
  • Study Time Estimation β€” per-topic minute estimates based on difficulty, with total/remaining hours
  • Dark Mode β€” full dark theme toggle across header, sidebar, graph, and toasts
  • Graph Analytics Dashboard β€” spectral gap, algebraic connectivity, ACO convergence chart, degree distribution
  • Study Streak Calendar β€” GitHub-style heatmap tracking daily study activity with current/longest streak stats
  • Weekly Study Goals β€” adjustable weekly target with auto-reset, progress bar, and localStorage persistence
  • Topic Notes β€” per-topic rich-text note editor with save/delete, persisted per skill
  • Smart Recommendations β€” GAT-powered personalised "next topic" suggestions with difficulty indicators

How It Works β€” The Algorithms

Spectral Graph Theory (graph.py β€” 1006 lines)

The knowledge graph isn't just a data structure β€” it's analysed using the Laplacian spectrum to understand its topology:

  • Fiedler vector (2nd eigenvector of the Laplacian) determines natural graph partitions and drives node layout
  • Spectral embedding maps topics into Euclidean space where distance = topological dissimilarity
  • Algebraic connectivity (Ξ»β‚‚) measures how tightly connected the curriculum is
  • Spectral clustering groups related topics without manual labelling
  • ArpackNoConvergence resilience β€” graceful fallback when eigensolvers partially converge

Ant Colony Optimisation (ACO.py β€” 495 lines)

Finding the optimal study order is NP-hard. ACO solves it with swarm intelligence:

  • 50 virtual ants walk the graph per iteration, guided by pheromone trails and a spectral heuristic
  • Pheromone is warm-started using Fiedler distances β€” spectrally close topics get higher initial pheromone, converging 2–5Γ— faster
  • Spectral distance replaces naive edge-hop relatedness for the cost matrix
  • Prerequisite constraints are enforced via vectorised boolean matrix multiplication
  • All matrix ops (cost, heuristic, pheromone deposit) are fully vectorised with NumPy
  • Early stopping when convergence plateaus

Stochastic Diffusion Search (SDS.py β€” 559 lines)

Real-time spell correction as you type, backed by a 100k+ word dictionary:

  • Vectorised pre-filter (character frequency + bigram overlap + prefix matching) narrows candidates from 100k β†’ 200
  • SDS agents test random micro-features (fuzzy character position matching) and cluster on the best match
  • Final ranking combines SDS hits, character similarity, and Levenshtein edit distance
  • All operations on padded NumPy uint8 matrices β€” zero Python loops over the dictionary

Web Scraping (Webscraping.py β€” 524 lines)

Structured curriculum extraction from multiple sources:

  • Concurrent fetching (4 sources in parallel via ThreadPoolExecutor)
  • DAG-aware prerequisite assignment β€” foundational topics have no prereqs, higher levels depend on 1–2 topics from the level below, creating realistic fan-in/fan-out

GAT Difficulty Analysis (difficulty_gnn.py β€” 443 lines)

Self-supervised Graph Attention Network that predicts per-topic difficulty:

  • 3-layer GATConv architecture (10 β†’ 64 β†’ 64 β†’ 1) with multi-head attention
  • 10 structural features per node: in/out-degree, topological depth, prerequisite ratio, spectral coordinates (Fiedler), mastery state, neighbourhood mastery
  • Self-supervised β€” no external training data; uses fixed weight initialisation tuned to structural heuristics
  • Mastered neighbours reduce effective difficulty, enabling personalised recommendations

File Structure

neuralearn/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Backend/
β”‚   β”‚   β”œβ”€β”€ graph.py            # Knowledge graph + spectral analysis (1006 lines)
β”‚   β”‚   β”œβ”€β”€ ACO.py              # Ant Colony Optimisation with spectral heuristics (495 lines)
β”‚   β”‚   β”œβ”€β”€ SDS.py              # Stochastic Diffusion Search spell corrector (559 lines)
β”‚   β”‚   β”œβ”€β”€ difficulty_gnn.py   # GAT difficulty predictor (443 lines)
β”‚   β”‚   β”œβ”€β”€ Webscraping.py      # Concurrent multi-source web scraper (524 lines)
β”‚   β”‚   β”œβ”€β”€ api.py              # Flask REST API β€” 11 endpoints, thread-safe (1000 lines)
β”‚   β”‚   β”œβ”€β”€ test_all.py         # 5 test suites, 218 assertions (1190 lines)
β”‚   β”‚   └── words in english/   # A–Z dictionary CSVs for spell correction
β”‚   β”‚
β”‚   └── frontend/
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ app/
β”‚       β”‚   β”‚   β”œβ”€β”€ pages/
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ Home.tsx             # Landing page with live spell-check
β”‚       β”‚   β”‚   β”‚   └── KnowledgeGraph.tsx   # Interactive graph + 5-tab sidebar
β”‚       β”‚   β”‚   β”œβ”€β”€ components/
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ CustomNode.tsx       # ReactFlow node with level/cluster badges
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ PomodoroTimer.tsx    # 25/5/15-min study timer with SVG ring
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ GamificationPanel.tsx # XP, levels, achievements, streaks
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ LearningInsightsPanel.tsx # Curriculum cohesion & bottleneck cards
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ SmartRecommendation.tsx # GAT-powered next-topic suggestions
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ StudyStreakCalendar.tsx # GitHub-style study heatmap
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ TopicNotes.tsx       # Per-topic note editor
β”‚       β”‚   β”‚   β”‚   β”œβ”€β”€ WeeklyStudyGoal.tsx  # Weekly target tracker
β”‚       β”‚   β”‚   β”‚   └── ui/                  # shadcn/ui component library
β”‚       β”‚   β”‚   β”œβ”€β”€ utils/
β”‚       β”‚   β”‚   β”‚   └── api.ts               # Typed API client (10 functions, timeout handling)
β”‚       β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚       β”‚   β”‚   └── routes.tsx
β”‚       β”‚   └── main.tsx
β”‚       β”œβ”€β”€ index.html
β”‚       β”œβ”€β”€ vite.config.ts
β”‚       └── package.json
β”‚
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

Tech Stack

Layer Tech
Graph Engine Python 3.14, NumPy, SciPy (sparse Laplacians, ARPACK eigensolver), PyTorch Geometric
Optimisation Ant Colony Optimisation (vectorised), Stochastic Diffusion Search
API Flask 3.1, flask-cors, thread-safe LRU graph store
Frontend React 19, TypeScript 5.7, Vite 6.4, ReactFlow, Tailwind CSS v4, shadcn/ui, Motion, Sonner
Scraping requests, BeautifulSoup4, MediaWiki API, concurrent.futures

Quick Start

# Clone
git clone https://github.com/AKillerPanda/NeuraLearn.git
cd NeuraLearn

# Backend
python -m venv .venv
.venv\Scripts\activate          # Windows
pip install flask flask-cors torch torch-geometric numpy scipy scikit-learn pandas beautifulsoup4 requests matplotlib seaborn

cd src/Backend
python api.py                   # β†’ http://localhost:5000

# Frontend (new terminal)
cd src/frontend
npm install
npm run dev                     # β†’ http://localhost:5173

Note: Always run api.py using the venv Python (.venv\Scripts\python.exe api.py) to ensure all dependencies are available.


Run Tests

cd src/Backend
python -m pytest test_all.py -v   # 5 suites, 218 assertions

API Endpoints

Method Endpoint Description
POST /api/generate Build knowledge graph + learning paths for a skill
POST /api/sub-graph Generate sub-graph for a subtopic
POST /api/spell-check SDS-powered spell correction
POST /api/master Mark a topic as mastered (prerequisite-validated)
POST /api/unmaster Un-master a topic with cascade to dependents
POST /api/shortest-path Find minimum-topic route to a target node
GET /api/progress/:skill Get current mastery progress for a graph
GET /api/flashcards/:skill Export Anki-compatible flashcards (TSV)
GET /api/study-stats/:skill Study time estimates & difficulty breakdown
GET /api/difficulty/:skill GAT-based per-topic difficulty scores & recommendations
GET /api/health Health check

License

See LICENSE.

About

An ai app that helps you learn new skills given a plan and route based on what seems the best option for youπŸ’ž.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors