Production Monorepo: Next.js 15 (React 19, Turbopack, Tailwind CSS v4, Motion) + FastAPI Agentic GraphRAG Backend (LangGraph, Knowledge Graph, Pinecone Vector Search, LLM Guardrails).
Created by Ahmed Bargady β PhD Student in AI & Cybersecurity at UM6P (Mohammed VI Polytechnic University).
This monorepo powers an AI-driven digital twin designed to answer complex technical, research, and career inquiries in real-time. Unlike standard RAG systems, it combines Agentic Corrective RAG (LangGraph), structured Knowledge Graphs, and AI Security Guardrails.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Next.js 15 Frontend (App Router) β
β Chat Interface β’ Knowledge Graph Viz β’ Security Hub β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β SSE / Stream
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI GraphRAG Server Endpoint β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
ββββββββββββββββββββ΄βββββββββββββββββββ
βΌ βΌ
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
β AI Security Shield β β LangGraph State Engineβ
β Prompt Leak & Injectionβ β Adaptive Routing Node β
ββββββββββββββββββββββββββ βββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
βΌ βΌ
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
β Knowledge Graph β β Pinecone Vector DB β
β Multi-Hop Entity Facts β β Semantic Document RAG β
ββββββββββββββββββββββββββ ββββββββββββββββββββββββββ
- Adaptive Routing: Automatically detects query intent (Smalltalk, General Knowledge, Entity-Grounded, or Multi-hop Complex).
- Corrective Retrieval Loop: Grades retrieved facts; if context is insufficient, it rewrites the query dynamically and re-retrieves before generation.
- Hybrid Retrieval: Fuses deterministic Knowledge Graph subgraphs with high-dimensional vector embeddings for max recall and precision.
- Entity Linking: Maps research domains (APT Detection, Provenance Graphs, GNNs, Transformers) to papers, projects, and skills.
- Live Traversal Stream: Emits active graph paths alongside response streams, rendering interactive node topologies in the UI.
- Prompt Injection Defense: Pre-execution input classification blocking adversarial jailbreaks.
- System Prompt Leak Guard: Output stream monitoring to prevent sensitive context disclosure.
- Rate Limiting & Red-Teaming Suite: Built-in endpoints for automated security evaluation.
- Data Privacy & Open-Source Audit: All biography, research, and project knowledge base files stored under
backend/data/are 100% sanitized, public-ready, and clean of private credentials, SSH keys, or confidential secrets.
GraphRAGPortfolio/
βββ frontend/ # Next.js 15 (React 19, Turbopack, Tailwind CSS v4, Motion, Lucide)
β βββ src/
β β βββ app/ # App router pages (Home, Chat, Security Showcase)
β β βββ components/ # Interactive Graph, Chat UI, Reasoning Trace, Terminal components
β β βββ store/ # Zustand state management
β βββ package.json
β
βββ backend/ # FastAPI Python Backend
β βββ agent/ # LangGraph state machine & Corrective RAG pipeline
β βββ kg/ # Knowledge graph schema, networkx, & store
β βββ security/ # Red-teaming scripts, guardrails, & rate limiters
β βββ data/ # Research documents, papers, & bio knowledge base
β βββ config.py # Centralized model & server configuration
β βββ requirements.txt
β
βββ package.json # Root npm workspace & script orchestration
βββ turbo.json # Turborepo task pipeline configuration
βββ .gitignore
βββ .env.example
- Node.js:
v20+ - npm or pnpm
- Python:
v3.10+
Clone the repository and install root workspace dependencies:
git clone https://github.com/AhmedCoolProjects/GraphRAGPortfolio.git
cd GraphRAGPortfolio
# Install Node dependencies for all workspaces
npm installSet up Python virtual environment for the backend:
cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cd ..Copy .env.example to set up environment variables:
cp .env.example .envConfigure your environment variables:
GROQ_API_KEY: Groq API Key for fast LLM inference.PINECONE_API_KEY: Pinecone Vector Store API Key.NEXT_PUBLIC_CHAT_API_URL: Backend URL (e.g.http://localhost:8000).
Run both Frontend and Backend concurrently with Turborepo:
npm run dev- Frontend:
http://localhost:3000 - Backend API:
http://localhost:8000 - Swagger Docs:
http://localhost:8000/docs
This project is licensed under the MIT License β see the LICENSE file for details.