Core Concept Behind the Memory ArchitectureShort-Term Memory (STM): Managed via a rolling Redis cache buffer and database-backed sliding window session context. This keeps the immediate conversation snippet (
+-------------------------------------------+
| React Client |
+-------------------+-----------------------+
| (Prompt Input)
v
+-------------------+-----------------------+
| Express API Gateway |
+-------------------+-----------------------+
|
+-------------------------+-------------------------+
| (Fetch Current Window) | (Semantic Vector Query)
v v
+--------+----------------+ +--------+----------------+
| Short-Term Memory | | Long-Term Memory |
| - Redis Buffer Cache | | - Vector Embeddings |
| - Recent Context (10k) | | - Historical Facts |
+--------+----------------+ +--------+----------------+
| |
+-------------------------+-------------------------+
| (Injected Context Matrix)
v
+-------------+-------------+
| Large Language Model |
+---------------------------+
The Ingestion Flow: User sends a message -> Gateway queries STM for the trailing thread window -> Gateway simultaneously sends embeddings of the message to the Vector DB to surface relevant historical contexts (LTM).Context Compilation: LTM facts + STM threads + System Prompts are compiled into an optimized prompt payload and passed to the LLM.The Consolidation Phase: Periodic background workers parse old conversations, summarize redundant threads, and write them permanently into the Vector Space while flushing expired STM entries.🛠️ Tech StackFrontend: React, Tailwind CSS v4, Vite, Axios, React Context API.Backend: Node.js, Express.js.Database & Storage: MongoDB (User accounts & message logs), Redis (Short-term cache layer).Vector Engine: Pinecone / MongoDB Atlas Vector Search (For semantic LTM retrieval).AI Integration: OpenAI API / LangChain framework (Text generation & text-embedding models).