A modern, high-performance developer portfolio website integrated with a secure administrative Content Management System (CMS) and a production-grade AI chat assistant. Built using Next.js, Tailwind CSS 4, and MongoDB, the platform features smooth 3D elements, dynamic drag-and-drop reordering, and a vector-backed RAG (Retrieval-Augmented Generation) pipeline for context-aware portfolio assistance.
- โจ Features
- ๐๏ธ System Design Architecture
- ๐ Application Workflows
- ๐ ๏ธ Tech Stack
- ๐ Project Structure
- ๐ Getting Started
- ๐ฎ Future Roadmap: AI Agent + MCP
- ๐ค Contributing
- ๐จ Modern & Responsive Design: Styled using Tailwind CSS 4 and Shadcn/ui for fluid, responsive layouts optimized for all screens.
- โจ Immersive Visuals: Fluid animations powered by Framer Motion and responsive 3D elements utilizing Three.js (
@react-three/fiberand@react-three/drei). - ๐ Dynamic Content Showcase: Projects, skills, intros, and certificates are served dynamically from a MongoDB database.
- ๐ค Intelligent AI Assistant: A floating interactive chat widget that:
- Hybrid Intent Detection: Detects user query intent (Fast Path: rule-based keywords | Slow Path: Gemini 2.5 Flash semantic classification) to filter out greetings, projects, skills, contact info, bio, or general chats.
- Dynamic Metadata Filtering: Uses query intent to filter Pinecone search results by category (
project,skill,contact, etc.) and dynamically adjusts search depth (k) for summaries vs. specific items. - Real-Time Streaming: Streams answers token-by-token with support for mid-stream cancellation via
AbortController. - Persistent Session Memory: Persists conversation context and history per session directly in MongoDB.
- Anti-Hallucination Guardrails: Employs strict system prompts ensuring answers are grounded only in verified portfolio context.
- ๐ง Seamless Contact Form: Direct email notifications using the Resend API.
- ๐ Secure Authentication: Protected dashboard routes utilizing NextAuth.js.
- ๐ Comprehensive CRUD Dashboards: Complete management interface for updating introduction texts, project entries, skill sets, blogs, and certificates.
- โ Drag & Drop Reordering: Intuitive sorting of skills and projects powered by
@dnd-kit. - โ๏ธ Cloud-Based Media Management: Seamless image uploads and background cleanup using the Cloudinary SDK.
- โก Web-Based Vector Ingestion: Rebuild, purge, and seed the Pinecone vector index dynamically via
/api/ingestHTTP GET requests.
The project is structured around an intent-routed search model where client queries are classified before performing Pinecone queries:
graph TD
%% User/Client Interaction
User[Web Browser / Visitor] <-->|1. HTTP / SSE Stream| NextApp[Next.js App Router]
Admin[Admin Owner] <-->|Updates Content / Sorts| NextAdmin[Admin CMS Dashboard]
%% Next.js Core Routes
subgraph NextServer [Next.js Backend Server]
NextApp -->|POST Chat Message| ChatAPI[Chat Route: api/chat/route.ts]
NextAdmin -->|CRUD Content| AdminAPIs[Admin API Routes]
NextAdmin -->|HTTP GET Seed| IngestAPI[Ingest Route: api/ingest/route.ts]
end
%% Intent Routing & RAG
subgraph AIWorkflow [AI Workflow & Routing]
ChatAPI -->|1. Parse Message| Intent[Intent Detector: lib/intent.ts]
Intent -->|Rule-based OR LLM Classifier| IntentType{Query Intent}
IntentType -->|project/skill/about/etc.| Filter[Apply Metadata Filter & K]
ChatAPI -->|2. Query Index with Filter| VectorStore[Pinecone Vector Database]
ChatAPI -->|3. Get History| Memory[MongoDB Chat History]
ChatAPI -->|4. Generate Response| LLM[Google Gemini 2.5 Flash]
end
%% Databases
subgraph Databases [Data Storage]
AdminAPIs <-->|Store / Fetch| MongoDB[(MongoDB Database)]
Memory <--> MongoDB
VectorStore <-->|Index Vectors| PineconeIndex[Pinecone Vector Index]
end
%% External Services
subgraph Services [External Services]
AdminAPIs <-->|Upload Media| Cloudinary[Cloudinary SDK]
NextApp -->|Send Emails| Resend[Resend API]
LLM <-->|API Calls| GeminiAPI[Google Generative AI]
end
%% Ingestion Sync
IngestAPI -->|Clear & Pull Core Data| MongoDB
IngestAPI -->|HF Lazy Embeddings| HF[HuggingFace Inference API]
HF -->|all-MiniLM-L6-v2| IngestAPI
IngestAPI -->|Embed Summaries & Data| PineconeIndex
IngestScript[scripts/ingest.ts] -->|CLI Sync Fallback| MongoDB
IngestScript -->|HF Embeddings| PineconeIndex
To make the AI Chat Assistant knowledgeable, project metadata must be embedded and indexed:
- CMS Update: The admin updates or adds content in the Admin dashboard.
- Database Sync: The data is persisted in MongoDB.
- Index Generation & Seeding:
- Method A (HTTP Web Ingestion): The admin requests the
/api/ingestendpoint. The route validates or builds the Pinecone index, clears old data to prevent stale duplicates, compiles MongoDB records into document chunks, generates embeddings using HuggingFace (sentence-transformers/all-MiniLM-L6-v2), and uploads them. - Method B (CLI Script): The administrator runs
npx tsx scripts/ingest.tsdirectly from the command line.
- Method A (HTTP Web Ingestion): The admin requests the
- Structured Summaries: The ingestion process automatically injects pre-compiled overview documents (e.g., "Projects Overview & Summary" and "Skills Overview & Summary") to ensure aggregate count and listing queries return accurate stats.
- Static Contact Ingestion: Embedded contact channels and social profiles are seeded as dedicated index documents for contact-intent queries.
When a visitor interacts with the floating AI Chat Widget:
- Message Dispatch: The client sends the prompt along with a unique
sessionIdtoapi/chat/route.ts. - Session Memory Retrieval: The API fetches the last 10 chat messages associated with the
sessionIdfrom MongoDB to maintain conversation context. - Intent Detection: The message passes through a hybrid classifier:
- Fast Path: Resolves greetings, contact information, identity, bios, skills, and projects instantly using keyword pre-filtering rules.
- Slow Path: Falls back to calling Gemini 2.5 Flash as a zero-temperature semantic classifier to categorize the message.
- Dynamic Metadata Filtering:
- If the intent matches
project,skill,about,intro, orcontact, the API configures a Pinecone metadata filter targeting that specific document type. - The lookup depth
kis adjusted dynamically:k=8for broad listing queries (like "list all projects"),k=1for single-document profile queries, andk=3for general similarity matching.
- If the intent matches
- Context Retrieval: The API queries Pinecone using the lazy-loaded HuggingFace embeddings client with the calculated filter and
k. - Prompt Engineering & Grounding: All pieces of data (retrieved Pinecone segments and chat history) are formatted into the LangChain system prompt template.
- LLM Chain & Streaming: The prompt is processed by Google Gemini 2.5 Flash, and the response is streamed back to the client using Server-Sent Events (SSE). The assistant response is saved back to MongoDB upon completion.
| Layer | Technologies |
|---|---|
| Frontend | Next.js 15/16 (App Router), React 19, Tailwind CSS 4, Framer Motion, Three.js (@react-three/fiber), Shadcn/ui |
| Backend | Next.js Route Handlers, NextAuth.js (Security), MongoDB (Database), Mongoose (ODM) |
| AI & RAG | LangChain.js (Chains & Orchestration), Pinecone (Vector Database), Google Gemini 2.5 Flash (LLM), HuggingFace Inference API (all-MiniLM-L6-v2 embeddings) |
| Services & Tools | Cloudinary (Image hosting), Resend (Emailing), @dnd-kit (Drag-and-drop sorting), ESLint, TSX |
src/
โโโ app/
โ โโโ (admin)/ # Protected admin routes (Dashboard, Project & Skill CMS)
โ โโโ (main)/ # Public facing routes (Home, Projects list, Contact form)
โ โโโ api/
โ โ โโโ chat/ # AI Chat endpoint (hybrid RAG with Intent Routing & SSE streaming)
โ โ โโโ ingest/ # HTTP Vector Store synchronization endpoint (Clear -> Seed Index)
โ โ โโโ ... # Next.js API Routes (auth, projects, skills, email, upload)
โ โโโ globals.css # Global CSS definitions & variables
โ โโโ layout.tsx # Root App Router Layout
โโโ components/
โ โโโ GlobalChatWidget.tsx # Floating AI chat sidebar/widget
โ โโโ MarkdownRender.tsx # Custom markdown parser for streamed response output
โ โโโ ... # Reusable UI parts (Shadcn/custom)
โโโ hooks/ # Custom React state/utility hooks
โโโ types/ # TypeScript interfaces
โโโ middleware.ts # Auth interceptor middleware
lib/ # Backend utilities
โโโ db.ts # Mongoose DB connector
โโโ auth.ts # NextAuth Configuration
โโโ prompt.ts # System prompt template with anti-hallucination instructions
โโโ memory.ts # Persistent chat history handlers
โโโ intent.ts # Hybrid Intent Classifier (Rule-based + LLM Fallback)
โโโ embeddings.ts # Lazy-loaded HuggingFace embed client wrapper
โโโ vectorStore.ts # Pinecone DB vector retriever wrappers (with metadata filters)
โโโ pinecone.ts # Pinecone Client initialization & index checker
โโโ delete-image.ts # Cloudinary asset purge helper
models/ # Mongoose Models
โโโ user.model.ts # Admin User accounts
โโโ intro.model.ts # Title, short description and key details
โโโ about.model.ts # Detailed bio text
โโโ skill.model.ts # Tech skills tagged with categories
โโโ project.model.ts # Featured projects with links and tags
โโโ certificate.model.ts # Course completion credentials
โโโ chatMessage.model.ts # Persisted chat conversation sessions
โโโ blog.model.ts # Custom blog posts
scripts/
โโโ ingest.ts # Data sync CLI pipeline (MongoDB -> HuggingFace -> Pinecone Store)Follow these steps to spin up the codebase in your local development environment.
- Node.js (v18.x or higher)
- MongoDB Database Instance (Local or MongoDB Atlas)
- Pinecone Index (Vector Dimension: 384 for
all-MiniLM-L6-v2)
git clone https://github.com/your-username/your-repository-name.git
cd your-repository-name
npm installCreate a .env file in the root directory and configure it as follows:
# MongoDB Connection
MONGODB_URI="your_mongodb_connection_string"
# NextAuth Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your_nextauth_secret_hash" # Generate using: openssl rand -base64 32
# Cloudinary Integration (Image Uploads)
CLOUDINARY_CLOUD_NAME="your_cloudinary_cloud_name"
CLOUDINARY_API_KEY="your_cloudinary_api_key"
CLOUDINARY_API_SECRET="your_cloudinary_api_secret"
# Resend API (Contact Form Emailer)
RESEND_API_KEY="your_resend_api_key"
# Base URL Configuration
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
# AI Model Keys (Google Gemini)
GOOGLE_API_KEY="your_google_api_key"
# Pinecone Credentials
PINECONE_API_KEY="your_pinecone_api_key"
PINECONE_INDEX_NAME="portfolio-ai"
# HuggingFace Credentials (For Embeddings Generation)
HUGGINGFACE_API_KEY="your_huggingface_api_key"To index your database content into the Pinecone vector database, choose one of the following methods:
-
Method A (Web Route): Run the server (
npm run dev) and visit:http://localhost:3000/api/ingestThis will dynamically build/reset the Pinecone index and seed the data, outputting JSON stats upon completion.
-
Method B (CLI Command): Run the ingestion script directly:
npx tsx scripts/ingest.ts
npm run devOpen http://localhost:3000 inside your browser to inspect the result.
Note
The current system leverages a static Retrieval-Augmented Generation (RAG) pipeline. While effective for simple question-answering, it lacks active tool execution, multi-step planning, and dynamic contextual awareness.
In the next phase of development, this workflow will be migrated to an autonomous AI Agent + Model Context Protocol (MCP) architecture:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Future Agent UI โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Prompts / Tasks
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Autonomous AI Agent โ
โ (Planning Loop, Tool Call Parsing, State Management) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP JSON-RPC Protocol
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Router / Hub โ
โโโโโโโฌโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
โ MongoDB โ โ Filesystemโ โ Git / โ
โ MCP Serverโ โ MCP Serverโ โ API Serverโ
โโโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโ
- Dynamic Tool Calling:
Instead of injecting static text from the DB and vector search blindly into a single prompt, the LLM will act as an AI Agent. It will decide dynamically which tools to execute based on what the user asks (e.g., calling
query_projects_by_categoryorfetch_recent_blogs). - Integrating Model Context Protocol (MCP):
- MCP is an open standard that enables LLMs to access data sources and tools securely.
- We will deploy custom MCP Servers connected directly to the codebase's subsystems:
- Database MCP Server: Exposes secure read/write queries to MongoDB for real-time querying without manual pipeline code in our API routes.
- Filesystem MCP Server: Allows the agent to inspect project documentation, assets, or markdown files directly.
- GitHub MCP Server: Fetches live commit histories, repository statistics, and star counts dynamically during chat.
- Expanded Agentic Actions:
The agent will gain the ability to perform complex workflows. Examples:
- โSchedule a meeting with me next Mondayโ -> Agent triggers a Calendly/Google Calendar MCP tool.
- โAdd a new project from this descriptionโ -> Agent runs validation tools and invokes the DB MCP Server to write the entry directly (with admin approval).
- โBuild a custom resume PDF highlighting my React experienceโ -> Agent compiles a custom resume using styling templates and exports it.
Contributions make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project.
- Create your Feature Branch (
git checkout -b feature/AmazingFeature). - Commit your Changes (
git commit -m 'Add some AmazingFeature'). - Push to the Branch (
git push origin feature/AmazingFeature). - Open a Pull Request.