Digital Logic Studio

Your AI teaching assistant,
explained simply.

This page walks you through what the DLS AI Chatbot project is, how it works, what Pinecone does, and what every folder is for โ€” no prior AI experience needed.

Groq AI Pinecone RAG Node.js + Express

What is this project?

DLS AI Chatbot is a small backend service built for Digital Logic Studio (Boolforge). It answers student questions about digital logic โ€” Boolean algebra, gates, flip-flops, counters, and more.

๐ŸŽ“

Teaching assistant

It acts like a patient tutor that knows the DLS curriculum and speaks in plain language with examples and truth tables.

โšก

Fast answers

Powered by Groq and the llama-3.3-70b-versatile model โ€” responses come back in milliseconds.

๐Ÿ“š

Book-aware (RAG)

It can pull real excerpts from your DLD/DLS textbooks stored in Pinecone, so answers match your course material.

๐Ÿ”Œ

Plugs into DLS

The main Boolforge frontend calls this service over REST. It runs on its own port (5100) alongside the main backend.

What are we doing here?

In plain terms: we built a chatbot that reads your textbooks once, remembers them in a smart search database, and then uses that knowledge plus an AI brain to answer student questions.

  1. 1

    Drop books in /data

    You place PDF or text files of digital logic books (e.g. Morris Mano, Floyd) into the data/ folder.

  2. 2

    Ingest into Pinecone

    Run npm run ingest. The script splits each book into small chunks and uploads them to Pinecone's vector database.

  3. 3

    Student asks a question

    From the Boolforge app or the local test UI, a learner types something like "How does a JK flip-flop work?"

  4. 4

    Search + generate

    The server finds the 5 most relevant book passages in Pinecone, adds them to the AI prompt, and Groq writes a personalized answer.

How a question travels through the system

Student / Frontend
โ†’
POST /api/ai/chat
โ†“
Pinecone search
find relevant book chunks
+
System prompt
name, topic, curriculum
โ†“
Groq API (LLM)
โ†’
JSON reply to student

This pattern is called RAG (Retrieval-Augmented Generation): retrieve facts first, then generate an answer grounded in those facts.

What is Pinecone?

Pinecone is a cloud vector database. Think of it as a library index that understands meaning, not just exact keywords.

When you ingest a book, each chunk of text is turned into a list of numbers called an embedding (a mathematical fingerprint of what that paragraph is about). Pinecone stores millions of these fingerprints.

When a student asks "What is a multiplexer?", Pinecone converts that question into the same kind of fingerprint and finds the book paragraphs whose fingerprints are closest โ€” even if the book never used the exact same words.

Simple analogy

Imagine every paragraph of your textbook on a sticky note. Pinecone is the wall where similar sticky notes are placed near each other. When a student asks a question, we find the nearest sticky notes and hand them to the AI before it answers โ€” so it cites your actual course material instead of guessing.

What does the data/ folder do?

The data/ folder is your local bookshelf. It is where you put the source material the chatbot should learn from.

data/
โ”œโ”€โ”€ boolean-algebra-ch1.pdf   โ† your textbook chapters
โ”œโ”€โ”€ sequential-circuits.txt   โ† course notes
โ””โ”€โ”€ README.md                 โ† instructions (not ingested)

Supported files

.pdf and .txt only. The ingest script reads text from PDFs automatically.

Not in git

Actual book PDFs are gitignored for copyright. Each developer adds their own copies locally.

Re-run anytime

Add new books and run npm run ingest again. Pinecone gets updated with the new content.

Ingest command

npm run ingest

Reads every .pdf / .txt in data/, splits into ~500-word chunks with overlap, uploads to Pinecone.

Folder structure (simple map)

Every important folder and what it is responsible for.

Dls-AI-Chatbot/ โ€” project root
server.js Starts the HTTP server on port 5100.
index.html Local test chat UI โ€” open at /index.html when the server is running.
package.json Dependencies and scripts: npm run dev, npm start, npm run ingest.
.env Secret keys (Groq, Pinecone, JWT). Copy from .env.example.
data/ โ€” your textbooks

Put PDF/TXT books here. The ingest script reads this folder and uploads chunks to Pinecone. See section above.

scripts/ โ€” one-off tools
ingest.js Chunks books from data/ and uploads them to Pinecone. Run with npm run ingest.
src/ โ€” main application code
app.js Express setup: CORS, JSON parsing, routes, static files.
config/groq.js Connects to Groq AI (the LLM that writes answers).
config/pinecone.js Connects to Pinecone vector database.
controllers/chatController.js Handles chat requests: validates input, runs RAG, calls Groq, returns reply.
services/retrieval.js Searches Pinecone for book chunks related to the user's question.
prompts/systemPrompt.js Builds the "you are DLS Mentor" instruction with student name, topic, and curriculum.
routes/chat.js Defines POST /api/ai/chat and streaming endpoint.
middleware/auth.js Checks JWT login token (shared with main DLS backend).
middleware/rateLimit.js Limits how many messages one user can send per minute.
website/ โ€” this guide

You are here. A static explainer page for the project. Open at /website/index.html.

docs/ โ€” contributor docs

Code of conduct, contributing guide, security policy โ€” for developers joining the repo.

Quick start commands

Install npm install
Configure cp .env.example .env Then add your Groq and Pinecone API keys.
Add books data/your-book.pdf
Ingest npm run ingest
Run dev server npm run dev
Open chat UI localhost:5100/index.html
Open this guide localhost:5100/website/