This project builds an AI-powered concept knowledge graph from text notes (e.g., course summaries or lecture topics).
It automatically extracts concepts, generates embeddings, and links related topics using Gemini.
Each .txt file you upload represents a concept node (e.g., Depth-First Search, Aggregate Demand).
The backend then:
- Parses each note and generates an embedding.
- Creates nodes in
public/graph.json. - Uses Gemini to infer semantic edges (e.g., prerequisites, related, contrasts_with).
- Visualizes them interactively in the web frontend.
study-net/
├── server/
│ ├── ingest.ts # Handles file ingestion and embedding updates
│ ├── connectNodesGemini.js # Generates intelligent edges using Gemini
│ ├── connectNodes.js # Optional cosine-similarity baseline
│ ├── data/
│ │ ├── chunks.ndjson # Parsed text chunks
│ │ ├── embeddings.bin # Embedding vectors
│ │ └── embeddings.index.json
│ └── public/
│ └── graph.json # Final merged graph (nodes + links + edges)
├── generate_notes_random_years.sh # Script to create 15 sample notes
└── README.md
Create a .env file inside /server with your Gemini key:
GOOGLE_API_KEY="your_google_api_key"
# or
GEMINI_API_KEY="your_gemini_api_key"cd server
npm installTo test the system, run:
chmod +x generate_notes_random_years.sh
./generate_notes_random_years.shThis will create 15 .txt course notes (CSC & ECO) in the current directory with randomized years between 2023–2025.
curl -s -X POST http://localhost:8787/api/ingest/finalize \
-H "Content-Type: application/json" \
-d '{"docIds": ["doc_dummy"]}' | jqThen verify:
jq '{nodes: (.nodes | length), links: (.links | length), edges: (.edges | length)}' ../public/graph.jsonTo infer semantic edges with Gemini:
node connectNodesGemini.jsExample output:
[connectNodesGemini] Created 10 edges from 15 nodes.
Once integrated, you can ask natural-language questions:
curl -X POST http://localhost:8787/api/ask \
-H "Content-Type: application/json" \
-d '{"query": "How does Dijkstra relate to recursion?"}'- The frontend reads from
public/graph.json. - Clicking a node highlights related and prerequisite connections.
- Gemini edges (
graph.edges) show directional and typed relationships,
while base edges (graph.links) preserve prerequisite logic.
| Source | Target | Type | Why |
|---|---|---|---|
| Recursion | DFS | prerequisite | DFS implementations rely on recursion. |
| DFS | Flow Networks | prerequisite | Flow algorithms traverse graphs using DFS. |
| Fiscal Policy | Aggregate Demand | related | Fiscal policy directly influences aggregate demand. |
To reset the dataset:
rm -f data/chunks.ndjson data/embeddings.* public/graph.jsonMIT License © 2025