An intelligent HR chatbot platform with a Next.js frontend and NestJS backend, designed to provide a simple OpenAI-style chat experience. The system supports both MongoDB Atlas with Vector Search and PostgreSQL with PGVector, enabling flexible and efficient data handling for AI-driven applications.
Built using LangChain, LangGraph, OpenAI for embeddings and Claude AI for conversation, the project demonstrates how to integrate AI agent frameworks with scalable web technologies.
This project extends the official MongoDB tutorial Build a JavaScript AI Agent With LangGraph.js and MongoDB by showcasing a full-stack implementation with additional features, architectural best practices, and multi-database support.
Connect with me on LinkedIn
- Clean Architecture
- AI Agent Development: Implemented in NestJS with TypeScript, leveraging modular and extensible patterns
- Modern Frontend: Simple OpenAI-style chat interface built with Next.js, TypeScript, Shadcn UI, and TailwindCSS
- Multi-Database Support: Dual support for MongoDB Atlas + Vector Search and PostgreSQL + PGVector for structured and vector search capabilities
- Intelligent Conversations: Powered by Claude 4 Sonnet with LangGraph
- Semantic Search: Vector similarity search for employee information
- Conversation Memory: Persistent chat history using database-specific checkpointers
This is by no means a production-ready implementation, feel free to fork it and extend the development.
- Implement authentication, authorization and Role-Based Access Control (RBAC)
- Associate thread id's to the user
- Add unit and integration tests
- Implement Redis for caching purposes
- Node.js 18+ installed
- npm or yarn installed
- MongoDB Atlas account (free tier works)
- API Keys:
- Anthropic API key
- OpenAI API key
- Follow the Setup Steps before proceeding
- Start the frontend and backend using turbo from the project root folder
npm run dev
- Access the frontend interface via http://localhost:3000/
- Access the backend API Swagger Docs via http://localhost:3001/api/docs
npm install
Copy the template and fill in your values:
cd apps/backend
cp .env.template .env
Edit .env
and update MONGODB_URI
, ANTHROPIC_API_KEY
and OPENAI_API_KEY
:
# For MongoDB Atlas
MONGODB_ATLAS_URI=mongodb://admin:admin@localhost:27017
MONGODB_DB_NAME=hr_database
# For PostgreSQL
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=hr_database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
# Required API Keys
ANTHROPIC_API_KEY=sk-ant-xxx
OPENAI_API_KEY=sk-xxx
The PostgreSQL database with PGVector extension is created as a container via docker compose later in this setup guide.
MongoDB does not support Vector Search in local development, you have to create a MongoDB Atlas cluster hosted in their cloud environment, to use MongoDB as a Vector Database.
- Create a cluster at MongoDB Atlas
- Create database
hr_database
with collectionemployees
- Create vector search index named
vector_index
- Follow YouTube tutorial
- Use JSON configuration
{ "fields": [ { "numDimensions": 1536, "path": "embedding", "similarity": "cosine", "type": "vector" } ] }
NOTE: OpenAI requires 1536 number of dimensions, by default, the length of >the embedding vector is 1536.
- Whitelist your IP address (should be done automatically)
This will stand-up the containers for the PostgreSQL database, MongoDB database, and PGAdmin.
docker-compose up -d
docker-compose down
docker-compose down -v
Connection Details:
- Host:
localhost
via local client ORhr-postgres
via PGAdmin container - Port:
5432
- Database:
hr_database
- Username:
postgres
- Password:
postgres
Note: When connecting from pgAdmin to PostgreSQL, use the container name hr-postgres
as the hostname, NOT localhost
. This is because pgAdmin runs inside Docker and needs to connect through the Docker network.
Connection Details:
- Host:
localhost
- Port:
27017
- Database:
hr_database
- Username:
admin
- Password:
admin
- Conneciton string:
mongodb://admin:admin@localhost:27017/
Run the apps/backend/package.json scripts.
cd apps/backend
npm run seed:postgres
cd apps/backend
npm run seed:mongodb