How adarshukla3005/portfolio works
Project Type and Purpose
• Type: Full-stack portfolio website with a static frontend, serverless API endpoints, and a small Node.js backend for AI chatbot integration.
• Purpose: Serve static portfolio content (HTML/CSS/JS), provide an AI-powered chatbot via Google Gemini, implement RAG with an in-memory vector store, and deploy on Netlify (or any hosting).
Main Components
a. Frontend
– index.html, css/, scss/, js/, lib/, images/, fonts/
– Bundled SCSS→CSS build step (Prepros or npm scripts)
– Served as static assets via CDN/Netlify
b. Serverless Functions (Netlify Functions)
– netlify/functions/chatbot.js & test.js
– Exposed as HTTPS endpoints (e.g., /.netlify/functions/chatbot)
– Handle incoming user prompts, call backend logic
c. Node.js Backend (Express)
– server.js, package.json
– Also provides a dev server, fallback API routes, and RAG logic
– Depends on environment vars (PORT, GEMINI_API_KEY)
d. In-Memory Vector Store
– Stores indexed text snippets from portfolio content
– Performs vector similarity lookups for RAG
e. External AI Service
– Google Gemini API (Generative AI)
– Invoked by serverless functions / Express routes
f. Deployment & Hosting
– Netlify for static frontend & functions (netlify.toml)
– Optionally AWS/Azure/GCP or traditional hosting for server.js
Relationships and Data Flows
1. User’s Browser → CDN/Netlify
• Requests static HTML, CSS, JS
2. Frontend Chat Widget → Serverless Function Endpoint
• AJAX call to /chatbot function with user message
3. Serverless Function → In-Memory Vector Store
• Lookup top-K relevant snippets via cosine similarity
4. Serverless Function → Gemini API
• Send retrieved context + user question → receive generated answer
5. Serverless Function → Frontend
• Return response JSON to be rendered in chat UI
6. (Fallback) Frontend/API → Express Server
• During local dev or non-Netlify deploy, calls hit Express routes in server.js
Architectural Patterns and Principles
• Static Site + Serverless Backend (Jamstack)
• Retrieval-Augmented Generation (RAG) for chatbot
• Separation of Concerns:
– Static assets isolated from compute functions
– AI logic encapsulated in functions or Express middleware
• In-memory vector store for low-latency retrieval (no external DB)
Final Checklist
• Components: Frontend, Serverless Fns, Express Server, Vector Store, Gemini API
• Labels: Protocols, file/folder names (optional) for clarity