-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Last updated:Β Sep 30, 2025
Owner:Β David NguyenΒ (repo:Β hoangsonww/AI-RAG-Assistant-Chatbot)
LuminaΒ is a full-stack RAG-powered chatbot that answers questions about David Nguyen or general topics. It pairs a modern React/MUI frontend with an Express/TypeScript backend, adds JWT authentication, and usesΒ Retrieval-Augmented Generation (RAG)Β viaΒ LangChainΒ andΒ PineconeΒ to ground LLM responses in a curated knowledge base. Logged-in users can save, search, and rename conversations; guests can chat without persistence.
Live apps
Frontend:Β
https://lumina-david.vercel.appBackend + Swagger:Β
https://ai-assistant-chatbot-server.vercel.appBackup frontend:Β
https://lumina-ai-chatbot.netlify.app
Key Capabilities
Real-time chat with markdown rendering
RAG over personal knowledge base (Pinecone vector DB)
Auth (signup/login/reset) withΒ JWT
Conversation CRUD + search (MongoDB via Mongoose)
Guest mode (ephemeral conversations)
Light/Dark themes, responsive UI, polished animations
CI/CD viaΒ GitHub ActionsΒ (deploy to Vercel/Netlify)
OpenAPI spec + Swagger docs
[ User ]
β (browser)
βΌ
[ Frontend: React + MUI + TS ]
β REST (HTTPS)
βΌ
[ Backend: Express + TS ]
ββ Auth (JWT)
ββ Conversations API
ββ Chat API (LLM + RAG orchestration w/ LangChain)
β
ββ MongoDB (Users, Conversations)
ββ Pinecone (Vectors: knowledge chunks)
β²
β indexer script (storeKnowledge.ts / npm run store)
ββ Knowledge sources (docs, notes, etc.)
RAG loop (high-level)
Embed & storeΒ knowledge in Pinecone (
storeKnowledge.ts).RetrieveΒ top-k chunks from Pinecone for a user query (cosine similarity).
AugmentΒ the prompt with retrieved context (LangChain).
GenerateΒ an answer via LLM (OpenAI/Gemini).
PersistΒ messages to MongoDB for authenticated users; useΒ ephemeralΒ storage for guests.
AI-RAG-Assistant-Chatbot/
βββ client/ # React + TS + MUI application
β βββ src/
β β βββ components/ # Navbar, Sidebar, ChatArea
β β βββ pages/ # Landing, Home, Login, Signup, ForgotPassword, 404
β β βββ services/api.ts # API client
β β βββ theme.ts # Light/Dark themes
β β βββ types/ # conversation.d.ts, user.d.ts
β βββ Dockerfile, docker-compose.yml, tsconfig.json, package.json
β
βββ server/ # Express + TS backend
β βββ src/
β βββ server.ts # App bootstrap
β βββ routes/ # auth.ts, conversations.ts, chat.ts
β βββ models/ # User.ts, Conversation.ts
β βββ middleware/ # auth.ts (JWT guard)
β βββ services/ # authService.ts
β βββ utils/ # ephemeralConversations.ts
β βββ scripts/ # storeKnowledge.ts (RAG indexer)
β βββ Dockerfile, docker-compose.yml, tsconfig.json, package.json
β
βββ openapi.yaml # API contract (importable into Swagger/Postman)
βββ docker-compose.yml # Root compose for local dev
βββ .github/workflows/ # CI/CD (build, test, deploy)
βββ Jenkinsfile # (legacy/optional)
βββ README.md, LICENSE, CITATION.cff
βββ .env.example # Example server env
Frontend: React + TypeScript, Material UI (MUI)
Backend: Node.js, Express, TypeScript
Database: MongoDB (Mongoose)
Vector DB: Pinecone (k-NN cosine similarity)
RAG/Orchestration: LangChain
LLMs: OpenAI / Google Gemini (configurable)
Auth: JWT + middleware
Infra/Delivery: Vercel (FE), Netlify (FE backup), Vercel (BE)
Docs: OpenAPI + Swagger
CI/CD: GitHub Actions (install β test β build β deploy; artifacts, linting)
Containers: Docker, docker-compose
Testing: Jest (FE + BE)
Misc: Python/Jupyter for experiments (optional)
CreateΒ server/.envΒ (seeΒ .env.example) with:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/ai-assistant
JWT_SECRET=replace_with_a_strong_secret
GOOGLE_AI_API_KEY=your_google_ai_api_key_here
AI_INSTRUCTIONS="System prompt for the assistant"
PINECONE_API_KEY=your_pinecone_api_key_here
PINECONE_INDEX_NAME=your_pinecone_index_name_here
Notes
JWT_SECRETΒ must be long and random; rotate if leaked.
AI_INSTRUCTIONSΒ holds your system prompt (persona/guardrails).
Ensure Pinecone index (dimension/metric) matches your embedding model.
CreateΒ client/.envΒ (if not already present):
REACT_APP_API_BASE_URL=http://localhost:5000
Update this value to the deployed backend URL in hosted environments.
Node 18+ / npm
Docker (optional, recommended)
MongoDB (local or Docker)
Pinecone account & index
Backend
git clone https://github.com/hoangsonww/AI-RAG-Assistant-Chatbot.git
cd AI-RAG-Assistant-Chatbot/server
npm install
# 1) Prepare .env (see above)
# 2) (One-time) index your knowledge into Pinecone:
npm run store # or: npx ts-node src/scripts/storeKnowledge.ts
# 3) Run the API:
npm run dev # ts-node + nodemon
Frontend
cd ../client
npm install
npm start # http://localhost:3000
From repo root:
docker-compose up --build
This brings up the FE and BE services as defined in rootΒ docker-compose.yml.
EditΒ .envΒ to point FE β BE service hostname within the compose network if needed.
The exact schemas live inΒ
server/src/models. Below is a typical structure to guide usage and API expectations.
User
emailΒ (unique),ΒpasswordHashΒ (bcrypt),Βname?createdAt,ΒupdatedAtemailVerified?Β or verification helper endpoints
Conversation
userIdΒ (ref User; omitted for guest)titlemessages[]Β ofΒ{ role: 'user' | 'assistant', content: string, ts }createdAt,ΒupdatedAt
Ephemeral Conversations
Utility (
utils/ephemeralConversations.ts) handles non-authenticated chat state without DB writes.
OpenAPI:Β openapi.yamlΒ (repo root). Import into Swagger UI/Postman.
Deployed Swagger: at the backend host (e.g.,Β /docs).
POST /api/auth/signupΒ β create account
Body:Β{ email, password, name? }
Returns:Β{ token, user }POST /api/auth/loginΒ β authenticate
Body:Β{ email, password }Β βΒ{ token, user }GET /api/auth/verify-email?email=<addr>Β β email existence checkPOST /api/auth/reset-passwordΒ β start/reset flow (implementation depends on env)
Example
curl -X POST "$API/api/auth/login" \
-H "Content-Type: application/json" \
-d '{"email":"me@example.com","password":"secret"}'
UseΒ Authorization: Bearer <token>Β for subsequent protected requests.
POST /api/conversationsΒ β create new conversation
Body:Β{ title? }Β βΒ{ conversation }GET /api/conversationsΒ β list all for userGET /api/conversations/:idΒ β get by idPUT /api/conversations/:idΒ β rename
Body:Β{ title }GET /api/conversations/search/:queryΒ β title/content searchDELETE /api/conversations/:idΒ β delete
-
POST /api/chatΒ β send a user message and get AI response
Body:Β{ message: string, conversationId?: string }
Returns:Β{ reply, conversationId? }Authenticated users: message persisted to conversation
Guests: handled via ephemeral store
# From server/:
npm run store
# or
npx ts-node src/scripts/storeKnowledge.ts
Reads your knowledge sources (implementation specific)
Splits/embeds documents
Upserts vectors intoΒ PineconeΒ (
PINECONE_INDEX_NAME)
Tip: Re-run after updating the knowledge base.
Embed incoming user query.
Pinecone similarity search (cosine) β top-k chunks.
Assemble prompt (system instructions + retrieved context + user query).
Call configured LLM (OpenAI/Gemini).
Stream/return markdown answer; persist if authenticated.
Pages: Landing, Home (chat), Login, Signup, Forgot Password, 404
Components:Β
Navbar,ΒSidebarΒ (collapsible, lists conversations),ΒChatAreaTheme: Light/Dark with localStorage persistence
Guest Mode: Skip auth; ephemeral conversations only
Workflow inΒ .github/workflows/:
Install deps (client & server)
Lint,Β JestΒ tests
Build apps
-
Deploy:
FE βΒ VercelΒ (primary) +Β NetlifyΒ (backup)
BE βΒ Vercel
Artifacts upload, notifications on success/failure
Required secretsΒ (examples):Β
VERCEL_TOKEN,ΒVERCEL_PROJECT_ID_(client/server),ΒNETLIFY_AUTH_TOKEN, etc., plus runtime env for both apps. Configure inΒ Repo Settings β Secrets and variables β Actions.
Present for legacy/alt CI; prefer GitHub Actions unless org mandates Jenkins.
-
Prepare secretsΒ in Vercel/Netlify dashboards:
Server:Β
MONGODB_URI,ΒJWT_SECRET,ΒPINECONE_*,ΒAI_INSTRUCTIONS,ΒGOOGLE_AI_API_KEYClient:Β
REACT_APP_API_BASE_URL
TriggerΒ a release by merging to the main branch.
-
Verify:
Backend health: openΒ
/docsΒ and testΒ/api/auth/loginΒ with a test user.Frontend health: loadΒ
/Β andΒ/chat.
-
Smoke test RAG:
Ask a question covered by the knowledge base; verify grounded response.
Rollback: Revert the commit or redeploy a prior successful build from Vercel/Netlify dashboards.
JWT: Signed withΒ
JWT_SECRET. Store tokens only inΒ memoryΒ orΒ secure storageΒ on the client; avoid localStorage if possible.Password hashing: Use bcrypt (or argon2) server-side.
CORS: Restrict origins in production.
PII: User emails are stored; conversation content may include sensitive dataβensure your privacy notice covers this.
Rate limiting: Recommended forΒ
/api/chatΒ and auth routes.Secrets management: Use platform secret managers; never commit secrets.
License: MIT (seeΒ
LICENSE).
Frontend
cd client
npm test
Backend
cd server
npm test
Add integration tests for:
Auth flow (signup/login/jwt guard)
Conversation CRUD
Chat happy path + RAG retrieval stubs/mocks