This project demonstrates a production-ready chatbot backend using:
- Node.js + TypeScript
- MongoDB (conversation + long-term memory)
- MongoDB Atlas Vector Search (semantic memory)
- OpenAI LLM
- Conversational memory
- Semantic recall using vector search
- Long-term fact extraction
- Clean architecture (API / Application / Domain / Infra)
- Easily extensible for agents, tools, RBAC
Before running, create the memory_index on your memories collection with the following mapping:
{
"fields": [
{
"numDimensions": 768,
"path": "embedding",
"similarity": "cosine",
"type": "vector"
},
{
"path": "userId",
"type": "filter"
},
{
"path": "importance",
"type": "filter"
}
]
}Refer to MongoDB Atlas documentation for details on creating vector indexes.
npm install
cp .env.example .env
npm run devPOST /chat
{
"userId": "user1",
"message": "My name is Yogesh"
}